stonesql/migrator_test.go
Rene Nochebuena ff1fc8ca0c
All checks were successful
Go CI/CD / go-ci (push) Successful in 19m9s
Release v1.0.0 (#2)
Reviewed-on: #2
Reviewed-by: Cloud Administrator <cloud-admin@noreply.gitstormr.dev>
Co-authored-by: Rene Nochebuena <code-raider@noreply.gitstormr.dev>
Co-committed-by: Rene Nochebuena <code-raider@noreply.gitstormr.dev>
2025-04-13 11:34:45 -06:00

44 lines
896 B
Go

package stonesql
import (
"context"
"fmt"
"testing"
"gitstormr.dev/stone-utils/stonesql/test"
)
type migratorSuccessMock struct{}
func (m *migratorSuccessMock) ExecuteMigration(
ctx context.Context, name string, sqlContent string,
) error {
fmt.Println(name, sqlContent)
return nil
}
type migratorFailureMock struct{}
func (m *migratorFailureMock) ExecuteMigration(
ctx context.Context, name string, sqlContent string,
) error {
return fmt.Errorf("failed to execute migration %s", name)
}
func Test_MigrationSuccess(t *testing.T) {
migrator := &migratorSuccessMock{}
err := RunMigrations(context.Background(), migrator, test.TestFS, ".")
if err != nil {
t.Error(err)
}
}
func Test_MigrationFailure(t *testing.T) {
migrator := &migratorFailureMock{}
err := RunMigrations(context.Background(), migrator, test.TestFS, ".")
if err == nil {
t.Error("expected error")
}
}