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

Function TestConfigFromEnvInvalidOverride

internal/debug/config_test.go:74–100  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

72}
73
74func TestConfigFromEnvInvalidOverride(t *testing.T) {
75 tests := []struct {
76 name string
77 key string
78 value string
79 }{
80 {name: "invalid access lifetime", key: "GH_INTERNAL_AT_EXPIRES_IN", value: "invalid"},
81 {name: "invalid refresh lifetime", key: "GH_INTERNAL_RT_EXPIRES_IN", value: "invalid"},
82 {name: "fractional seconds", key: "GH_INTERNAL_AT_EXPIRES_IN", value: "1.5"},
83 {name: "duration overflow", key: "GH_INTERNAL_AT_EXPIRES_IN", value: "9223372037"},
84 {name: "duration underflow", key: "GH_INTERNAL_AT_EXPIRES_IN", value: "-9223372037"},
85 {name: "integer overflow", key: "GH_INTERNAL_RT_EXPIRES_IN", value: "9223372036854775808"},
86 {name: "empty lifetime", key: "GH_INTERNAL_AT_EXPIRES_IN", value: ""},
87 {name: "invalid boolean", key: "GH_INTERNAL_DEBUG_REFRESH_TOKEN", value: "enabled"},
88 {name: "empty boolean", key: "GH_INTERNAL_DEBUG_REFRESH_TOKEN", value: ""},
89 }
90 for _, tt := range tests {
91 t.Run(tt.name, func(t *testing.T) {
92 clearConfigEnv(t)
93 t.Setenv(tt.key, tt.value)
94
95 require.Panics(t, func() {
96 configFromEnv()
97 })
98 })
99 }
100}
101
102// clearConfigEnv unsets the debug variables for the test, so cases expecting no override are not affected by the
103// environment running the tests. t.Setenv registers the restore before the variable is unset.

Callers

nothing calls this directly

Calls 3

clearConfigEnvFunction · 0.85
configFromEnvFunction · 0.85
RunMethod · 0.65

Tested by

no test coverage detected