Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandear committed Oct 7, 2023
1 parent be7bcca commit fb2d556
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions viper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,7 @@ func TestReadInConfig(t *testing.T) {
}

func TestDefault(t *testing.T) {
Reset()
SetDefault("age", 45)
assert.Equal(t, 45, Get("age"))

Expand All @@ -486,6 +487,7 @@ func TestDefault(t *testing.T) {
}

func TestUnmarshaling(t *testing.T) {
Reset()
SetConfigType("yaml")
r := bytes.NewReader(yamlExample)

Expand Down Expand Up @@ -524,13 +526,16 @@ func TestDefaultPost(t *testing.T) {
}

func TestAliases(t *testing.T) {
initConfigs()
Set("age", 40)
RegisterAlias("years", "age")
assert.Equal(t, 40, Get("years"))
Set("years", 45)
assert.Equal(t, 45, Get("age"))
}

func TestAliasInConfigFile(t *testing.T) {
initConfigs()
// the config file specifies "beard". If we make this an alias for
// "hasbeard", we still want the old config file to work with beard.
RegisterAlias("beard", "hasbeard")
Expand Down Expand Up @@ -873,6 +878,7 @@ func TestRecursiveAliases(t *testing.T) {
}

func TestUnmarshal(t *testing.T) {
Reset()
SetDefault("port", 1313)
Set("name", "Steve")
Set("duration", "1s1ms")
Expand Down Expand Up @@ -1277,6 +1283,7 @@ func TestBindPFlagStringToInt(t *testing.T) {
}

func TestBoundCaseSensitivity(t *testing.T) {
initConfigs()
assert.Equal(t, "brown", Get("eyes"))

BindEnv("eYEs", "TURTLE_EYES")
Expand Down

0 comments on commit fb2d556

Please sign in to comment.