Skip to content

Commit

Permalink
#4 add tests for config
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-dammeier committed Dec 18, 2023
1 parent 589abf4 commit 446947c
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions pkg/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,3 +116,27 @@ func TestGetRemoteConfiguration(t *testing.T) {
})

}

func TestGetRemoteCredentials(t *testing.T) {
t.Run("default config", func(t *testing.T) {
t.Setenv(doguRegistryUsernameEnvVar, "user")
t.Setenv(doguRegistryPasswordEnvVar, "pass")
config, err := GetRemoteCredentials()

require.NoError(t, err)
assert.Equal(t, "user", config.Username)
assert.Equal(t, "pass", config.Password)
})
t.Run("no user", func(t *testing.T) {
t.Setenv(doguRegistryPasswordEnvVar, "pass")
_, err := GetRemoteCredentials()

require.Error(t, err)
})
t.Run("no pass", func(t *testing.T) {
t.Setenv(doguRegistryUsernameEnvVar, "user")
_, err := GetRemoteCredentials()

require.Error(t, err)
})
}

0 comments on commit 446947c

Please sign in to comment.