From a90954ae1a1b4d01d9695e45feb979c40ca42c9e Mon Sep 17 00:00:00 2001 From: Michael Muré Date: Sat, 29 Feb 2020 17:21:46 +0100 Subject: github: fix tests --- bridge/github/config_test.go | 55 ++++++++++++++++++++++++++------------------ 1 file 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) }) } } -- cgit