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

Function TestRunDNSPerf

cmd/dnsperf_test.go:59–88  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

57}
58
59func TestRunDNSPerf(t *testing.T) {
60 testCases := map[string]struct {
61 from string
62 nodeIDs []int
63 ipv6 bool
64 exp string
65 }{
66 "Location": {"From here", []int{}, false, `{"target":"example.com","dnsServer":"127.0.0.1","location":"From here","limit":12,"ipversion":4}`},
67 "NodeID": {"", []int{123}, false, `{"target":"example.com","dnsServer":"127.0.0.1","nodes":"123","limit":12,"ipversion":4}`},
68 "IPv6": {"", []int{}, true, `{"target":"example.com","dnsServer":"127.0.0.1","limit":12,"ipversion":6}`},
69 }
70 // We're only interested in the first HTTP call, e.g., the one to get the test ID
71 // to validate our parameters got passed properly.
72 tr := &recordingTransport{}
73 c, err := newTestPerfopsClient(tr)
74 if err != nil {
75 t.Fatalf("unexpected error %v", err)
76 }
77 for name, tc := range testCases {
78 t.Run(name, func(t *testing.T) {
79 runDNSPerf(c, "example.com", "127.0.0.1", tc.from, tc.nodeIDs, 12, tc.ipv6)
80 if got, exp := tr.req.URL.Path, "/run/dns-perf"; got != exp {
81 t.Fatalf("expected %v; got %v", exp, got)
82 }
83 if got, exp := reqBody(tr.req), tc.exp; got != exp {
84 t.Fatalf("expected %v; got %v", exp, got)
85 }
86 })
87 }
88}

Callers

nothing calls this directly

Calls 3

newTestPerfopsClientFunction · 0.85
runDNSPerfFunction · 0.85
reqBodyFunction · 0.70

Tested by

no test coverage detected