MCPcopy Create free account
hub / github.com/CyCoreSystems/ari-proxy / TestEndpointData

Function TestEndpointData

internal/integration/endpoint.go:76–126  ·  view source on GitHub ↗
(t *testing.T, s Server)

Source from the content-addressed store, hash-verified

74}
75
76func TestEndpointData(t *testing.T, s Server) {
77 runTest("ok", t, s, func(t *testing.T, m *mock, cl ari.Client) {
78 var expected ari.EndpointData
79 expected.State = "st1"
80 expected.Technology = "tech1"
81 expected.Resource = "resource"
82
83 h1 := ari.NewEndpointKey(expected.Technology, expected.Resource)
84
85 m.Endpoint.On("Data", h1).Return(&expected, nil)
86
87 data, err := cl.Endpoint().Data(h1)
88 if err != nil {
89 t.Errorf("Error in remote Endpoint Data call: %s", err)
90 }
91 if data == nil {
92 t.Errorf("Expected data to be non-nil")
93 } else {
94 failed := false
95 failed = failed || expected.State != data.State
96 failed = failed || expected.Resource != data.Resource
97 failed = failed || expected.Technology != data.Technology
98 if failed {
99 t.Errorf("Expected '%v', got '%v'", expected, data)
100 }
101 }
102
103 m.Endpoint.AssertCalled(t, "Data", h1)
104 })
105
106 runTest("err", t, s, func(t *testing.T, m *mock, cl ari.Client) {
107 var expected ari.EndpointData
108 expected.State = "st1"
109 expected.Technology = "tech1"
110 expected.Resource = "resource"
111
112 h1 := ari.NewEndpointKey(expected.Technology, expected.Resource)
113
114 m.Endpoint.On("Data", h1).Return(nil, errors.New("error"))
115
116 data, err := cl.Endpoint().Data(h1)
117 if err == nil {
118 t.Errorf("Expected error in remote Endpoint Data call")
119 }
120 if data != nil {
121 t.Errorf("Expected data to be nil")
122 }
123
124 m.Endpoint.AssertCalled(t, "Data", h1)
125 })
126}

Callers 2

TestEndpointDataFunction · 0.92
TestEndpointDataFunction · 0.92

Calls 4

runTestFunction · 0.85
EndpointMethod · 0.80
NewMethod · 0.80
DataMethod · 0.45

Tested by

no test coverage detected