mirror of https://gitlab.com/gitlab-org/cli.git
test: fix assertion order, clear token in keyring test
This commit is contained in:
parent
f0a7862f85
commit
c46ec24b53
|
@ -41,7 +41,7 @@ $ glab auth login --hostname salsa.debian.org
|
|||
-h, --hostname string The hostname of the GitLab instance to authenticate with
|
||||
--stdin Read token from standard input
|
||||
-t, --token string Your GitLab access token
|
||||
--use-keyring Store token in your operating system keyring
|
||||
--use-keyring Store token in your operating system's keyring
|
||||
```
|
||||
|
||||
## Options inherited from parent commands
|
||||
|
|
|
@ -6,6 +6,7 @@ import (
|
|||
|
||||
"github.com/MakeNowJust/heredoc"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"github.com/zalando/go-keyring"
|
||||
)
|
||||
|
||||
|
@ -111,19 +112,20 @@ host: gitlab.com
|
|||
func Test_getFromKeyring(t *testing.T) {
|
||||
c := NewBlankConfig()
|
||||
|
||||
err := c.Set("gitlab.com", "api_host", "gitlab.com")
|
||||
assert.NoError(t, err)
|
||||
// Ensure host exists and its token is empty
|
||||
err := c.Set("gitlab.com", "token", "")
|
||||
require.NoError(t, err)
|
||||
|
||||
keyring.MockInit()
|
||||
token, err := c.Get("gitlab.com", "token")
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, token, "")
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, "", token)
|
||||
|
||||
err = keyring.Set("glab:gitlab.com", "", "glpat-1234")
|
||||
assert.NoError(t, err)
|
||||
require.NoError(t, err)
|
||||
|
||||
token, err = c.Get("gitlab.com", "token")
|
||||
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, token, "glpat-1234")
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, "glpat-1234", token)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue