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

Function TestShouldUseExpiring

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

Source from the content-addressed store, hash-verified

100}
101
102func TestShouldUseExpiring(t *testing.T) {
103 tests := []struct {
104 name string
105 configured string
106 flagValue *bool
107 want bool
108 }{
109 {
110 name: "disabled by default",
111 want: false,
112 },
113 {
114 name: "enabled by configuration",
115 configured: "enabled",
116 want: true,
117 },
118 {
119 name: "explicit flag enables disabled configuration",
120 configured: "disabled",
121 flagValue: new(true),
122 want: true,
123 },
124 {
125 name: "explicit flag disables enabled configuration",
126 configured: "enabled",
127 flagValue: new(false),
128 want: false,
129 },
130 {
131 name: "explicit flag and configuration both prefer expiring",
132 configured: "enabled",
133 flagValue: new(true),
134 want: true,
135 },
136 {
137 name: "explicit flag and configuration both disable expiring",
138 configured: "disabled",
139 flagValue: new(false),
140 want: false,
141 },
142 }
143
144 for _, tt := range tests {
145 t.Run(tt.name, func(t *testing.T) {
146 cfg := config.NewMockConfig()
147 if tt.configured != "" {
148 cfg.Set("github.com", "expiring_credentials", tt.configured)
149 }
150
151 require.Equal(t, tt.want, ShouldUseExpiring(cfg, tt.flagValue, "github.com"))
152 })
153 }
154}
155
156func TestLogin(t *testing.T) {
157 tests := []struct {

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected