@@ -245,6 +245,7 @@ NOTE: An error occurred while building plan-preview for applications of the foll
245245 }
246246}
247247func TestSortResults (t * testing.T ) {
248+ t .Parallel ()
248249 testcases := []struct {
249250 name string
250251 results []* model.PlanPreviewCommandResult
@@ -300,6 +301,8 @@ func TestSortResults(t *testing.T) {
300301 {
301302 PipedId : "piped-2" ,
302303 Results : []* model.ApplicationPlanPreviewResult {
304+ {ApplicationName : "app-3" , Labels : map [string ]string {"env" : "staging" }},
305+ {ApplicationName : "app-3" , Labels : map [string ]string {"env" : "prod" }},
303306 {ApplicationName : "app-2" , Labels : map [string ]string {"env" : "staging" }},
304307 {ApplicationName : "app-2" , Labels : map [string ]string {"env" : "prod" }},
305308 },
@@ -318,7 +321,35 @@ func TestSortResults(t *testing.T) {
318321 PipedId : "piped-2" ,
319322 Results : []* model.ApplicationPlanPreviewResult {
320323 {ApplicationName : "app-2" , Labels : map [string ]string {"env" : "prod" }},
324+ {ApplicationName : "app-3" , Labels : map [string ]string {"env" : "prod" }},
321325 {ApplicationName : "app-2" , Labels : map [string ]string {"env" : "staging" }},
326+ {ApplicationName : "app-3" , Labels : map [string ]string {"env" : "staging" }},
327+ },
328+ },
329+ },
330+ },
331+ {
332+ name : "sort by multiple label keys" ,
333+ results : []* model.PlanPreviewCommandResult {
334+ {
335+ PipedId : "piped-1" ,
336+ Results : []* model.ApplicationPlanPreviewResult {
337+ {ApplicationName : "app-1" , Labels : map [string ]string {"env" : "prod" , "team" : "team-2" }},
338+ {ApplicationName : "app-1" , Labels : map [string ]string {"env" : "staging" , "team" : "team-1" }},
339+ {ApplicationName : "app-1" , Labels : map [string ]string {"env" : "prod" , "team" : "team-1" }},
340+ {ApplicationName : "app-2" , Labels : map [string ]string {"env" : "prod" , "team" : "team-2" }},
341+ },
342+ },
343+ },
344+ sortLabelKeys : []string {"env" , "team" },
345+ expected : []* model.PlanPreviewCommandResult {
346+ {
347+ PipedId : "piped-1" ,
348+ Results : []* model.ApplicationPlanPreviewResult {
349+ {ApplicationName : "app-1" , Labels : map [string ]string {"env" : "prod" , "team" : "team-1" }},
350+ {ApplicationName : "app-1" , Labels : map [string ]string {"env" : "prod" , "team" : "team-2" }},
351+ {ApplicationName : "app-2" , Labels : map [string ]string {"env" : "prod" , "team" : "team-2" }},
352+ {ApplicationName : "app-1" , Labels : map [string ]string {"env" : "staging" , "team" : "team-1" }},
322353 },
323354 },
324355 },
0 commit comments