MCPcopy Create free account
hub / github.com/ProspectOne/perfops-cli / TestRunListCmd

Function TestRunListCmd

cmd/list_test.go:18–53  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

16}
17
18func TestRunListCmd(t *testing.T) {
19 testCases := map[string]struct {
20 dataType string
21 url string
22 expectedErr interface{}
23 }{
24 "Countries": {"countries", "/analytics/dns/countries", nil},
25 "Cities": {"cities", "/analytics/dns/city", nil},
26 "Wrong type": {"country", "/analytics/dns/country", "no data with type 'country'"},
27 }
28
29 for name, tc := range testCases {
30 t.Run(name, func(t *testing.T) {
31 tr := &recordingTransport{}
32 c, err := newTestPerfopsClient(tr)
33 if err != nil {
34 t.Fatalf("unexpected error %v", err)
35 }
36
37 err = runListCmd(c, tc.dataType)
38
39 if tc.expectedErr != nil {
40 if tc.expectedErr != err.Error() {
41 t.Fatalf("expected %v error; got %v", tc.expectedErr, err)
42 }
43
44 // No reason to continue if we check for error case
45 return
46 }
47
48 if got, exp := tr.req.URL.Path, tc.url; got != exp {
49 t.Fatalf("expected %v; got %v", exp, got)
50 }
51 })
52 }
53}

Callers

nothing calls this directly

Calls 3

newTestPerfopsClientFunction · 0.85
runListCmdFunction · 0.85
ErrorMethod · 0.45

Tested by

no test coverage detected