MCPcopy Create free account
hub / github.com/cli/cli / TestShouldCopyToClipboard

Function TestShouldCopyToClipboard

pkg/cmd/auth/shared/login_flow_test.go:61–100  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

59}
60
61func TestShouldCopyToClipboard(t *testing.T) {
62 tests := []struct {
63 name string
64 configured string
65 flagValue *bool
66 want bool
67 }{
68 {
69 name: "enabled by default",
70 want: true,
71 },
72 {
73 name: "enabled by configuration",
74 configured: "enabled",
75 want: true,
76 },
77 {
78 name: "explicit flag enables disabled configuration",
79 configured: "disabled",
80 flagValue: new(true),
81 want: true,
82 },
83 {
84 name: "explicit flag disables enabled configuration",
85 configured: "enabled",
86 flagValue: new(false),
87 },
88 }
89
90 for _, tt := range tests {
91 t.Run(tt.name, func(t *testing.T) {
92 cfg := config.NewMockConfig()
93 if tt.configured != "" {
94 cfg.Set("", "clipboard", tt.configured)
95 }
96
97 require.Equal(t, tt.want, ShouldCopyToClipboard(cfg, tt.flagValue))
98 })
99 }
100}
101
102func TestShouldUseExpiring(t *testing.T) {
103 tests := []struct {

Callers

nothing calls this directly

Calls 5

NewMockConfigFunction · 0.92
ShouldCopyToClipboardFunction · 0.85
EqualMethod · 0.80
RunMethod · 0.65
SetMethod · 0.65

Tested by

no test coverage detected