MCPcopy
hub / github.com/cli/cli / Test_setRun

Function Test_setRun

pkg/cmd/config/set/set_test.go:87–159  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

85}
86
87func Test_setRun(t *testing.T) {
88 tests := []struct {
89 name string
90 input *SetOptions
91 expectedValue string
92 stdout string
93 stderr string
94 wantsErr bool
95 errMsg string
96 }{
97 {
98 name: "set key value",
99 input: &SetOptions{
100 Config: config.NewBlankConfig(),
101 Key: "editor",
102 Value: "vim",
103 },
104 expectedValue: "vim",
105 },
106 {
107 name: "set key value scoped by host",
108 input: &SetOptions{
109 Config: config.NewBlankConfig(),
110 Hostname: "github.com",
111 Key: "editor",
112 Value: "vim",
113 },
114 expectedValue: "vim",
115 },
116 {
117 name: "set unknown key",
118 input: &SetOptions{
119 Config: config.NewBlankConfig(),
120 Key: "unknownKey",
121 Value: "someValue",
122 },
123 expectedValue: "someValue",
124 stderr: "! warning: 'unknownKey' is not a known configuration key\n",
125 },
126 {
127 name: "set invalid value",
128 input: &SetOptions{
129 Config: config.NewBlankConfig(),
130 Key: "git_protocol",
131 Value: "invalid",
132 },
133 wantsErr: true,
134 errMsg: "failed to set \"git_protocol\" to \"invalid\": valid values are 'https', 'ssh'",
135 },
136 }
137 for _, tt := range tests {
138 t.Run(tt.name, func(t *testing.T) {
139 _ = config.StubWriteConfig(t)
140
141 ios, _, stdout, stderr := iostreams.Test()
142 tt.input.IO = ios
143
144 err := setRun(tt.input)

Callers

nothing calls this directly

Calls 9

NewBlankConfigFunction · 0.92
StubWriteConfigFunction · 0.92
TestFunction · 0.92
EqualMethod · 0.80
ExpectMethod · 0.80
setRunFunction · 0.70
RunMethod · 0.65
GetOrDefaultMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected