MCPcopy Create free account
hub / github.com/github/gh-aw / TestParseSecretNames

Function TestParseSecretNames

pkg/cli/add_interactive_secrets_test.go:207–256  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

205}
206
207func TestParseSecretNames(t *testing.T) {
208 tests := []struct {
209 name string
210 input []byte
211 expected []string
212 }{
213 {
214 name: "single secret name",
215 input: []byte("MY_SECRET\n"),
216 expected: []string{"MY_SECRET"},
217 },
218 {
219 name: "multiple secret names",
220 input: []byte("SECRET_A\nSECRET_B\nSECRET_C"),
221 expected: []string{"SECRET_A", "SECRET_B", "SECRET_C"},
222 },
223 {
224 name: "empty output",
225 input: []byte(""),
226 expected: nil,
227 },
228 {
229 name: "output with only whitespace",
230 input: []byte(" \n \n"),
231 expected: nil,
232 },
233 {
234 name: "names with surrounding whitespace",
235 input: []byte(" MY_SECRET \n ANOTHER_SECRET "),
236 expected: []string{"MY_SECRET", "ANOTHER_SECRET"},
237 },
238 {
239 name: "output with blank lines interspersed",
240 input: []byte("FIRST_SECRET\n\nSECOND_SECRET\n\n"),
241 expected: []string{"FIRST_SECRET", "SECOND_SECRET"},
242 },
243 {
244 name: "trailing newline is handled correctly",
245 input: []byte("SECRET_ONE\nSECRET_TWO\n"),
246 expected: []string{"SECRET_ONE", "SECRET_TWO"},
247 },
248 }
249
250 for _, tt := range tests {
251 t.Run(tt.name, func(t *testing.T) {
252 result := parseSecretNames(tt.input)
253 assert.Equal(t, tt.expected, result, "parseSecretNames output should match expected")
254 })
255 }
256}
257
258func TestAddInteractiveConfig_checkExistingSecrets(t *testing.T) {
259 config := &AddInteractiveConfig{

Callers

nothing calls this directly

Calls 2

parseSecretNamesFunction · 0.85
RunMethod · 0.45

Tested by

no test coverage detected