-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Split tests in two files, use white-box testing
- Loading branch information
Showing
3 changed files
with
44 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package analyzer_test | ||
|
||
import ( | ||
"context" | ||
"os" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
|
||
cmdAnalyzer "github.com/oasisprotocol/nexus/cmd/analyzer" | ||
"github.com/oasisprotocol/nexus/storage/postgres/testutil" | ||
"github.com/oasisprotocol/nexus/tests" | ||
) | ||
|
||
// Relative path to the migrations directory when running tests in this file. | ||
// When running go tests, the working directory is always set to the package directory of the test being run. | ||
const migrationsPath = "file://../../storage/migrations" | ||
|
||
func TestMigrations(t *testing.T) { | ||
tests.SkipIfShort(t) | ||
client := testutil.NewTestClient(t) | ||
defer client.Close() | ||
|
||
ctx := context.Background() | ||
|
||
// Ensure database is empty before running migrations. | ||
require.NoError(t, client.Wipe(ctx), "failed to wipe database") | ||
|
||
// Run migrations. | ||
require.NoError(t, cmdAnalyzer.RunMigrations(migrationsPath, os.Getenv("CI_TEST_CONN_STRING")), "failed to run migrations") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters