Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
askolesov committed May 13, 2022
1 parent c5fb30c commit c52a4ca
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion services/ledger_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func (ls LedgerService) QueryDIDDoc(did string) (cheqd.Did, cheqd.Metadata, bool
_, namespace, _, _ := cheqdUtils.TrySplitDID(did)
serverAddr, namespaceFound := ls.ledgers[namespace]
if !namespaceFound {
return cheqd.Did{}, cheqd.Metadata{}, false, fmt.Errorf("namespace not suported: %s", namespace)
return cheqd.Did{}, cheqd.Metadata{}, false, fmt.Errorf("namespace not supported: %s", namespace)
}

log.Info().Msgf("Connecting to the ledger: %s", serverAddr)
Expand Down
10 changes: 7 additions & 3 deletions services/ledger_service_test.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package services

import (
"context"
"errors"
"testing"
"time"

cheqd "github.com/cheqd/cheqd-node/x/cheqd/types"
"github.com/stretchr/testify/require"
Expand All @@ -23,13 +24,16 @@ func TestQueryDIDDoc(t *testing.T) {
expectedDID: cheqd.Did{},
expectedMetadata: cheqd.Metadata{},
expectedIsFound: false,
expectedError: context.DeadlineExceeded,
expectedError: errors.New("namespace not supported: "),
},
}

for _, subtest := range subtests {
t.Run(subtest.name, func(t *testing.T) {
ledgerService := NewLedgerService()
timeout, err := time.ParseDuration("5s")
require.NoError(t, err)

ledgerService := NewLedgerService(timeout)
didDoc, metadata, isFound, err := ledgerService.QueryDIDDoc("fake did")
require.EqualValues(t, subtest.expectedDID, didDoc)
require.EqualValues(t, subtest.expectedMetadata, metadata)
Expand Down

0 comments on commit c52a4ca

Please sign in to comment.