From c9de81786587231bf488f800d0ca6d4fefd7fb0f Mon Sep 17 00:00:00 2001 From: William Martin Date: Thu, 19 Oct 2023 12:26:52 +0200 Subject: [PATCH] Avoid using keyring unnecessarily in AuthConfig tests This is to avoid the impression that the keyring matters, when the test is actually about general auth behaviour --- internal/config/auth_config_test.go | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/internal/config/auth_config_test.go b/internal/config/auth_config_test.go index 335489525..09649bce8 100644 --- a/internal/config/auth_config_test.go +++ b/internal/config/auth_config_test.go @@ -286,12 +286,11 @@ func TestLoginSetsUserForProvidedHost(t *testing.T) { tempDir := t.TempDir() t.Setenv("GH_CONFIG_DIR", tempDir) - // Given a usable keyring and an empty config - keyring.MockInit() + // Given we are not logged in authCfg := newTestAuthConfig() // When we login - _, err := authCfg.Login("github.com", "test-user", "test-token", "ssh", true) + _, err := authCfg.Login("github.com", "test-user", "test-token", "ssh", false) // Then it returns success and the user is set require.NoError(t, err) @@ -301,16 +300,15 @@ func TestLoginSetsUserForProvidedHost(t *testing.T) { require.Equal(t, "test-user", user) } -func TestLoginSetsGitProtocolForProdivdedHost(t *testing.T) { +func TestLoginSetsGitProtocolForProvidedHost(t *testing.T) { tempDir := t.TempDir() t.Setenv("GH_CONFIG_DIR", tempDir) - // Given a usable keyring and an empty config - keyring.MockInit() + // Given we are not logged in authCfg := newTestAuthConfig() // When we login - _, err := authCfg.Login("github.com", "test-user", "test-token", "ssh", true) + _, err := authCfg.Login("github.com", "test-user", "test-token", "ssh", false) // Then it returns success and the git protocol is set require.NoError(t, err) @@ -324,12 +322,11 @@ func TestLoginAddsHostIfNotAlreadyAdded(t *testing.T) { tempDir := t.TempDir() t.Setenv("GH_CONFIG_DIR", tempDir) - // Given a usable keyring and an empty config - keyring.MockInit() + // Given we are not logged in authCfg := newTestAuthConfig() // When we login - _, err := authCfg.Login("github.com", "test-user", "test-token", "ssh", true) + _, err := authCfg.Login("github.com", "test-user", "test-token", "ssh", false) // Then it returns success and a host is added require.NoError(t, err)