From 29ac8f6f33a3de34ff906b0b46954a112389956a Mon Sep 17 00:00:00 2001 From: Miguel de la Cruz Date: Fri, 12 Aug 2022 16:55:21 +0200 Subject: [PATCH] Update README with the new library API --- README.md | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 79d03a7..3f93520 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,7 @@ type Migrator interface { DriverName() string Setup() error MigrateToStep(step int) error + Interceptors() map[int]Interceptor TearDown() error } @@ -39,7 +40,6 @@ your assertions: ```go t.Run("migration should link book 1 with its author", func(t *testing.T) { f := foundation.New(t, migrator). - RegisterInterceptors(interceptors). // runs migrations up to and including 5 MigrateToStep(5). // loads the SQL of the file @@ -48,14 +48,21 @@ t.Run("migration should link book 1 with its author", func(t *testing.T) { MigrateToStep(6) defer f.TearDown() - book := struct{ - ID int - AuthorID int - }{} + book := struct{ID int; AuthorID int}{} - err = f.DB().Get(&book, "SELECT id, authorID FROM books") + err := f.DB().Get(&book, "SELECT id, authorID FROM books") require.NoError(t, err) require.Equal(t, 1, book.ID) require.Equal(t, 3, book.AuthorID) }) + +t.Run("test specifically the interceptor 6", func(t *testing.T) { + f := foundation.New(t, migrator). + MigrateToStepSkippingLastInterceptor(6). + ExecFile("./myfixtures.sql"). + RunInterceptor(6) + defer f.TearDown() + + // ... +}) ```