github.com/konsorten/ktn-build-info@v1.0.11/ver/update_ordering_test.go (about) 1 package ver 2 3 import ( 4 "strconv" 5 "testing" 6 ) 7 8 func TestOrderUpdates(t *testing.T) { 9 actions := make(UpdateActions) 10 11 actions["5"] = "a" 12 actions["2"] = "$create$" 13 actions["1"] = "$delete$" 14 actions["6"] = "b" 15 actions["0"] = "$delete$" 16 actions["4"] = "$___" 17 actions["3"] = "$create$" 18 19 ordered := orderUpdates(actions) 20 21 if len(actions) != len(ordered) { 22 t.Fatal("Element count mismatch") 23 } 24 25 for i, u := range ordered { 26 j, _ := strconv.Atoi(u.Path) 27 28 if i != j { 29 t.Fatalf("Action in wrong position: %v: %v", i, u) 30 } 31 } 32 }