MCPcopy
hub / github.com/cli/cli / TestGetOrDefaultApplicationDefaults

Function TestGetOrDefaultApplicationDefaults

internal/config/config_test.go:38–65  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

36}
37
38func TestGetOrDefaultApplicationDefaults(t *testing.T) {
39 tests := []struct {
40 key string
41 expectedDefault string
42 }{
43 {gitProtocolKey, "https"},
44 {editorKey, ""},
45 {promptKey, "enabled"},
46 {pagerKey, ""},
47 {httpUnixSocketKey, ""},
48 {browserKey, ""},
49 }
50
51 for _, tt := range tests {
52 t.Run(tt.key, func(t *testing.T) {
53 // Given we have no top level configuration
54 cfg := newTestConfig()
55
56 // When we get a key that has no value, but has a default
57 optionalEntry := cfg.GetOrDefault("", tt.key)
58
59 // Then there is an entry with the default value, and source set as default
60 entry := optionalEntry.Expect(fmt.Sprintf("expected there to be a value for %s", tt.key))
61 require.Equal(t, tt.expectedDefault, entry.Value)
62 require.Equal(t, gh.ConfigDefaultProvided, entry.Source)
63 })
64 }
65}
66
67func TestGetOrDefaultNonExistentKey(t *testing.T) {
68 // Given we have no top level configuration

Callers

nothing calls this directly

Calls 5

newTestConfigFunction · 0.85
ExpectMethod · 0.80
EqualMethod · 0.80
RunMethod · 0.65
GetOrDefaultMethod · 0.65

Tested by

no test coverage detected