refactor: simplify test asserts (#1271)

This commit is contained in:
Oleksandr Redko authored and GitHub committed 2023-10-03 10:38:08 -05:00
1 parent d37b38f2ee
commit 2959fc072c
10 files changed
+151 -297

No files matched your search

+4 -13
View File
@@ -7,6 +7,7 @@ import (
"github.com/spf13/viper"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
const configPath = "../testdata/config/"
@@ -126,23 +127,13 @@ func TestTranslate(t *testing.T) {
viper.SetConfigName(tt.cfgName)
viper.SetConfigType("toml")
err := viper.ReadInConfig()
if err != nil {
t.Error(err)
}
require.NoError(t, err)
var vc ViperConfig
err = viper.Unmarshal(&vc)
if err != nil {
t.Error(err)
}
require.NoError(t, err)
cfg, err := vc.Translate()
if tt.wantError != nil {
if err == nil {
t.Errorf("expected error")
}
assert.Equal(t, tt.wantError, err)
}
assert.Equal(t, tt.wantError, err)
assert.Equal(t, cfg.Rules, tt.cfg.Rules)
}
}