aboutsummaryrefslogtreecommitdiffstats
path: root/bridge/github/config_test.go
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2020-02-29 17:26:33 +0100
committerGitHub <noreply@github.com>2020-02-29 17:26:33 +0100
commit0b559bacd51cc78235abc89b4767b459cc0e4cfa (patch)
tree541b255e5044e476605679eb3b613b68b50c0049 /bridge/github/config_test.go
parent140eae09c2311d2509e42376f1288da331705632 (diff)
parenta90954ae1a1b4d01d9695e45feb979c40ca42c9e (diff)
downloadgit-bug-0b559bacd51cc78235abc89b4767b459cc0e4cfa.tar.gz
Merge pull request #344 from MichaelMure/github-lowercase-login
github: fix matching cred/identity with badly cased login
Diffstat (limited to 'bridge/github/config_test.go')
-rw-r--r--bridge/github/config_test.go55
1 files changed, 32 insertions, 23 deletions
diff --git a/bridge/github/config_test.go b/bridge/github/config_test.go
index fe54c209..eecb1aa8 100644
--- a/bridge/github/config_test.go
+++ b/bridge/github/config_test.go
@@ -104,41 +104,50 @@ func TestValidateUsername(t *testing.T) {
t.Skip("Travis environment: avoiding non authenticated requests")
}
- type args struct {
- username string
- }
tests := []struct {
- name string
- args args
- want bool
+ name string
+ input string
+ fixed string
+ ok bool
}{
{
- name: "existing username",
- args: args{
- username: "MichaelMure",
- },
- want: true,
+ name: "existing username",
+ input: "MichaelMure",
+ fixed: "MichaelMure",
+ ok: true,
},
{
- name: "existing organisation name",
- args: args{
- username: "ipfs",
- },
- want: true,
+ name: "existing username with bad case",
+ input: "MicHaelmurE",
+ fixed: "MichaelMure",
+ ok: true,
},
{
- name: "non existing username",
- args: args{
- username: "cant-find-this",
- },
- want: false,
+ name: "existing organisation",
+ input: "ipfs",
+ fixed: "ipfs",
+ ok: true,
+ },
+ {
+ name: "existing organisation with bad case",
+ input: "iPfS",
+ fixed: "ipfs",
+ ok: true,
+ },
+ {
+ name: "non existing username",
+ input: "cant-find-this",
+ fixed: "",
+ ok: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
- ok, _ := validateUsername(tt.args.username)
- assert.Equal(t, tt.want, ok)
+ ok, fixed, err := validateUsername(tt.input)
+ assert.NoError(t, err)
+ assert.Equal(t, tt.ok, ok)
+ assert.Equal(t, tt.fixed, fixed)
})
}
}