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

Function TestApplicationData

internal/integration/application.go:42–79  ·  view source on GitHub ↗
(t *testing.T, s Server)

Source from the content-addressed store, hash-verified

40}
41
42func TestApplicationData(t *testing.T, s Server) {
43 key := ari.NewKey(ari.ApplicationKey, "1")
44 runTest("simple", t, s, func(t *testing.T, m *mock, cl ari.Client) {
45 ad := &ari.ApplicationData{}
46 ad.Name = "app1"
47
48 m.Application.On("Data", tmock.Anything).Return(ad, nil)
49
50 res, err := cl.Application().Data(key)
51 if err != nil {
52 t.Errorf("Unexpected error in remote Data call: %v", err)
53 }
54 if res == nil || res.Name != ad.Name {
55 t.Errorf("Expected application data name %s, got %s", ad, res)
56 }
57
58 m.Shutdown()
59 m.Application.AssertCalled(t, "Data", key)
60 })
61
62 runTest("error", t, s, func(t *testing.T, m *mock, cl ari.Client) {
63 expected := eris.New("unknown error")
64
65 m.Application.On("Data", key).Return(nil, expected)
66
67 res, err := cl.Application().Data(key)
68 if err == nil || eris.Cause(err).Error() != expected.Error() {
69 t.Errorf("Expected error '%v', got '%v'", expected, err)
70 }
71 if res != nil {
72 t.Errorf("Expected application data result to be empty, got %s", res)
73 }
74
75 m.Shutdown()
76
77 m.Application.AssertCalled(t, "Data", key)
78 })
79}
80
81func TestApplicationSubscribe(t *testing.T, s Server) {
82 key := ari.NewKey(ari.ApplicationKey, "1")

Callers 2

TestApplicationDataFunction · 0.92
TestApplicationDataFunction · 0.92

Calls 6

runTestFunction · 0.85
ApplicationMethod · 0.80
NewMethod · 0.80
CauseMethod · 0.65
DataMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected