MCPcopy Create free account
hub / github.com/basecamp/hey-cli / TestBareHeyShowsHelpWithoutTTY

Function TestBareHeyShowsHelpWithoutTTY

internal/cmd/writeok_test.go:15–32  ·  view source on GitHub ↗

TestBareHeyShowsHelpWithoutTTY verifies that bare `hey` falls back to help when either stdin or stdout is not a terminal (e.g. `hey | head`, cron, CI pipelines). In test context neither fd is a TTY, covering both gates.

(t *testing.T)

Source from the content-addressed store, hash-verified

13// when either stdin or stdout is not a terminal (e.g. `hey | head`, cron,
14// CI pipelines). In test context neither fd is a TTY, covering both gates.
15func TestBareHeyShowsHelpWithoutTTY(t *testing.T) {
16 root := newRootCmd()
17 var buf bytes.Buffer
18 root.SetOut(&buf)
19 root.SetArgs([]string{})
20
21 if err := root.Execute(); err != nil {
22 t.Fatalf("bare hey: %v", err)
23 }
24
25 out := buf.String()
26 if !strings.Contains(out, "USAGE") {
27 t.Errorf("expected help output with USAGE, got:\n%s", out)
28 }
29 if !strings.Contains(out, "hey <command>") {
30 t.Errorf("expected help to mention 'hey <command>', got:\n%s", out)
31 }
32}
33
34func TestWriteOKIncludesStats(t *testing.T) {
35 oldWriter, oldStats, oldSDKStats := writer, statsFlag, sdkStats

Callers

nothing calls this directly

Calls 2

newRootCmdFunction · 0.85
StringMethod · 0.80

Tested by

no test coverage detected