Skip to content

Commit

Permalink
test fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
woutslakhorst committed Dec 5, 2023
1 parent 30ef159 commit 62c57f7
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
9 changes: 6 additions & 3 deletions echo/echo_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,16 @@ import (

// TestStatusCodes tests if the returned errors from the API implementations are correctly translated to status codes
func TestStatusCodes(t *testing.T) {
hook := logTest.NewGlobal()
baseUrl, _ := node.StartServer(t)

type operation struct {
module string
operation string
url string
body interface{}
}
t.Run("404s", func(t *testing.T) {
hook := logTest.NewGlobal()
baseUrl, _ := node.StartServer(t)

testCases := []operation{
{module: "Auth", operation: "GetSignSessionStatus", url: "/internal/auth/v1/signature/session/1"},
{module: "Auth", operation: "GetContractByType", url: "/public/auth/v1/contract/1"},
Expand All @@ -66,6 +66,9 @@ func TestStatusCodes(t *testing.T) {
}
})
t.Run("400s", func(t *testing.T) {
hook := logTest.NewGlobal()
baseUrl, _ := node.StartServer(t)

testCases := []operation{
{module: "Crypto", operation: "SignJwt", url: "/internal/crypto/v1/sign_jwt", body: map[string]interface{}{"kid": "fpp", "claims": map[string]interface{}{"foo": "bar"}}},
{module: "Network", operation: "GetTransaction", url: "/internal/network/v1/transaction/invalidhash"},
Expand Down
1 change: 1 addition & 0 deletions vdr/didweb/manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ func TestManager_Create(t *testing.T) {
require.NoError(t, keyAsJWK.Raw(&publicKey))

t.Run("ok", func(t *testing.T) {
resetStore(t, storageEngine.GetSQLDatabase())
ctrl := gomock.NewController(t)
keyStore := nutsCrypto.NewMockKeyStore(ctrl)
keyStore.EXPECT().New(gomock.Any(), gomock.Any()).Return(nutsCrypto.TestPublicKey{
Expand Down
12 changes: 7 additions & 5 deletions vdr/didweb/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,13 @@ func Test_sqlStore_get(t *testing.T) {
}

func resetStore(t *testing.T, db *gorm.DB) {
underlyingDB, err := db.DB()
require.NoError(t, err)
// related tables are emptied due to on-delete-cascade clause
_, err = underlyingDB.Exec("DELETE FROM vdr_didweb")
require.NoError(t, err)
t.Cleanup(func() {
underlyingDB, err := db.DB()
require.NoError(t, err)
// related tables are emptied due to on-delete-cascade clause
_, err = underlyingDB.Exec("DELETE FROM vdr_didweb")
require.NoError(t, err)
})
}

func testVerificationMethod(t *testing.T, owner did.DID) did.VerificationMethod {
Expand Down

0 comments on commit 62c57f7

Please sign in to comment.