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

Function TestVersionFlag

cmd/root_test.go:87–108  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

85}
86
87func TestVersionFlag(t *testing.T) {
88 versionOutput := fmt.Sprintf(versionTmpl, version, buildDate, commitHash,
89 runtime.Version(), runtime.Compiler, runtime.GOOS, runtime.GOARCH)
90
91 var b bytes.Buffer
92 rootCmd.ResetFlags()
93 rootCmd.SetOutput(&b)
94 initRootCmd()
95
96 if err := rootCmd.ParseFlags([]string{"-v"}); err != nil {
97 t.Fatalf("exepected nil; got %v", err)
98 }
99 if got, exp := showVersion, true; got != exp {
100 t.Fatalf("expected %v; got %v", exp, got)
101 }
102 if err := rootCmd.Execute(); err != nil {
103 t.Fatalf("exepected nil; got %v", err)
104 }
105 if got, exp := b.String(), versionOutput; got != exp {
106 t.Fatalf("expected %q; got %q", exp, got)
107 }
108}
109
110func TestUsage(t *testing.T) {
111 var b bytes.Buffer

Callers

nothing calls this directly

Calls 2

initRootCmdFunction · 0.85
SetOutputMethod · 0.80

Tested by

no test coverage detected