MCPcopy Index your code
hub / github.com/rubenv/sql-migrate / TestSortMigrations

Method TestSortMigrations

sort_test.go:14–36  ·  view source on GitHub ↗
(c *C)

Source from the content-addressed store, hash-verified

12var _ = Suite(&SortSuite{})
13
14func (*SortSuite) TestSortMigrations(c *C) {
15 migrations := byId([]*Migration{
16 {Id: "10_abc", Up: nil, Down: nil},
17 {Id: "120_cde", Up: nil, Down: nil},
18 {Id: "1_abc", Up: nil, Down: nil},
19 {Id: "efg", Up: nil, Down: nil},
20 {Id: "2_cde", Up: nil, Down: nil},
21 {Id: "35_cde", Up: nil, Down: nil},
22 {Id: "3_efg", Up: nil, Down: nil},
23 {Id: "4_abc", Up: nil, Down: nil},
24 })
25
26 sort.Sort(migrations)
27 c.Assert(migrations, HasLen, 8)
28 c.Assert(migrations[0].Id, Equals, "1_abc")
29 c.Assert(migrations[1].Id, Equals, "2_cde")
30 c.Assert(migrations[2].Id, Equals, "3_efg")
31 c.Assert(migrations[3].Id, Equals, "4_abc")
32 c.Assert(migrations[4].Id, Equals, "10_abc")
33 c.Assert(migrations[5].Id, Equals, "35_cde")
34 c.Assert(migrations[6].Id, Equals, "120_cde")
35 c.Assert(migrations[7].Id, Equals, "efg")
36}

Callers

nothing calls this directly

Calls 1

byIdTypeAlias · 0.85

Tested by

no test coverage detected