Skip to content

Commit

Permalink
Changes requested in PR
Browse files Browse the repository at this point in the history
- Add test case for uint64(-1000) conversion
- Clean existing test case
  • Loading branch information
crobert-1 committed Feb 5, 2024
1 parent c8c576f commit be15997
Showing 1 changed file with 22 additions and 6 deletions.
28 changes: 22 additions & 6 deletions confmap/confmap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,11 +219,6 @@ type UintConfig struct {
}

func TestUintUnmarshalerSuccess(t *testing.T) {
testValue := 1000
stringMap := map[string]any{
"uint_test": testValue,
}

tests := []struct {
name string
testValue int
Expand All @@ -242,15 +237,36 @@ func TestUintUnmarshalerSuccess(t *testing.T) {
tt := tt

t.Run(tt.name, func(t *testing.T) {
stringMap := map[string]any{
"uint_test": tt.testValue,
}
conf := NewFromStringMap(stringMap)
cfg := &UintConfig{}
err := conf.Unmarshal(cfg)

assert.NoError(t, err)
assert.Equal(t, cfg.UintTest, uint32(testValue))
assert.Equal(t, cfg.UintTest, uint32(tt.testValue))
})
}
}

func TestUint64Unmarshaler(t *testing.T) {
negativeInt := -1000
testValue := uint64(negativeInt)

type Uint64Config struct {
UintTest uint64 `mapstructure:"uint_test"`
}
stringMap := map[string]any{
"uint_test": testValue,
}

conf := NewFromStringMap(stringMap)
cfg := &Uint64Config{}
err := conf.Unmarshal(cfg)

assert.NoError(t, err)
assert.Equal(t, cfg.UintTest, testValue)
}

func TestUintUnmarshalerFailure(t *testing.T) {
Expand Down

0 comments on commit be15997

Please sign in to comment.