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

Function TestInitLatencyCmd

cmd/latency_test.go:23–56  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

21)
22
23func TestInitLatencyCmd(t *testing.T) {
24 testCases := map[string]struct {
25 args []string
26 gotexp func() (interface{}, interface{})
27 }{
28 // Common flags
29 "from": {[]string{"--from", "Europe"}, func() (interface{}, interface{}) { return from, "Europe" }},
30 "nodeid": {[]string{"--nodeid", "1,2,3"}, func() (interface{}, interface{}) { return nodeIDs, []int{1, 2, 3} }},
31 "json": {[]string{"--json"}, func() (interface{}, interface{}) { return outputJSON, true }},
32
33 "limit": {[]string{"--limit", "23"}, func() (interface{}, interface{}) { return latencyLimit, 23 }},
34 "ipv6": {[]string{"--ipv6"}, func() (interface{}, interface{}) { return latencyIpv6, true }},
35 }
36 parent := &cobra.Command{}
37 for name, tc := range testCases {
38 t.Run(name, func(t *testing.T) {
39 latencyCmd.ResetFlags()
40 initLatencyCmd(parent)
41 if err := latencyCmd.ParseFlags(tc.args); err != nil {
42 t.Fatalf("exepected nil; got %v", err)
43 }
44 flags := latencyCmd.Flags()
45 f := flags.Lookup(name)
46 if f == nil {
47 t.Fatal("expected flag; got nil")
48 }
49
50 got, exp := tc.gotexp()
51 if reflect.DeepEqual(got, exp) == false {
52 t.Fatalf("expected %v; got %v", exp, got)
53 }
54 })
55 }
56}
57
58func TestRunLatency(t *testing.T) {
59 testCases := map[string]struct {

Callers

nothing calls this directly

Calls 1

initLatencyCmdFunction · 0.85

Tested by

no test coverage detected