aboutsummaryrefslogtreecommitdiffstats
path: root/internal/models/migration_test.go
diff options
context:
space:
mode:
authorEugene Triguba <eugenetriguba@gmail.com>2024-03-16 15:06:30 -0400
committerEugene Triguba <eugenetriguba@gmail.com>2024-03-16 15:06:30 -0400
commit65ded7c0133ae011a30546fb4fd1e00fc3179874 (patch)
tree305c9655c581ba5c959d56cf801a96bf80683dd7 /internal/models/migration_test.go
parentUpdate README (diff)
downloadcli-65ded7c0133ae011a30546fb4fd1e00fc3179874.zip
Update migration file format
Diffstat (limited to 'internal/models/migration_test.go')
-rw-r--r--internal/models/migration_test.go32
1 files changed, 29 insertions, 3 deletions
diff --git a/internal/models/migration_test.go b/internal/models/migration_test.go
index b6d3205..809887f 100644
--- a/internal/models/migration_test.go
+++ b/internal/models/migration_test.go
@@ -1,7 +1,6 @@
package models_test
import (
- "fmt"
"testing"
"time"
@@ -34,6 +33,33 @@ func TestNewSequentialMigration(t *testing.T) {
}
func TestName(t *testing.T) {
- m := models.NewSequentialMigration(1, "test message")
- check.Equal(t, m.Name(), fmt.Sprintf("%s_%s", m.Version, m.Message))
+ type test struct {
+ migration *models.Migration
+ expectedName string
+ }
+
+ testCases := []test{
+ // Underscores are used to separate version and message.
+ {
+ migration: models.NewSequentialMigration(1, "test_message"),
+ expectedName: "001_test_message",
+ },
+ {
+ migration: models.NewTimestampMigration(time.Date(1234, 1, 2, 3, 4, 5, 6, time.UTC), "test_message"),
+ expectedName: "12340102030405_test_message",
+ },
+ // Leading/Trailing spaces trimmed, lowercased, and spaces converted to underscores.
+ {
+ migration: models.NewSequentialMigration(1, " teST mesSAGE "),
+ expectedName: "001_test_message",
+ },
+ {
+ migration: models.NewTimestampMigration(time.Date(1234, 1, 2, 3, 4, 5, 6, time.UTC), " teST mesSAGE "),
+ expectedName: "12340102030405_test_message",
+ },
+ }
+
+ for _, tc := range testCases {
+ check.Equal(t, tc.migration.Name(), tc.expectedName)
+ }
}