forked from sourcenetwork/defradb
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
restore preflight checks and db path logic
- Loading branch information
Showing
2 changed files
with
65 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package tests | ||
|
||
import ( | ||
"os" | ||
"path" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func DetectDbChangesPreTestChecks( | ||
t *testing.T, | ||
collectionNames []string, | ||
) { | ||
if previousTestCaseTestName == t.Name() { | ||
// The database format changer currently only supports running the first test | ||
// case, if a second case is detected we return early | ||
t.Skip() | ||
} | ||
previousTestCaseTestName = t.Name() | ||
|
||
if len(collectionNames) == 0 { | ||
// If the test doesn't specify any collections, then we can't use it to check | ||
// the database format, so we skip it | ||
t.SkipNow() | ||
} | ||
|
||
if !SetupOnly { | ||
dbDirectory := path.Join(rootDatabaseDir, t.Name()) | ||
_, err := os.Stat(dbDirectory) | ||
if os.IsNotExist(err) { | ||
// This is a new test that does not exist in the target branch, we should | ||
// skip it. | ||
t.SkipNow() | ||
} else { | ||
require.NoError(t, err) | ||
} | ||
} | ||
} |
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