MCPcopy Index your code
hub / github.com/cli/cli / Test_getRun

Function Test_getRun

pkg/cmd/config/get/get_test.go:79–132  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

77}
78
79func Test_getRun(t *testing.T) {
80 tests := []struct {
81 name string
82 input *GetOptions
83 stdout string
84 err error
85 }{
86 {
87 name: "get key",
88 input: &GetOptions{
89 Key: "editor",
90 Config: func() gh.Config {
91 cfg := config.NewBlankConfig()
92 cfg.Set("", "editor", "ed")
93 return cfg
94 }(),
95 },
96 stdout: "ed\n",
97 },
98 {
99 name: "get key scoped by host",
100 input: &GetOptions{
101 Hostname: "github.com",
102 Key: "editor",
103 Config: func() gh.Config {
104 cfg := config.NewBlankConfig()
105 cfg.Set("", "editor", "ed")
106 cfg.Set("github.com", "editor", "vim")
107 return cfg
108 }(),
109 },
110 stdout: "vim\n",
111 },
112 {
113 name: "non-existent key",
114 input: &GetOptions{
115 Key: "non-existent",
116 Config: config.NewBlankConfig(),
117 },
118 err: nonExistentKeyError{key: "non-existent"},
119 },
120 }
121
122 for _, tt := range tests {
123 ios, _, stdout, _ := iostreams.Test()
124 tt.input.IO = ios
125
126 t.Run(tt.name, func(t *testing.T) {
127 err := getRun(tt.input)
128 require.Equal(t, err, tt.err)
129 require.Equal(t, tt.stdout, stdout.String())
130 })
131 }
132}

Callers

nothing calls this directly

Calls 7

NewBlankConfigFunction · 0.92
TestFunction · 0.92
EqualMethod · 0.80
getRunFunction · 0.70
SetMethod · 0.65
RunMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected