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

Function TestShouldCopyToClipboard

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

Source from the content-addressed store, hash-verified

33}
34
35func TestShouldCopyToClipboard(t *testing.T) {
36 tests := []struct {
37 name string
38 configured string
39 flagValue *bool
40 want bool
41 }{
42 {
43 name: "enabled by default",
44 want: true,
45 },
46 {
47 name: "enabled by configuration",
48 configured: "enabled",
49 want: true,
50 },
51 {
52 name: "explicit flag enables disabled configuration",
53 configured: "disabled",
54 flagValue: new(true),
55 want: true,
56 },
57 {
58 name: "explicit flag disables enabled configuration",
59 configured: "enabled",
60 flagValue: new(false),
61 },
62 }
63
64 for _, tt := range tests {
65 t.Run(tt.name, func(t *testing.T) {
66 cfg := config.NewMockConfig()
67 if tt.configured != "" {
68 cfg.Set("", "clipboard", tt.configured)
69 }
70
71 require.Equal(t, tt.want, ShouldCopyToClipboard(cfg, tt.flagValue))
72 })
73 }
74}
75
76func TestLogin(t *testing.T) {
77 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