Skip to content

Commit 8e131eb

Browse files
committed
fix test and case insensitivity
1 parent 62ada21 commit 8e131eb

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

cli/configssh.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ func (o *sshConfigOptions) addOption(option string) error {
7575
if err != nil {
7676
return err
7777
}
78-
if o.removedKeys != nil && o.removedKeys[key] {
78+
lowerKey := strings.ToLower(key)
79+
if o.removedKeys != nil && o.removedKeys[lowerKey] {
7980
// Key marked as removed, skip.
8081
return nil
8182
}
@@ -87,7 +88,7 @@ func (o *sshConfigOptions) addOption(option string) error {
8788
if o.removedKeys == nil {
8889
o.removedKeys = make(map[string]bool)
8990
}
90-
o.removedKeys[key] = true
91+
o.removedKeys[lowerKey] = true
9192
}
9293
return nil
9394
}

cli/configssh_internal_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -272,32 +272,32 @@ func Test_sshConfigOptions_addOption(t *testing.T) {
272272
},
273273
},
274274
{
275-
Name: "Replace",
275+
Name: "AddTwo",
276276
Start: []string{
277277
"foo bar",
278278
},
279279
Add: []string{"Foo baz"},
280280
Expect: []string{
281+
"foo bar",
281282
"Foo baz",
282283
},
283284
},
284285
{
285-
Name: "AddAndReplace",
286+
Name: "AddAndRemove",
286287
Start: []string{
287-
"a b",
288288
"foo bar",
289289
"buzz bazz",
290290
},
291291
Add: []string{
292292
"b c",
293+
"a=", // Remove all entries that start with "a", i.e. next line.
293294
"A hello",
294295
"hello world",
295296
},
296297
Expect: []string{
297298
"foo bar",
298299
"buzz bazz",
299300
"b c",
300-
"A hello",
301301
"hello world",
302302
},
303303
},

0 commit comments

Comments
 (0)