@@ -1264,3 +1264,70 @@ func TestGetResourceKeyFromResource(t *testing.T) {
12641264 assert .Equal (t , "" , resourceID )
12651265 }
12661266}
1267+
1268+ func TestConcatMapValuesSorted (t * testing.T ) {
1269+ tests := []struct {
1270+ name string
1271+ input map [string ]string
1272+ expected string
1273+ }{
1274+ {
1275+ name : "NilMap" ,
1276+ input : nil ,
1277+ expected : "" ,
1278+ },
1279+ {
1280+ name : "EmptyMap" ,
1281+ input : map [string ]string {},
1282+ expected : "" ,
1283+ },
1284+ {
1285+ name : "SingleKeyValue" ,
1286+ input : map [string ]string {
1287+ "a" : "foo" ,
1288+ },
1289+ expected : "\" foo\" " ,
1290+ },
1291+ {
1292+ name : "SingleKeyEmptyValue" ,
1293+ input : map [string ]string {
1294+ "a" : "" ,
1295+ },
1296+ expected : "" ,
1297+ },
1298+ {
1299+ name : "MultipleKeysSorted" ,
1300+ input : map [string ]string {
1301+ "b" : "bar" ,
1302+ "a" : "foo" ,
1303+ "c" : "baz" ,
1304+ },
1305+ expected : "\" foo\\ x1fbar\\ x1fbaz\" " ,
1306+ },
1307+ {
1308+ name : "KeysWithEmptyValue" ,
1309+ input : map [string ]string {
1310+ "a" : "" ,
1311+ "b" : "bar" ,
1312+ },
1313+ expected : "\" bar\" " ,
1314+ },
1315+ {
1316+ name : "KeysWithInterspersedEmptyValue" ,
1317+ input : map [string ]string {
1318+ "a" : "foo" ,
1319+ "b" : "" ,
1320+ "c" : "baz" ,
1321+ },
1322+ expected : "\" foo\\ x1fbaz\" " ,
1323+ },
1324+ }
1325+ for _ , tt := range tests {
1326+ t .Run (tt .name , func (t * testing.T ) {
1327+ got := util .ConcatMapValuesSorted (tt .input , "\x1f " )
1328+ if got != tt .expected {
1329+ t .Errorf ("ConcatMapValuesSorted() = %q, want %q" , got , tt .expected )
1330+ }
1331+ })
1332+ }
1333+ }
0 commit comments