forked from in-toto/go-witness
-
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.
chore(judge-api): support multiple database providers
- Loading branch information
1 parent
20edd15
commit ee045b4
Showing
6 changed files
with
149 additions
and
56 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
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,29 @@ | ||
package cmd | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
|
||
"entgo.io/ent/dialect/sql" | ||
_ "github.com/mattn/go-sqlite3" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
// This test just makes sure our sqllite3 in-memory db works for our tests | ||
func TestJudgeApiServer_WithSQLite3(t *testing.T) { | ||
// Arrange: Prepare the context and SQL driver | ||
ctx := context.Background() | ||
drv, err := sql.Open("sqlite3", "file:ent?mode=memory&cache=shared&_fk=1") | ||
require.NoError(t, err) | ||
|
||
// Act: Setup the database with the given SQL driver | ||
judge := SetupDb(ctx, drv) | ||
|
||
// Assert: Check if the server is properly initiated | ||
require.NotNil(t, judge.authProvider) | ||
require.NotNil(t, judge.authMiddleware) | ||
require.NotNil(t, judge.srv) | ||
require.NotNil(t, judge.database) | ||
require.NotNil(t, judge.mysqlStoreCh) | ||
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
Oops, something went wrong.