mirror of
https://github.com/spf13/viper
synced 2025-05-07 20:57:18 +00:00
ci: enable test shuffle; fix tests
This commit is contained in:
parent
dd9a341aec
commit
9a54b83ff5
3 changed files with 10 additions and 2 deletions
4
.github/workflows/ci.yaml
vendored
4
.github/workflows/ci.yaml
vendored
|
@ -57,11 +57,11 @@ jobs:
|
||||||
go-version: ${{ matrix.go }}
|
go-version: ${{ matrix.go }}
|
||||||
|
|
||||||
- name: Test
|
- name: Test
|
||||||
run: go test -race -v -tags '${{ matrix.tags }}' ./...
|
run: go test -race -v -tags '${{ matrix.tags }}' -shuffle=on ./...
|
||||||
if: runner.os != 'Windows'
|
if: runner.os != 'Windows'
|
||||||
|
|
||||||
- name: Test (without race detector)
|
- name: Test (without race detector)
|
||||||
run: go test -v -tags '${{ matrix.tags }}' ./...
|
run: go test -v -tags '${{ matrix.tags }}' -shuffle=on ./...
|
||||||
if: runner.os == 'Windows'
|
if: runner.os == 'Windows'
|
||||||
|
|
||||||
lint:
|
lint:
|
||||||
|
|
|
@ -8,6 +8,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestBindFlagValueSet(t *testing.T) {
|
func TestBindFlagValueSet(t *testing.T) {
|
||||||
|
Reset()
|
||||||
flagSet := pflag.NewFlagSet("test", pflag.ContinueOnError)
|
flagSet := pflag.NewFlagSet("test", pflag.ContinueOnError)
|
||||||
|
|
||||||
testValues := map[string]*string{
|
testValues := map[string]*string{
|
||||||
|
|
|
@ -472,6 +472,7 @@ func TestReadInConfig(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestDefault(t *testing.T) {
|
func TestDefault(t *testing.T) {
|
||||||
|
Reset()
|
||||||
SetDefault("age", 45)
|
SetDefault("age", 45)
|
||||||
assert.Equal(t, 45, Get("age"))
|
assert.Equal(t, 45, Get("age"))
|
||||||
|
|
||||||
|
@ -486,6 +487,7 @@ func TestDefault(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestUnmarshaling(t *testing.T) {
|
func TestUnmarshaling(t *testing.T) {
|
||||||
|
Reset()
|
||||||
SetConfigType("yaml")
|
SetConfigType("yaml")
|
||||||
r := bytes.NewReader(yamlExample)
|
r := bytes.NewReader(yamlExample)
|
||||||
|
|
||||||
|
@ -524,6 +526,8 @@ func TestDefaultPost(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestAliases(t *testing.T) {
|
func TestAliases(t *testing.T) {
|
||||||
|
initConfigs()
|
||||||
|
Set("age", 40)
|
||||||
RegisterAlias("years", "age")
|
RegisterAlias("years", "age")
|
||||||
assert.Equal(t, 40, Get("years"))
|
assert.Equal(t, 40, Get("years"))
|
||||||
Set("years", 45)
|
Set("years", 45)
|
||||||
|
@ -531,6 +535,7 @@ func TestAliases(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestAliasInConfigFile(t *testing.T) {
|
func TestAliasInConfigFile(t *testing.T) {
|
||||||
|
initConfigs()
|
||||||
// the config file specifies "beard". If we make this an alias for
|
// the config file specifies "beard". If we make this an alias for
|
||||||
// "hasbeard", we still want the old config file to work with beard.
|
// "hasbeard", we still want the old config file to work with beard.
|
||||||
RegisterAlias("beard", "hasbeard")
|
RegisterAlias("beard", "hasbeard")
|
||||||
|
@ -873,6 +878,7 @@ func TestRecursiveAliases(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestUnmarshal(t *testing.T) {
|
func TestUnmarshal(t *testing.T) {
|
||||||
|
Reset()
|
||||||
SetDefault("port", 1313)
|
SetDefault("port", 1313)
|
||||||
Set("name", "Steve")
|
Set("name", "Steve")
|
||||||
Set("duration", "1s1ms")
|
Set("duration", "1s1ms")
|
||||||
|
@ -1277,6 +1283,7 @@ func TestBindPFlagStringToInt(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestBoundCaseSensitivity(t *testing.T) {
|
func TestBoundCaseSensitivity(t *testing.T) {
|
||||||
|
initConfigs()
|
||||||
assert.Equal(t, "brown", Get("eyes"))
|
assert.Equal(t, "brown", Get("eyes"))
|
||||||
|
|
||||||
BindEnv("eYEs", "TURTLE_EYES")
|
BindEnv("eYEs", "TURTLE_EYES")
|
||||||
|
|
Loading…
Add table
Reference in a new issue