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

Function TestGetOrDefaultApplicationDefaults

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

Source from the content-addressed store, hash-verified

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