(t *testing.T)
| 499 | } |
| 500 | |
| 501 | func TestSwitchUserUpdatesTheActiveUser(t *testing.T) { |
| 502 | // Given we have two users logged into a host |
| 503 | authCfg := newTestAuthConfig(t) |
| 504 | _, err := authCfg.Login("github.com", "test-user-1", "test-token-1", "ssh", false) |
| 505 | require.NoError(t, err) |
| 506 | _, err = authCfg.Login("github.com", "test-user-2", "test-token-2", "ssh", false) |
| 507 | require.NoError(t, err) |
| 508 | |
| 509 | // When we switch to the other user |
| 510 | require.NoError(t, authCfg.SwitchUser("github.com", "test-user-1")) |
| 511 | |
| 512 | // Then the active user is updated |
| 513 | activeUser, err := authCfg.ActiveUser("github.com") |
| 514 | require.NoError(t, err) |
| 515 | require.Equal(t, "test-user-1", activeUser) |
| 516 | } |
| 517 | |
| 518 | func TestSwitchUserErrorsImmediatelyIfTheActiveTokenComesFromEnvironment(t *testing.T) { |
| 519 | // Given we have a token in the env |
nothing calls this directly
no test coverage detected