package goonvif import ( "testing" "github.com/use-go/onvif" ) func TestListInterfaces(t *testing.T) { ifaces, err := listLocalNetworkInterfaces() if err != nil { t.Fatal(err) } t.Log(ifaces) } func TestDiscovery(t *testing.T) { devices, err := Discovery() if err != nil { t.Fatal(err) } for _, device := range devices { t.Log(device) } } func TestGetCapabilities(t *testing.T) { // 创建一个模拟的 Device 对象 d := &Device{ DeviceParams: onvif.DeviceParams{ Xaddr: "192.168.12.52", Username: "dctdev", Password: "dacenT2017", }, } // 测试正常情况 response, err := d.GetCapabilities() if err != nil { t.Errorf("Expected no error, got %v", err) } t.Log(response) // 模拟 check 函数返回错误 } func TestGetEndpoints(t *testing.T) { // 创建一个模拟的 Device 对象 d := &Device{ DeviceParams: onvif.DeviceParams{ Xaddr: "192.168.12.52", Username: "dctdev", Password: "dacenT2017", }, } response, err := d.GetEndpoints() if err != nil { t.Errorf("Expected no error, got %v", err) } t.Log(response) } func TestGetRecordingSummary(t *testing.T) { // 创建一个模拟的 Device 对象 d := &Device{ DeviceParams: onvif.DeviceParams{ Xaddr: "192.168.12.52", Username: "dctdev", Password: "dacenT2017", }, } response, err := d.GetRecordingSummary() if err != nil { t.Errorf("Expected no error, got %v", err) } t.Log(response) }