Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: rename geminix test #2271

Merged
merged 1 commit into from
Dec 21, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
117 changes: 78 additions & 39 deletions services/wallet/gemini_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
should "github.com/stretchr/testify/assert"
)

func Test_getIssuingCountry(t *testing.T) {
func TestGetIssuingCountry(t *testing.T) {
type tcGiven struct {
gx *geminix
validAcc gemini.ValidatedAccount
Expand Down Expand Up @@ -109,10 +109,15 @@ func Test_getIssuingCountry(t *testing.T) {
}
}

func Test_countryForDocByPrecedence(t *testing.T) {
func TestCountryForDocByPrecedence(t *testing.T) {
type tcGiven struct {
docTypePres []string
validDocuments []gemini.ValidDocument
}

type testCase struct {
name string
given []gemini.ValidDocument
given tcGiven
exp string
}

Expand All @@ -123,68 +128,108 @@ func Test_countryForDocByPrecedence(t *testing.T) {

{
name: "one_passport",
given: []gemini.ValidDocument{
{
Type: "passport",
IssuingCountry: "US",
given: tcGiven{
docTypePres: []string{
"passport",
"drivers_license",
"national_identity_card",
"passport_card",
},
validDocuments: []gemini.ValidDocument{
{
Type: "passport",
IssuingCountry: "US",
},
},
},
exp: "US",
},

{
name: "two_docs",
given: []gemini.ValidDocument{
{
Type: "passport",
IssuingCountry: "US",
given: tcGiven{
docTypePres: []string{
"passport",
"drivers_license",
"national_identity_card",
"passport_card",
},
validDocuments: []gemini.ValidDocument{
{
Type: "passport",
IssuingCountry: "US",
},

{
Type: "drivers_license",
IssuingCountry: "CA",
{
Type: "drivers_license",
IssuingCountry: "CA",
},
},
},
exp: "US",
},

{
name: "two_docs_reverse",
given: []gemini.ValidDocument{
{
Type: "drivers_license",
IssuingCountry: "CA",
given: tcGiven{
docTypePres: []string{
"passport",
"drivers_license",
"national_identity_card",
"passport_card",
},
validDocuments: []gemini.ValidDocument{
{
Type: "drivers_license",
IssuingCountry: "CA",
},

{
Type: "passport",
IssuingCountry: "US",
{
Type: "passport",
IssuingCountry: "US",
},
},
},
exp: "US",
},

{
name: "no_valid_document_type",
given: []gemini.ValidDocument{
{
Type: "invalid_type",
IssuingCountry: "US",
given: tcGiven{
docTypePres: []string{
"passport",
"drivers_license",
"national_identity_card",
"passport_card",
},
validDocuments: []gemini.ValidDocument{
{
Type: "invalid_type",
IssuingCountry: "US",
},
},
},
exp: "",
},

{
name: "valid_and_invalid_document_type_lower_case",
given: []gemini.ValidDocument{
{
Type: "invalid_type",
IssuingCountry: "US",
given: tcGiven{
docTypePres: []string{
"passport",
"drivers_license",
"national_identity_card",
"passport_card",
},
{
Type: "passport",
IssuingCountry: "uk",
validDocuments: []gemini.ValidDocument{
{
Type: "invalid_type",
IssuingCountry: "US",
},
{
Type: "passport",
IssuingCountry: "uk",
},
},
},
exp: "UK",
Expand All @@ -194,13 +239,7 @@ func Test_countryForDocByPrecedence(t *testing.T) {
for i := range tests {
tc := tests[i]
t.Run(tc.name, func(t *testing.T) {
pres := []string{
"passport",
"drivers_license",
"national_identity_card",
"passport_card",
}
act := countryForDocByPrecedence(pres, tc.given)
act := countryForDocByPrecedence(tc.given.docTypePres, tc.given.validDocuments)
should.Equal(t, tc.exp, act)
})
}
Expand Down
Loading