Added test for FSFileMigration
1 files changed, 23 insertions(+), 0 deletions(-)

M sql_test.go
M sql_test.go +23 -0
@@ 4,6 4,7 @@ import (
 	"context"
 	"database/sql"
 	"fmt"
+	"os"
 	"testing"
 
 	_ "github.com/mattn/go-sqlite3"

          
@@ 107,6 108,28 @@ func TestMigrate(t *testing.T) {
 		}
 	})
 
+	t.Run("file FS", func(t *testing.T) {
+		db := sqliteInMem(t)
+		sfs := os.DirFS("./")
+		migrations := []migrate.Migration{
+			migrate.FSFileMigration("001_create_widgets", "testdata/widgets.sql", "", 0, sfs),
+		}
+		engine := migrate.NewEngine(db, migrations, migrate.QUESTION, false)
+		engine.Printf = func(format string, args ...interface{}) (int, error) {
+			t.Logf(format, args...)
+			return 0, nil
+		}
+		ctx := context.Background()
+		err := engine.Migrate(ctx, "", false)
+		if err != nil {
+			t.Fatalf("Migrate() err = %v; want nil", err)
+		}
+		_, err = db.Exec("INSERT INTO widgets (color, price) VALUES (?, ?)", "red", 1200)
+		if err != nil {
+			t.Fatalf("db.Exec() err = %v; want nil", err)
+		}
+	})
+
 	t.Run("rollback", func(t *testing.T) {
 		db := sqliteInMem(t)
 		migrations := []migrate.Migration{