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

Function TestEndpointList

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

Source from the content-addressed store, hash-verified

8)
9
10func TestEndpointList(t *testing.T, s Server) {
11 runTest("ok", t, s, func(t *testing.T, m *mock, cl ari.Client) {
12 h1 := ari.NewEndpointKey("h1", "1")
13 h2 := ari.NewEndpointKey("h1", "2")
14
15 m.Endpoint.On("List", (*ari.Key)(nil)).Return([]*ari.Key{h1, h2}, nil)
16
17 list, err := cl.Endpoint().List(nil)
18 if err != nil {
19 t.Errorf("Error in remote Endpoint List call: %s", err)
20 }
21 if len(list) != 2 {
22 t.Errorf("Expected list of length 2, got %d", len(list))
23 }
24
25 m.Endpoint.AssertCalled(t, "List", (*ari.Key)(nil))
26 })
27
28 runTest("err", t, s, func(t *testing.T, m *mock, cl ari.Client) {
29 m.Endpoint.On("List", (*ari.Key)(nil)).Return([]*ari.Key{}, errors.New("error"))
30
31 list, err := cl.Endpoint().List(nil)
32 if err == nil {
33 t.Errorf("Expected error in remote Endpoint List call")
34 }
35 if len(list) != 0 {
36 t.Errorf("Expected list of length 0, got %d", len(list))
37 }
38
39 m.Endpoint.AssertCalled(t, "List", (*ari.Key)(nil))
40 })
41}
42
43func TestEndpointListByTech(t *testing.T, s Server) {
44 runTest("ok", t, s, func(t *testing.T, m *mock, cl ari.Client) {

Callers 2

TestEndpointListFunction · 0.92
TestEndpointListFunction · 0.92

Calls 4

runTestFunction · 0.85
EndpointMethod · 0.80
NewMethod · 0.80
ListMethod · 0.65

Tested by

no test coverage detected