-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
check for mismatch on tlv2 credential submissions across request ids (#…
…2331) * check for mismatch on tlv2 credential submissions across request ids review feedback, change response time for aretimelimitedv2credssubmitted adding a unit test for mismatch linting issues resolved * updates based on review feedback * adding query test as per review feedback * updates to datastore interface for method signature change
- Loading branch information
Showing
7 changed files
with
716 additions
and
62 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
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,70 @@ | ||
package skus | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
|
||
"github.com/golang/mock/gomock" | ||
uuid "github.com/satori/go.uuid" | ||
should "github.com/stretchr/testify/assert" | ||
) | ||
|
||
type mockGetContext struct { | ||
getContext func(ctx context.Context, dest interface{}, query string, args ...interface{}) error | ||
} | ||
|
||
func (mgc *mockGetContext) GetContext(ctx context.Context, dest interface{}, query string, args ...interface{}) error { | ||
if mgc.getContext != nil { | ||
return mgc.getContext(ctx, dest, query, args) | ||
} | ||
return nil | ||
} | ||
|
||
func TestAreTimeLimitedV2CredsSubmitted(t *testing.T) { | ||
type tcExpected struct { | ||
result map[string]bool | ||
noErr bool | ||
} | ||
|
||
type testCase struct { | ||
name string | ||
dbi getContext | ||
given uuid.UUID | ||
exp tcExpected | ||
} | ||
|
||
ctrl := gomock.NewController(t) | ||
defer ctrl.Finish() | ||
|
||
tests := []testCase{ | ||
{ | ||
name: "mismatch", | ||
dbi: &mockGetContext{ | ||
getContext: func(ctx context.Context, dest interface{}, query string, args ...interface{}) error { | ||
*dest.(*AreTimeLimitedV2CredsSubmittedResult) = AreTimeLimitedV2CredsSubmittedResult{ | ||
AlreadySubmitted: true, | ||
Mismatch: true, | ||
} | ||
return nil | ||
}, | ||
}, | ||
given: uuid.Must(uuid.FromString("8f51f9ca-b593-4200-9bfb-91ac34748e09")), | ||
exp: tcExpected{ | ||
noErr: true, | ||
result: map[string]bool{ | ||
"mismatch": true, | ||
}, | ||
}, | ||
}, | ||
} | ||
|
||
for i := range tests { | ||
tc := tests[i] | ||
|
||
t.Run(tc.name, func(t *testing.T) { | ||
result, err := areTimeLimitedV2CredsSubmitted(context.TODO(), tc.dbi, tc.given, "") | ||
should.Equal(t, tc.exp.result["mismatch"], result.Mismatch) | ||
should.Equal(t, tc.exp.noErr, err == nil) | ||
}) | ||
} | ||
} |
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.