Skip to content

Commit

Permalink
Fix request_service_test
Browse files Browse the repository at this point in the history
  • Loading branch information
Toktar committed Jul 7, 2022
1 parent da2ac42 commit 18b6b7a
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 14 deletions.
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ require (
github.com/hashicorp/go-immutable-radix v1.3.1 // indirect
github.com/hashicorp/golang-lru v0.5.4 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/iancoleman/orderedmap v0.2.0 // indirect
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/jmhodges/levigo v1.0.0 // indirect
github.com/lestrrat-go/backoff/v2 v2.0.8 // indirect
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,8 @@ github.com/hudl/fargo v1.3.0/go.mod h1:y3CKSmjA+wD2gak7sUSXTAoopbhU08POFhmITJgmK
github.com/hudl/fargo v1.4.0/go.mod h1:9Ai6uvFy5fQNq6VPKtg+Ceq1+eTY4nKUlR2JElEOcDo=
github.com/huin/goupnp v1.0.0/go.mod h1:n9v9KO1tAxYH82qOn+UTIFQDmx5n1Zxd/ClZDMX7Bnc=
github.com/huin/goutil v0.0.0-20170803182201-1ca381bf3150/go.mod h1:PpLOETDnJ0o3iZrZfqZzyLl6l7F3c6L1oWn7OICBi6o=
github.com/iancoleman/orderedmap v0.2.0 h1:sq1N/TFpYH++aViPcaKjys3bDClUEU7s5B+z6jq8pNA=
github.com/iancoleman/orderedmap v0.2.0/go.mod h1:N0Wam8K1arqPXNWjMo21EXnBPOPp36vB07FNRdD2geA=
github.com/iancoleman/strcase v0.2.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho=
github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
Expand Down
28 changes: 15 additions & 13 deletions services/request_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ func (ls MockLedgerService) GetNamespaces() []string {
}

func TestResolve(t *testing.T) {
validDIDDoc := validDIDDoc()
subtests := []struct {
name string
ledgerService MockLedgerService
Expand All @@ -121,12 +122,12 @@ func TestResolve(t *testing.T) {
}{
{
name: "successful resolution",
ledgerService: NewMockLedgerService(validDIDDoc(), validMetadata(), resource.Resource{}),
ledgerService: NewMockLedgerService(validDIDDoc, validMetadata(), resource.Resource{}),
resolutionType: types.DIDJSONLD,
identifier: validIdentifier,
method: validMethod,
namespace: validNamespace,
expectedDID: validDIDDoc(),
expectedDID: validDIDDoc,
expectedMetadata: validMetadata(),
expectedError: "",
},
Expand Down Expand Up @@ -181,12 +182,10 @@ func TestResolve(t *testing.T) {
requestService := NewRequestService("cheqd", subtest.ledgerService)
id := "did:" + subtest.method + ":" + subtest.namespace + ":" + subtest.identifier
expectedDIDProperties := types.DidProperties{}
if subtest.expectedError == "" {
expectedDIDProperties = types.DidProperties{
DidString: id,
MethodSpecificId: subtest.identifier,
Method: subtest.method,
}
expectedDIDProperties = types.DidProperties{
DidString: id,
MethodSpecificId: subtest.identifier,
Method: subtest.method,
}
if (subtest.resolutionType == types.DIDJSONLD || subtest.resolutionType == types.JSONLD) && subtest.expectedError == "" {
subtest.expectedDID.Context = []string{types.DIDSchemaJSONLD}
Expand Down Expand Up @@ -299,7 +298,7 @@ func TestDereferencing(t *testing.T) {
name: "resource not found",
ledgerService: NewMockLedgerService(cheqd.Did{}, cheqd.Metadata{}, resource.Resource{}),
dereferencingType: types.DIDJSONLD,
didUrl: validDid + "/resource/unknownID",
didUrl: validDid + "/resource/00000000-0000-0000-0000-000000000000",
expectedMetadata: cheqd.Metadata{},
expectedError: types.DereferencingNotFound,
},
Expand All @@ -308,10 +307,13 @@ func TestDereferencing(t *testing.T) {
for _, subtest := range subtests {
t.Run(subtest.name, func(t *testing.T) {
requestService := NewRequestService("cheqd", subtest.ledgerService)
expectedDIDProperties := types.DidProperties{
DidString: validDid,
MethodSpecificId: validIdentifier,
Method: validMethod,
var expectedDIDProperties types.DidProperties
if subtest.expectedError != types.DereferencingInvalidDIDUrl {
expectedDIDProperties = types.DidProperties{
DidString: validDid,
MethodSpecificId: validIdentifier,
Method: validMethod,
}
}

fmt.Println(" dereferencingResult " + subtest.didUrl)
Expand Down
2 changes: 1 addition & 1 deletion types/resolution_metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func NewResolutionMetadata(didUrl string, contentType ContentType, resolutionErr
MethodSpecificId: id,
Method: method,
}
}
}
return ResolutionMetadata{
ContentType: contentType,
ResolutionError: resolutionError,
Expand Down

0 comments on commit 18b6b7a

Please sign in to comment.