-
Notifications
You must be signed in to change notification settings - Fork 409
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
17feddb
commit e2536ad
Showing
4 changed files
with
87 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package config | ||
|
||
import ( | ||
"reflect" | ||
"testing" | ||
) | ||
|
||
func Test_keysWithColons(t *testing.T) { | ||
type args struct { | ||
list []string | ||
} | ||
tests := []struct { | ||
name string | ||
args args | ||
want []string | ||
}{ | ||
{"0", args{list: []string{""}}, nil}, | ||
{"1", args{list: []string{"none"}}, nil}, | ||
{"2", args{list: []string{"a:b"}}, []string{"a:b"}}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
if got := keysWithColons(tt.args.list); !reflect.DeepEqual(got, tt.want) { | ||
t.Errorf("keysWithColons() = %v, want %v", got, tt.want) | ||
} | ||
}) | ||
} | ||
} | ||
|
||
func Test_quotedList(t *testing.T) { | ||
type args struct { | ||
l []string | ||
} | ||
tests := []struct { | ||
name string | ||
args args | ||
want string | ||
}{ | ||
{"none", args{}, ""}, | ||
{"single", args{l: []string{"one"}}, `"one"`}, | ||
{"two", args{l: []string{"ricky", "lucy"}}, `"ricky", "lucy"`}, | ||
{"three", args{l: []string{"manny", "moe", "jack"}}, `"manny", "moe", "jack"`}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
if got := quotedList(tt.args.l); got != tt.want { | ||
t.Errorf("quotedList() = %v, want %v", got, tt.want) | ||
} | ||
}) | ||
} | ||
} |