-
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
review feedback, change response time for aretimelimitedv2credssubmitted adding a unit test for mismatch
- Loading branch information
Showing
6 changed files
with
579 additions
and
61 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,71 @@ | ||
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 | ||
ok 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) | ||
}) | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.