github.com/rjgonzale/pop/v5@v5.1.3-dev/migration_info_test.go (about) 1 package pop 2 3 import ( 4 "github.com/stretchr/testify/assert" 5 "sort" 6 "testing" 7 ) 8 9 func TestSortingMigrations(t *testing.T) { 10 t.Run("case=enforces precedence for specific migrations", func(t *testing.T) { 11 migrations := Migrations{ 12 { 13 Version: "1", 14 DBType: "all", 15 }, 16 { 17 Version: "1", 18 DBType: "postgres", 19 }, 20 { 21 Version: "2", 22 DBType: "cockroach", 23 }, 24 { 25 Version: "2", 26 DBType: "all", 27 }, 28 { 29 Version: "3", 30 DBType: "all", 31 }, 32 { 33 Version: "3", 34 DBType: "mysql", 35 }, 36 } 37 expectedOrder := Migrations{ 38 migrations[1], 39 migrations[0], 40 migrations[2], 41 migrations[3], 42 migrations[5], 43 migrations[4], 44 } 45 46 sort.Sort(migrations) 47 48 assert.Equal(t, expectedOrder, migrations) 49 }) 50 }