11package collections
22
33import (
4+ "fmt"
45 "testing"
6+
57 "github.com/stretchr/testify/assert"
6- "fmt"
78)
89
910func TestMergeMapsNoMaps (t * testing.T ) {
@@ -123,7 +124,7 @@ func TestKeys(t *testing.T) {
123124 t .Parallel ()
124125
125126 testCases := []struct {
126- input map [string ]string
127+ input map [string ]string
127128 expected []string
128129 }{
129130 {map [string ]string {}, []string {}},
@@ -137,4 +138,44 @@ func TestKeys(t *testing.T) {
137138 assert .Equal (t , testCase .expected , actual )
138139 })
139140 }
140- }
141+ }
142+
143+ func TestKeyValueStringSlice (t * testing.T ) {
144+ t .Parallel ()
145+
146+ testCases := []struct {
147+ input map [string ]string
148+ expected []string
149+ }{
150+ {map [string ]string {"a" : "foo" }, []string {"a=foo" }},
151+ {map [string ]string {"a" : "foo" , "b" : "bar" , "c" : "baz" }, []string {"a=foo" , "b=bar" , "c=baz" }},
152+ }
153+
154+ for _ , testCase := range testCases {
155+ t .Run (fmt .Sprintf ("%v" , testCase .input ), func (t * testing.T ) {
156+ actual := KeyValueStringSlice (testCase .input )
157+ assert .Equal (t , testCase .expected , actual )
158+ })
159+ }
160+ }
161+
162+ func TestKeyValueStringSliceWithFormat (t * testing.T ) {
163+ t .Parallel ()
164+
165+ testCases := []struct {
166+ input map [string ]string
167+ format string
168+ expected []string
169+ }{
170+ {map [string ]string {"a" : "foo" }, "%s='%s'" , []string {"a='foo'" }},
171+ {map [string ]string {"a" : "foo" }, "%s%s" , []string {"afoo" }},
172+ {map [string ]string {"a" : "foo" , "b" : "bar" , "c" : "baz" }, "%s=%s" , []string {"a=foo" , "b=bar" , "c=baz" }},
173+ }
174+
175+ for _ , testCase := range testCases {
176+ t .Run (fmt .Sprintf ("%v" , testCase .input ), func (t * testing.T ) {
177+ actual := KeyValueStringSliceWithFormat (testCase .input , testCase .format )
178+ assert .Equal (t , testCase .expected , actual )
179+ })
180+ }
181+ }
0 commit comments