master
go 36 lines 1.13 KB
Raw
1 package migrations
2
3 import (
4 "context"
5 "testing"
6
7 "github.com/stretchr/testify/assert"
8 "github.com/stretchr/testify/require"
9 )
10
11 func TestHasEmbeddedMigration(t *testing.T) {
12 // Test that the 16-to-17 migration is registered
13 assert.True(t, HasEmbeddedMigration("fs-repo-16-to-17"),
14 "fs-repo-16-to-17 migration should be registered")
15
16 // Test that a non-existent migration is not found
17 assert.False(t, HasEmbeddedMigration("fs-repo-99-to-100"),
18 "fs-repo-99-to-100 migration should not be registered")
19 }
20
21 func TestEmbeddedMigrations(t *testing.T) {
22 // Test that we have at least one embedded migration
23 assert.NotEmpty(t, embeddedMigrations, "No embedded migrations found")
24
25 // Test that all registered migrations implement the interface
26 for name, migration := range embeddedMigrations {
27 assert.NotEmpty(t, migration.Versions(),
28 "Migration %s has empty versions", name)
29 }
30 }
31
32 func TestRunEmbeddedMigration(t *testing.T) {
33 // Test that running a non-existent migration returns an error
34 err := RunEmbeddedMigration(context.Background(), "non-existent", "/tmp", false)
35 require.Error(t, err, "Expected error for non-existent migration")
36 }