From a67343ddd00bba279ae921ae98a9165ccce15692 Mon Sep 17 00:00:00 2001 From: axenteoctavian Date: Fri, 12 Apr 2024 18:00:58 +0300 Subject: [PATCH 1/2] added map support for over writable configs --- common/reflectcommon/structFieldsUpdate.go | 21 +++++++ .../reflectcommon/structFieldsUpdate_test.go | 55 ++++++++++++++++++- .../configOverriding_test.go | 10 ++-- testscommon/toml/config.go | 6 ++ 4 files changed, 84 insertions(+), 8 deletions(-) diff --git a/common/reflectcommon/structFieldsUpdate.go b/common/reflectcommon/structFieldsUpdate.go index 94ad6002c07..66434365179 100644 --- a/common/reflectcommon/structFieldsUpdate.go +++ b/common/reflectcommon/structFieldsUpdate.go @@ -123,6 +123,10 @@ func trySetTheNewValue(value *reflect.Value, newValue interface{}) error { structVal := reflect.ValueOf(newValue) return trySetStructValue(value, structVal) + case reflect.Map: + mapValue := reflect.ValueOf(newValue) + + return tryUpdateMapValue(value, mapValue) default: return fmt.Errorf("unsupported type <%s> when trying to set the value '%v' of type <%s>", valueKind, newValue, reflect.TypeOf(newValue)) } @@ -163,6 +167,23 @@ func trySetStructValue(value *reflect.Value, newValue reflect.Value) error { } } +func tryUpdateMapValue(value *reflect.Value, newValue reflect.Value) error { + if value.IsNil() { + value.Set(reflect.MakeMap(value.Type())) + } + + switch newValue.Kind() { + case reflect.Map: + for _, key := range newValue.MapKeys() { + value.SetMapIndex(key, newValue.MapIndex(key)) + } + default: + return fmt.Errorf("unsupported type <%s> when trying to add value in type <%s>", newValue.Kind(), value.Kind()) + } + + return nil +} + func updateStructFromMap(value *reflect.Value, newValue reflect.Value) error { for _, key := range newValue.MapKeys() { fieldName := key.String() diff --git a/common/reflectcommon/structFieldsUpdate_test.go b/common/reflectcommon/structFieldsUpdate_test.go index d2145ca8fa0..e59695598f4 100644 --- a/common/reflectcommon/structFieldsUpdate_test.go +++ b/common/reflectcommon/structFieldsUpdate_test.go @@ -5,9 +5,10 @@ import ( "reflect" "testing" - "github.com/multiversx/mx-chain-core-go/core" "github.com/multiversx/mx-chain-go/config" "github.com/multiversx/mx-chain-go/testscommon/toml" + + "github.com/multiversx/mx-chain-core-go/core" "github.com/stretchr/testify/require" ) @@ -447,10 +448,10 @@ func TestAdaptStructureValueBasedOnPath(t *testing.T) { expectedNewValue["first"] = 1 expectedNewValue["second"] = 2 - path := "TestMap.Value" + path := "TestInterface.Value" err = AdaptStructureValueBasedOnPath(testConfig, path, expectedNewValue) - require.Equal(t, "unsupported type when trying to set the value 'map[first:1 second:2]' of type ", err.Error()) + require.Equal(t, "unsupported type when trying to set the value 'map[first:1 second:2]' of type ", err.Error()) }) t.Run("should error fit signed for target type not int", func(t *testing.T) { @@ -1193,6 +1194,54 @@ func TestAdaptStructureValueBasedOnPath(t *testing.T) { require.Equal(t, expectedNewValue, testConfig.TestConfigNestedStruct.ConfigNestedStruct.Message.MessageDescription) }) + t.Run("should work on map and override existing value in map", func(t *testing.T) { + t.Parallel() + + testConfig, err := loadTestConfig("../../testscommon/toml/config.toml") + require.NoError(t, err) + + expectedNewValue := make(map[string]int) + expectedNewValue["key"] = 100 + + path := "TestMap.Value" + + err = AdaptStructureValueBasedOnPath(testConfig, path, expectedNewValue) + require.NoError(t, err) + require.Equal(t, 1, len(testConfig.TestMap.Value)) + require.Equal(t, testConfig.TestMap.Value["key"], 100) + }) + + t.Run("should work on map and insert values in map", func(t *testing.T) { + t.Parallel() + + testConfig, err := loadTestConfig("../../testscommon/toml/config.toml") + require.NoError(t, err) + + expectedNewValue := make(map[string]int) + expectedNewValue["first"] = 1 + expectedNewValue["second"] = 2 + + path := "TestMap.Value" + + err = AdaptStructureValueBasedOnPath(testConfig, path, expectedNewValue) + require.NoError(t, err) + require.Equal(t, 3, len(testConfig.TestMap.Value)) + }) + + t.Run("should error on map when override anything else other than map", func(t *testing.T) { + t.Parallel() + + testConfig, err := loadTestConfig("../../testscommon/toml/config.toml") + require.NoError(t, err) + + expectedNewValue := 1 + + path := "TestMap.Value" + + err = AdaptStructureValueBasedOnPath(testConfig, path, expectedNewValue) + require.Equal(t, "unsupported type when trying to add value in type ", err.Error()) + }) + } func loadTestConfig(filepath string) (*toml.Config, error) { diff --git a/config/overridableConfig/configOverriding_test.go b/config/overridableConfig/configOverriding_test.go index 5e23a2bacda..9f187a8a501 100644 --- a/config/overridableConfig/configOverriding_test.go +++ b/config/overridableConfig/configOverriding_test.go @@ -5,6 +5,7 @@ import ( "github.com/multiversx/mx-chain-go/config" p2pConfig "github.com/multiversx/mx-chain-go/p2p/config" + "github.com/stretchr/testify/require" ) @@ -104,16 +105,15 @@ func TestOverrideConfigValues(t *testing.T) { }) t.Run("should work for enableRounds.toml", func(t *testing.T) { - // TODO: fix this test - t.Skip("skipped, as this test requires the fix from this PR: https://github.com/multiversx/mx-chain-go/pull/5851") - t.Parallel() configs := &config.Configs{RoundConfig: &config.RoundConfig{}} + value := make(map[string]config.ActivationRoundByName) + value["DisableAsyncCallV1"] = config.ActivationRoundByName{Round: "37"} - err := OverrideConfigValues([]config.OverridableConfig{{Path: "RoundActivations.DisableAsyncCallV1.Round", Value: "37", File: "enableRounds.toml"}}, configs) + err := OverrideConfigValues([]config.OverridableConfig{{Path: "RoundActivations", Value: value, File: "enableRounds.toml"}}, configs) require.NoError(t, err) - require.Equal(t, uint32(37), configs.RoundConfig.RoundActivations["DisableAsyncCallV1"]) + require.Equal(t, "37", configs.RoundConfig.RoundActivations["DisableAsyncCallV1"].Round) }) t.Run("should work for ratings.toml", func(t *testing.T) { diff --git a/testscommon/toml/config.go b/testscommon/toml/config.go index 47a45839be0..16ec8a7fdd4 100644 --- a/testscommon/toml/config.go +++ b/testscommon/toml/config.go @@ -15,6 +15,7 @@ type Config struct { TestConfigStruct TestConfigNestedStruct TestMap + TestInterface } // TestConfigI8 will hold an int8 value for testing @@ -169,3 +170,8 @@ type MessageDescriptionOtherName struct { type TestMap struct { Value map[string]int } + +// TestInterface will hold an interface for testing +type TestInterface struct { + Value interface{} +} From 10411000c3fd12ceba2da7dcabc180b9d38a3f7e Mon Sep 17 00:00:00 2001 From: axenteoctavian Date: Tue, 16 Apr 2024 18:59:13 +0300 Subject: [PATCH 2/2] over writable map fixes --- common/reflectcommon/structFieldsUpdate.go | 10 +- .../reflectcommon/structFieldsUpdate_test.go | 242 ++++++++---------- testscommon/toml/config.go | 27 +- testscommon/toml/config.toml | 5 +- testscommon/toml/overwrite.toml | 64 ++--- 5 files changed, 163 insertions(+), 185 deletions(-) diff --git a/common/reflectcommon/structFieldsUpdate.go b/common/reflectcommon/structFieldsUpdate.go index 66434365179..be8671eff4f 100644 --- a/common/reflectcommon/structFieldsUpdate.go +++ b/common/reflectcommon/structFieldsUpdate.go @@ -175,7 +175,15 @@ func tryUpdateMapValue(value *reflect.Value, newValue reflect.Value) error { switch newValue.Kind() { case reflect.Map: for _, key := range newValue.MapKeys() { - value.SetMapIndex(key, newValue.MapIndex(key)) + item := newValue.MapIndex(key) + newItem := reflect.New(value.Type().Elem()).Elem() + + err := trySetTheNewValue(&newItem, item.Interface()) + if err != nil { + return err + } + + value.SetMapIndex(key, newItem) } default: return fmt.Errorf("unsupported type <%s> when trying to add value in type <%s>", newValue.Kind(), value.Kind()) diff --git a/common/reflectcommon/structFieldsUpdate_test.go b/common/reflectcommon/structFieldsUpdate_test.go index e59695598f4..44d3ae7d694 100644 --- a/common/reflectcommon/structFieldsUpdate_test.go +++ b/common/reflectcommon/structFieldsUpdate_test.go @@ -518,11 +518,9 @@ func TestAdaptStructureValueBasedOnPath(t *testing.T) { overrideConfig, err := loadOverrideConfig("../../testscommon/toml/overwrite.toml") require.NoError(t, err) - path := "TestConfigI8.Int8.Value" - - err = AdaptStructureValueBasedOnPath(testConfig, path, overrideConfig.OverridableConfigTomlValues[0].Value) + err = AdaptStructureValueBasedOnPath(testConfig, overrideConfig.OverridableConfigTomlValues[0].Path, overrideConfig.OverridableConfigTomlValues[0].Value) require.NoError(t, err) - require.Equal(t, overrideConfig.OverridableConfigTomlValues[0].Value, int64(testConfig.Int8.Value)) + require.Equal(t, overrideConfig.OverridableConfigTomlValues[0].Value, int64(testConfig.Int8.Number)) }) t.Run("should error int8 value", func(t *testing.T) { @@ -534,9 +532,7 @@ func TestAdaptStructureValueBasedOnPath(t *testing.T) { overrideConfig, err := loadOverrideConfig("../../testscommon/toml/overwrite.toml") require.NoError(t, err) - path := "TestConfigI8.Int8.Value" - - err = AdaptStructureValueBasedOnPath(testConfig, path, overrideConfig.OverridableConfigTomlValues[1].Value) + err = AdaptStructureValueBasedOnPath(testConfig, overrideConfig.OverridableConfigTomlValues[1].Path, overrideConfig.OverridableConfigTomlValues[1].Value) require.NotNil(t, err) require.Equal(t, "unable to cast value '128' of type to type ", err.Error()) }) @@ -550,11 +546,9 @@ func TestAdaptStructureValueBasedOnPath(t *testing.T) { overrideConfig, err := loadOverrideConfig("../../testscommon/toml/overwrite.toml") require.NoError(t, err) - path := "TestConfigI8.Int8.Value" - - err = AdaptStructureValueBasedOnPath(testConfig, path, overrideConfig.OverridableConfigTomlValues[2].Value) + err = AdaptStructureValueBasedOnPath(testConfig, overrideConfig.OverridableConfigTomlValues[2].Path, overrideConfig.OverridableConfigTomlValues[2].Value) require.NoError(t, err) - require.Equal(t, overrideConfig.OverridableConfigTomlValues[2].Value, int64(testConfig.Int8.Value)) + require.Equal(t, overrideConfig.OverridableConfigTomlValues[2].Value, int64(testConfig.Int8.Number)) }) t.Run("should error int8 negative value", func(t *testing.T) { @@ -566,9 +560,7 @@ func TestAdaptStructureValueBasedOnPath(t *testing.T) { overrideConfig, err := loadOverrideConfig("../../testscommon/toml/overwrite.toml") require.NoError(t, err) - path := "TestConfigI8.Int8.Value" - - err = AdaptStructureValueBasedOnPath(testConfig, path, overrideConfig.OverridableConfigTomlValues[3].Value) + err = AdaptStructureValueBasedOnPath(testConfig, overrideConfig.OverridableConfigTomlValues[3].Path, overrideConfig.OverridableConfigTomlValues[3].Value) require.NotNil(t, err) require.Equal(t, "unable to cast value '-129' of type to type ", err.Error()) }) @@ -582,11 +574,9 @@ func TestAdaptStructureValueBasedOnPath(t *testing.T) { overrideConfig, err := loadOverrideConfig("../../testscommon/toml/overwrite.toml") require.NoError(t, err) - path := "TestConfigI16.Int16.Value" - - err = AdaptStructureValueBasedOnPath(testConfig, path, overrideConfig.OverridableConfigTomlValues[4].Value) + err = AdaptStructureValueBasedOnPath(testConfig, overrideConfig.OverridableConfigTomlValues[4].Path, overrideConfig.OverridableConfigTomlValues[4].Value) require.NoError(t, err) - require.Equal(t, overrideConfig.OverridableConfigTomlValues[4].Value, int64(testConfig.Int16.Value)) + require.Equal(t, overrideConfig.OverridableConfigTomlValues[4].Value, int64(testConfig.Int16.Number)) }) t.Run("should error int16 value", func(t *testing.T) { @@ -598,9 +588,7 @@ func TestAdaptStructureValueBasedOnPath(t *testing.T) { overrideConfig, err := loadOverrideConfig("../../testscommon/toml/overwrite.toml") require.NoError(t, err) - path := "TestConfigI16.Int16.Value" - - err = AdaptStructureValueBasedOnPath(testConfig, path, overrideConfig.OverridableConfigTomlValues[5].Value) + err = AdaptStructureValueBasedOnPath(testConfig, overrideConfig.OverridableConfigTomlValues[5].Path, overrideConfig.OverridableConfigTomlValues[5].Value) require.NotNil(t, err) require.Equal(t, "unable to cast value '32768' of type to type ", err.Error()) }) @@ -614,11 +602,9 @@ func TestAdaptStructureValueBasedOnPath(t *testing.T) { overrideConfig, err := loadOverrideConfig("../../testscommon/toml/overwrite.toml") require.NoError(t, err) - path := "TestConfigI16.Int16.Value" - - err = AdaptStructureValueBasedOnPath(testConfig, path, overrideConfig.OverridableConfigTomlValues[6].Value) + err = AdaptStructureValueBasedOnPath(testConfig, overrideConfig.OverridableConfigTomlValues[6].Path, overrideConfig.OverridableConfigTomlValues[6].Value) require.NoError(t, err) - require.Equal(t, overrideConfig.OverridableConfigTomlValues[6].Value, int64(testConfig.Int16.Value)) + require.Equal(t, overrideConfig.OverridableConfigTomlValues[6].Value, int64(testConfig.Int16.Number)) }) t.Run("should error int16 negative value", func(t *testing.T) { @@ -630,9 +616,7 @@ func TestAdaptStructureValueBasedOnPath(t *testing.T) { overrideConfig, err := loadOverrideConfig("../../testscommon/toml/overwrite.toml") require.NoError(t, err) - path := "TestConfigI16.Int16.Value" - - err = AdaptStructureValueBasedOnPath(testConfig, path, overrideConfig.OverridableConfigTomlValues[7].Value) + err = AdaptStructureValueBasedOnPath(testConfig, overrideConfig.OverridableConfigTomlValues[7].Path, overrideConfig.OverridableConfigTomlValues[7].Value) require.NotNil(t, err) require.Equal(t, "unable to cast value '-32769' of type to type ", err.Error()) }) @@ -646,11 +630,9 @@ func TestAdaptStructureValueBasedOnPath(t *testing.T) { overrideConfig, err := loadOverrideConfig("../../testscommon/toml/overwrite.toml") require.NoError(t, err) - path := "TestConfigI32.Int32.Value" - - err = AdaptStructureValueBasedOnPath(testConfig, path, overrideConfig.OverridableConfigTomlValues[17].Value) + err = AdaptStructureValueBasedOnPath(testConfig, overrideConfig.OverridableConfigTomlValues[8].Path, overrideConfig.OverridableConfigTomlValues[8].Value) require.NoError(t, err) - require.Equal(t, overrideConfig.OverridableConfigTomlValues[17].Value, int64(testConfig.Int32.Value)) + require.Equal(t, overrideConfig.OverridableConfigTomlValues[8].Value, int64(testConfig.Int32.Number)) }) t.Run("should work and override int32 value with uint16", func(t *testing.T) { @@ -661,11 +643,11 @@ func TestAdaptStructureValueBasedOnPath(t *testing.T) { expectedNewValue := uint16(10) - path := "TestConfigI32.Int32.Value" + path := "TestConfigI32.Int32.Number" err = AdaptStructureValueBasedOnPath(testConfig, path, expectedNewValue) require.NoError(t, err) - require.Equal(t, int32(expectedNewValue), testConfig.Int32.Value) + require.Equal(t, int32(expectedNewValue), testConfig.Int32.Number) }) t.Run("should error int32 value", func(t *testing.T) { @@ -677,9 +659,7 @@ func TestAdaptStructureValueBasedOnPath(t *testing.T) { overrideConfig, err := loadOverrideConfig("../../testscommon/toml/overwrite.toml") require.NoError(t, err) - path := "TestConfigI32.Int32.Value" - - err = AdaptStructureValueBasedOnPath(testConfig, path, overrideConfig.OverridableConfigTomlValues[9].Value) + err = AdaptStructureValueBasedOnPath(testConfig, overrideConfig.OverridableConfigTomlValues[9].Path, overrideConfig.OverridableConfigTomlValues[9].Value) require.NotNil(t, err) require.Equal(t, "unable to cast value '2147483648' of type to type ", err.Error()) }) @@ -693,11 +673,9 @@ func TestAdaptStructureValueBasedOnPath(t *testing.T) { overrideConfig, err := loadOverrideConfig("../../testscommon/toml/overwrite.toml") require.NoError(t, err) - path := "TestConfigI32.Int32.Value" - - err = AdaptStructureValueBasedOnPath(testConfig, path, overrideConfig.OverridableConfigTomlValues[10].Value) + err = AdaptStructureValueBasedOnPath(testConfig, overrideConfig.OverridableConfigTomlValues[10].Path, overrideConfig.OverridableConfigTomlValues[10].Value) require.NoError(t, err) - require.Equal(t, overrideConfig.OverridableConfigTomlValues[10].Value, int64(testConfig.Int32.Value)) + require.Equal(t, overrideConfig.OverridableConfigTomlValues[10].Value, int64(testConfig.Int32.Number)) }) t.Run("should error int32 negative value", func(t *testing.T) { @@ -709,9 +687,7 @@ func TestAdaptStructureValueBasedOnPath(t *testing.T) { overrideConfig, err := loadOverrideConfig("../../testscommon/toml/overwrite.toml") require.NoError(t, err) - path := "TestConfigI32.Int32.Value" - - err = AdaptStructureValueBasedOnPath(testConfig, path, overrideConfig.OverridableConfigTomlValues[11].Value) + err = AdaptStructureValueBasedOnPath(testConfig, overrideConfig.OverridableConfigTomlValues[11].Path, overrideConfig.OverridableConfigTomlValues[11].Value) require.NotNil(t, err) require.Equal(t, "unable to cast value '-2147483649' of type to type ", err.Error()) }) @@ -725,11 +701,9 @@ func TestAdaptStructureValueBasedOnPath(t *testing.T) { overrideConfig, err := loadOverrideConfig("../../testscommon/toml/overwrite.toml") require.NoError(t, err) - path := "TestConfigI64.Int64.Value" - - err = AdaptStructureValueBasedOnPath(testConfig, path, overrideConfig.OverridableConfigTomlValues[12].Value) + err = AdaptStructureValueBasedOnPath(testConfig, overrideConfig.OverridableConfigTomlValues[12].Path, overrideConfig.OverridableConfigTomlValues[12].Value) require.NoError(t, err) - require.Equal(t, overrideConfig.OverridableConfigTomlValues[12].Value, int64(testConfig.Int64.Value)) + require.Equal(t, overrideConfig.OverridableConfigTomlValues[12].Value, int64(testConfig.Int64.Number)) }) t.Run("should work and override int64 negative value", func(t *testing.T) { @@ -741,11 +715,9 @@ func TestAdaptStructureValueBasedOnPath(t *testing.T) { overrideConfig, err := loadOverrideConfig("../../testscommon/toml/overwrite.toml") require.NoError(t, err) - path := "TestConfigI64.Int64.Value" - - err = AdaptStructureValueBasedOnPath(testConfig, path, overrideConfig.OverridableConfigTomlValues[13].Value) + err = AdaptStructureValueBasedOnPath(testConfig, overrideConfig.OverridableConfigTomlValues[13].Path, overrideConfig.OverridableConfigTomlValues[13].Value) require.NoError(t, err) - require.Equal(t, overrideConfig.OverridableConfigTomlValues[13].Value, int64(testConfig.Int64.Value)) + require.Equal(t, overrideConfig.OverridableConfigTomlValues[13].Value, int64(testConfig.Int64.Number)) }) t.Run("should work and override uint8 value", func(t *testing.T) { @@ -757,11 +729,9 @@ func TestAdaptStructureValueBasedOnPath(t *testing.T) { overrideConfig, err := loadOverrideConfig("../../testscommon/toml/overwrite.toml") require.NoError(t, err) - path := "TestConfigU8.Uint8.Value" - - err = AdaptStructureValueBasedOnPath(testConfig, path, overrideConfig.OverridableConfigTomlValues[14].Value) + err = AdaptStructureValueBasedOnPath(testConfig, overrideConfig.OverridableConfigTomlValues[14].Path, overrideConfig.OverridableConfigTomlValues[14].Value) require.NoError(t, err) - require.Equal(t, overrideConfig.OverridableConfigTomlValues[14].Value, int64(testConfig.Uint8.Value)) + require.Equal(t, overrideConfig.OverridableConfigTomlValues[14].Value, int64(testConfig.Uint8.Number)) }) t.Run("should error uint8 value", func(t *testing.T) { @@ -773,9 +743,7 @@ func TestAdaptStructureValueBasedOnPath(t *testing.T) { overrideConfig, err := loadOverrideConfig("../../testscommon/toml/overwrite.toml") require.NoError(t, err) - path := "TestConfigU8.Uint8.Value" - - err = AdaptStructureValueBasedOnPath(testConfig, path, overrideConfig.OverridableConfigTomlValues[15].Value) + err = AdaptStructureValueBasedOnPath(testConfig, overrideConfig.OverridableConfigTomlValues[15].Path, overrideConfig.OverridableConfigTomlValues[15].Value) require.NotNil(t, err) require.Equal(t, "unable to cast value '256' of type to type ", err.Error()) }) @@ -789,9 +757,7 @@ func TestAdaptStructureValueBasedOnPath(t *testing.T) { overrideConfig, err := loadOverrideConfig("../../testscommon/toml/overwrite.toml") require.NoError(t, err) - path := "TestConfigU8.Uint8.Value" - - err = AdaptStructureValueBasedOnPath(testConfig, path, overrideConfig.OverridableConfigTomlValues[16].Value) + err = AdaptStructureValueBasedOnPath(testConfig, overrideConfig.OverridableConfigTomlValues[16].Path, overrideConfig.OverridableConfigTomlValues[16].Value) require.NotNil(t, err) require.Equal(t, "unable to cast value '-256' of type to type ", err.Error()) }) @@ -805,11 +771,9 @@ func TestAdaptStructureValueBasedOnPath(t *testing.T) { overrideConfig, err := loadOverrideConfig("../../testscommon/toml/overwrite.toml") require.NoError(t, err) - path := "TestConfigU16.Uint16.Value" - - err = AdaptStructureValueBasedOnPath(testConfig, path, overrideConfig.OverridableConfigTomlValues[17].Value) + err = AdaptStructureValueBasedOnPath(testConfig, overrideConfig.OverridableConfigTomlValues[17].Path, overrideConfig.OverridableConfigTomlValues[17].Value) require.NoError(t, err) - require.Equal(t, overrideConfig.OverridableConfigTomlValues[17].Value, int64(testConfig.Uint16.Value)) + require.Equal(t, overrideConfig.OverridableConfigTomlValues[17].Value, int64(testConfig.Uint16.Number)) }) t.Run("should error uint16 value", func(t *testing.T) { @@ -821,9 +785,7 @@ func TestAdaptStructureValueBasedOnPath(t *testing.T) { overrideConfig, err := loadOverrideConfig("../../testscommon/toml/overwrite.toml") require.NoError(t, err) - path := "TestConfigU16.Uint16.Value" - - err = AdaptStructureValueBasedOnPath(testConfig, path, overrideConfig.OverridableConfigTomlValues[18].Value) + err = AdaptStructureValueBasedOnPath(testConfig, overrideConfig.OverridableConfigTomlValues[18].Path, overrideConfig.OverridableConfigTomlValues[18].Value) require.NotNil(t, err) require.Equal(t, "unable to cast value '65536' of type to type ", err.Error()) }) @@ -837,9 +799,7 @@ func TestAdaptStructureValueBasedOnPath(t *testing.T) { overrideConfig, err := loadOverrideConfig("../../testscommon/toml/overwrite.toml") require.NoError(t, err) - path := "TestConfigU16.Uint16.Value" - - err = AdaptStructureValueBasedOnPath(testConfig, path, overrideConfig.OverridableConfigTomlValues[19].Value) + err = AdaptStructureValueBasedOnPath(testConfig, overrideConfig.OverridableConfigTomlValues[19].Path, overrideConfig.OverridableConfigTomlValues[19].Value) require.NotNil(t, err) require.Equal(t, "unable to cast value '-65536' of type to type ", err.Error()) }) @@ -853,11 +813,9 @@ func TestAdaptStructureValueBasedOnPath(t *testing.T) { overrideConfig, err := loadOverrideConfig("../../testscommon/toml/overwrite.toml") require.NoError(t, err) - path := "TestConfigU32.Uint32.Value" - - err = AdaptStructureValueBasedOnPath(testConfig, path, overrideConfig.OverridableConfigTomlValues[20].Value) + err = AdaptStructureValueBasedOnPath(testConfig, overrideConfig.OverridableConfigTomlValues[20].Path, overrideConfig.OverridableConfigTomlValues[20].Value) require.NoError(t, err) - require.Equal(t, overrideConfig.OverridableConfigTomlValues[20].Value, int64(testConfig.Uint32.Value)) + require.Equal(t, overrideConfig.OverridableConfigTomlValues[20].Value, int64(testConfig.Uint32.Number)) }) t.Run("should error uint32 value", func(t *testing.T) { @@ -869,9 +827,7 @@ func TestAdaptStructureValueBasedOnPath(t *testing.T) { overrideConfig, err := loadOverrideConfig("../../testscommon/toml/overwrite.toml") require.NoError(t, err) - path := "TestConfigU32.Uint32.Value" - - err = AdaptStructureValueBasedOnPath(testConfig, path, overrideConfig.OverridableConfigTomlValues[21].Value) + err = AdaptStructureValueBasedOnPath(testConfig, overrideConfig.OverridableConfigTomlValues[21].Path, overrideConfig.OverridableConfigTomlValues[21].Value) require.NotNil(t, err) require.Equal(t, "unable to cast value '4294967296' of type to type ", err.Error()) }) @@ -885,9 +841,7 @@ func TestAdaptStructureValueBasedOnPath(t *testing.T) { overrideConfig, err := loadOverrideConfig("../../testscommon/toml/overwrite.toml") require.NoError(t, err) - path := "TestConfigU32.Uint32.Value" - - err = AdaptStructureValueBasedOnPath(testConfig, path, overrideConfig.OverridableConfigTomlValues[22].Value) + err = AdaptStructureValueBasedOnPath(testConfig, overrideConfig.OverridableConfigTomlValues[22].Path, overrideConfig.OverridableConfigTomlValues[22].Value) require.NotNil(t, err) require.Equal(t, "unable to cast value '-4294967296' of type to type ", err.Error()) }) @@ -901,11 +855,9 @@ func TestAdaptStructureValueBasedOnPath(t *testing.T) { overrideConfig, err := loadOverrideConfig("../../testscommon/toml/overwrite.toml") require.NoError(t, err) - path := "TestConfigU64.Uint64.Value" - - err = AdaptStructureValueBasedOnPath(testConfig, path, overrideConfig.OverridableConfigTomlValues[23].Value) + err = AdaptStructureValueBasedOnPath(testConfig, overrideConfig.OverridableConfigTomlValues[23].Path, overrideConfig.OverridableConfigTomlValues[23].Value) require.NoError(t, err) - require.Equal(t, overrideConfig.OverridableConfigTomlValues[23].Value, int64(testConfig.Uint64.Value)) + require.Equal(t, overrideConfig.OverridableConfigTomlValues[23].Value, int64(testConfig.Uint64.Number)) }) t.Run("should error uint64 negative value", func(t *testing.T) { @@ -917,9 +869,7 @@ func TestAdaptStructureValueBasedOnPath(t *testing.T) { overrideConfig, err := loadOverrideConfig("../../testscommon/toml/overwrite.toml") require.NoError(t, err) - path := "TestConfigU64.Uint64.Value" - - err = AdaptStructureValueBasedOnPath(testConfig, path, overrideConfig.OverridableConfigTomlValues[24].Value) + err = AdaptStructureValueBasedOnPath(testConfig, overrideConfig.OverridableConfigTomlValues[24].Path, overrideConfig.OverridableConfigTomlValues[24].Value) require.Equal(t, "unable to cast value '-9223372036854775808' of type to type ", err.Error()) }) @@ -932,11 +882,9 @@ func TestAdaptStructureValueBasedOnPath(t *testing.T) { overrideConfig, err := loadOverrideConfig("../../testscommon/toml/overwrite.toml") require.NoError(t, err) - path := "TestConfigF32.Float32.Value" - - err = AdaptStructureValueBasedOnPath(testConfig, path, overrideConfig.OverridableConfigTomlValues[25].Value) + err = AdaptStructureValueBasedOnPath(testConfig, overrideConfig.OverridableConfigTomlValues[25].Path, overrideConfig.OverridableConfigTomlValues[25].Value) require.NoError(t, err) - require.Equal(t, float32(3.4), testConfig.Float32.Value) + require.Equal(t, float32(3.4), testConfig.Float32.Number) }) t.Run("should error float32 value", func(t *testing.T) { @@ -948,9 +896,7 @@ func TestAdaptStructureValueBasedOnPath(t *testing.T) { overrideConfig, err := loadOverrideConfig("../../testscommon/toml/overwrite.toml") require.NoError(t, err) - path := "TestConfigF32.Float32.Value" - - err = AdaptStructureValueBasedOnPath(testConfig, path, overrideConfig.OverridableConfigTomlValues[26].Value) + err = AdaptStructureValueBasedOnPath(testConfig, overrideConfig.OverridableConfigTomlValues[26].Path, overrideConfig.OverridableConfigTomlValues[26].Value) require.NotNil(t, err) require.Equal(t, "unable to cast value '3.4e+39' of type to type ", err.Error()) }) @@ -964,11 +910,9 @@ func TestAdaptStructureValueBasedOnPath(t *testing.T) { overrideConfig, err := loadOverrideConfig("../../testscommon/toml/overwrite.toml") require.NoError(t, err) - path := "TestConfigF32.Float32.Value" - - err = AdaptStructureValueBasedOnPath(testConfig, path, overrideConfig.OverridableConfigTomlValues[27].Value) + err = AdaptStructureValueBasedOnPath(testConfig, overrideConfig.OverridableConfigTomlValues[27].Path, overrideConfig.OverridableConfigTomlValues[27].Value) require.NoError(t, err) - require.Equal(t, float32(-3.4), testConfig.Float32.Value) + require.Equal(t, float32(-3.4), testConfig.Float32.Number) }) t.Run("should error float32 negative value", func(t *testing.T) { @@ -980,9 +924,7 @@ func TestAdaptStructureValueBasedOnPath(t *testing.T) { overrideConfig, err := loadOverrideConfig("../../testscommon/toml/overwrite.toml") require.NoError(t, err) - path := "TestConfigF32.Float32.Value" - - err = AdaptStructureValueBasedOnPath(testConfig, path, overrideConfig.OverridableConfigTomlValues[28].Value) + err = AdaptStructureValueBasedOnPath(testConfig, overrideConfig.OverridableConfigTomlValues[28].Path, overrideConfig.OverridableConfigTomlValues[28].Value) require.NotNil(t, err) require.Equal(t, "unable to cast value '-3.4e+40' of type to type ", err.Error()) }) @@ -996,11 +938,9 @@ func TestAdaptStructureValueBasedOnPath(t *testing.T) { overrideConfig, err := loadOverrideConfig("../../testscommon/toml/overwrite.toml") require.NoError(t, err) - path := "TestConfigF64.Float64.Value" - - err = AdaptStructureValueBasedOnPath(testConfig, path, overrideConfig.OverridableConfigTomlValues[29].Value) + err = AdaptStructureValueBasedOnPath(testConfig, overrideConfig.OverridableConfigTomlValues[29].Path, overrideConfig.OverridableConfigTomlValues[29].Value) require.NoError(t, err) - require.Equal(t, overrideConfig.OverridableConfigTomlValues[29].Value, testConfig.Float64.Value) + require.Equal(t, overrideConfig.OverridableConfigTomlValues[29].Value, testConfig.Float64.Number) }) t.Run("should work and override float64 negative value", func(t *testing.T) { @@ -1012,11 +952,9 @@ func TestAdaptStructureValueBasedOnPath(t *testing.T) { overrideConfig, err := loadOverrideConfig("../../testscommon/toml/overwrite.toml") require.NoError(t, err) - path := "TestConfigF64.Float64.Value" - - err = AdaptStructureValueBasedOnPath(testConfig, path, overrideConfig.OverridableConfigTomlValues[30].Value) + err = AdaptStructureValueBasedOnPath(testConfig, overrideConfig.OverridableConfigTomlValues[30].Path, overrideConfig.OverridableConfigTomlValues[30].Value) require.NoError(t, err) - require.Equal(t, overrideConfig.OverridableConfigTomlValues[30].Value, testConfig.Float64.Value) + require.Equal(t, overrideConfig.OverridableConfigTomlValues[30].Value, testConfig.Float64.Number) }) t.Run("should work and override struct", func(t *testing.T) { @@ -1028,13 +966,11 @@ func TestAdaptStructureValueBasedOnPath(t *testing.T) { overrideConfig, err := loadOverrideConfig("../../testscommon/toml/overwrite.toml") require.NoError(t, err) - path := "TestConfigStruct.ConfigStruct.Description" - expectedNewValue := toml.Description{ Number: 11, } - err = AdaptStructureValueBasedOnPath(testConfig, path, overrideConfig.OverridableConfigTomlValues[31].Value) + err = AdaptStructureValueBasedOnPath(testConfig, overrideConfig.OverridableConfigTomlValues[31].Path, overrideConfig.OverridableConfigTomlValues[31].Value) require.NoError(t, err) require.Equal(t, expectedNewValue, testConfig.TestConfigStruct.ConfigStruct.Description) }) @@ -1048,9 +984,7 @@ func TestAdaptStructureValueBasedOnPath(t *testing.T) { overrideConfig, err := loadOverrideConfig("../../testscommon/toml/overwrite.toml") require.NoError(t, err) - path := "TestConfigStruct.ConfigStruct.Description" - - err = AdaptStructureValueBasedOnPath(testConfig, path, overrideConfig.OverridableConfigTomlValues[32].Value) + err = AdaptStructureValueBasedOnPath(testConfig, overrideConfig.OverridableConfigTomlValues[32].Path, overrideConfig.OverridableConfigTomlValues[32].Value) require.Equal(t, "field not found or cannot be set", err.Error()) }) @@ -1063,9 +997,7 @@ func TestAdaptStructureValueBasedOnPath(t *testing.T) { overrideConfig, err := loadOverrideConfig("../../testscommon/toml/overwrite.toml") require.NoError(t, err) - path := "TestConfigStruct.ConfigStruct.Description" - - err = AdaptStructureValueBasedOnPath(testConfig, path, overrideConfig.OverridableConfigTomlValues[33].Value) + err = AdaptStructureValueBasedOnPath(testConfig, overrideConfig.OverridableConfigTomlValues[33].Path, overrideConfig.OverridableConfigTomlValues[33].Value) require.Equal(t, "unable to cast value '11' of type to type ", err.Error()) }) @@ -1078,8 +1010,6 @@ func TestAdaptStructureValueBasedOnPath(t *testing.T) { overrideConfig, err := loadOverrideConfig("../../testscommon/toml/overwrite.toml") require.NoError(t, err) - path := "TestConfigNestedStruct.ConfigNestedStruct" - expectedNewValue := toml.ConfigNestedStruct{ Text: "Overwritten text", Message: toml.Message{ @@ -1090,7 +1020,7 @@ func TestAdaptStructureValueBasedOnPath(t *testing.T) { }, } - err = AdaptStructureValueBasedOnPath(testConfig, path, overrideConfig.OverridableConfigTomlValues[34].Value) + err = AdaptStructureValueBasedOnPath(testConfig, overrideConfig.OverridableConfigTomlValues[34].Path, overrideConfig.OverridableConfigTomlValues[34].Value) require.NoError(t, err) require.Equal(t, expectedNewValue, testConfig.TestConfigNestedStruct.ConfigNestedStruct) }) @@ -1104,14 +1034,12 @@ func TestAdaptStructureValueBasedOnPath(t *testing.T) { overrideConfig, err := loadOverrideConfig("../../testscommon/toml/overwrite.toml") require.NoError(t, err) - path := "TestConfigNestedStruct.ConfigNestedStruct.Message.MessageDescription" - expectedNewValue := []toml.MessageDescription{ {Text: "Overwritten Text1"}, {Text: "Overwritten Text2"}, } - err = AdaptStructureValueBasedOnPath(testConfig, path, overrideConfig.OverridableConfigTomlValues[35].Value) + err = AdaptStructureValueBasedOnPath(testConfig, overrideConfig.OverridableConfigTomlValues[35].Path, overrideConfig.OverridableConfigTomlValues[35].Value) require.NoError(t, err) require.Equal(t, expectedNewValue, testConfig.TestConfigNestedStruct.ConfigNestedStruct.Message.MessageDescription) }) @@ -1194,38 +1122,72 @@ func TestAdaptStructureValueBasedOnPath(t *testing.T) { require.Equal(t, expectedNewValue, testConfig.TestConfigNestedStruct.ConfigNestedStruct.Message.MessageDescription) }) - t.Run("should work on map and override existing value in map", func(t *testing.T) { + t.Run("should work on map, override and insert from config", func(t *testing.T) { t.Parallel() testConfig, err := loadTestConfig("../../testscommon/toml/config.toml") require.NoError(t, err) - expectedNewValue := make(map[string]int) - expectedNewValue["key"] = 100 + overrideConfig, err := loadOverrideConfig("../../testscommon/toml/overwrite.toml") + require.NoError(t, err) - path := "TestMap.Value" + err = AdaptStructureValueBasedOnPath(testConfig, overrideConfig.OverridableConfigTomlValues[36].Path, overrideConfig.OverridableConfigTomlValues[36].Value) + require.NoError(t, err) + require.Equal(t, 2, len(testConfig.TestMap.Map)) + require.Equal(t, 10, testConfig.TestMap.Map["Key1"].Number) + require.Equal(t, 11, testConfig.TestMap.Map["Key2"].Number) + }) - err = AdaptStructureValueBasedOnPath(testConfig, path, expectedNewValue) + t.Run("should work on map and insert from config", func(t *testing.T) { + t.Parallel() + + testConfig, err := loadTestConfig("../../testscommon/toml/config.toml") + require.NoError(t, err) + + overrideConfig, err := loadOverrideConfig("../../testscommon/toml/overwrite.toml") + require.NoError(t, err) + + err = AdaptStructureValueBasedOnPath(testConfig, overrideConfig.OverridableConfigTomlValues[37].Path, overrideConfig.OverridableConfigTomlValues[37].Value) require.NoError(t, err) - require.Equal(t, 1, len(testConfig.TestMap.Value)) - require.Equal(t, testConfig.TestMap.Value["key"], 100) + require.Equal(t, 3, len(testConfig.TestMap.Map)) + require.Equal(t, 999, testConfig.TestMap.Map["Key1"].Number) + require.Equal(t, 2, testConfig.TestMap.Map["Key2"].Number) + require.Equal(t, 3, testConfig.TestMap.Map["Key3"].Number) }) - t.Run("should work on map and insert values in map", func(t *testing.T) { + t.Run("should work on map, override and insert values in map", func(t *testing.T) { t.Parallel() testConfig, err := loadTestConfig("../../testscommon/toml/config.toml") require.NoError(t, err) - expectedNewValue := make(map[string]int) - expectedNewValue["first"] = 1 - expectedNewValue["second"] = 2 + expectedNewValue := make(map[string]toml.MapValues) + expectedNewValue["Key1"] = toml.MapValues{Number: 100} + expectedNewValue["Key2"] = toml.MapValues{Number: 200} - path := "TestMap.Value" + path := "TestMap.Map" err = AdaptStructureValueBasedOnPath(testConfig, path, expectedNewValue) require.NoError(t, err) - require.Equal(t, 3, len(testConfig.TestMap.Value)) + require.Equal(t, 2, len(testConfig.TestMap.Map)) + require.Equal(t, 100, testConfig.TestMap.Map["Key1"].Number) + require.Equal(t, 200, testConfig.TestMap.Map["Key2"].Number) + }) + + t.Run("should error on map when override different map", func(t *testing.T) { + t.Parallel() + + testConfig, err := loadTestConfig("../../testscommon/toml/config.toml") + require.NoError(t, err) + + expectedNewValue := make(map[string]toml.MessageDescription) + expectedNewValue["Key1"] = toml.MessageDescription{Text: "A"} + expectedNewValue["Key2"] = toml.MessageDescription{Text: "B"} + + path := "TestMap.Map" + + err = AdaptStructureValueBasedOnPath(testConfig, path, expectedNewValue) + require.Equal(t, "field not found or cannot be set", err.Error()) }) t.Run("should error on map when override anything else other than map", func(t *testing.T) { @@ -1236,7 +1198,7 @@ func TestAdaptStructureValueBasedOnPath(t *testing.T) { expectedNewValue := 1 - path := "TestMap.Value" + path := "TestMap.Map" err = AdaptStructureValueBasedOnPath(testConfig, path, expectedNewValue) require.Equal(t, "unsupported type when trying to add value in type ", err.Error()) diff --git a/testscommon/toml/config.go b/testscommon/toml/config.go index 16ec8a7fdd4..56cfeb1f0ad 100644 --- a/testscommon/toml/config.go +++ b/testscommon/toml/config.go @@ -25,7 +25,7 @@ type TestConfigI8 struct { // Int8 will hold the value type Int8 struct { - Value int8 + Number int8 } // TestConfigI16 will hold an int16 value for testing @@ -35,7 +35,7 @@ type TestConfigI16 struct { // Int16 will hold the value type Int16 struct { - Value int16 + Number int16 } // TestConfigI32 will hold an int32 value for testing @@ -45,7 +45,7 @@ type TestConfigI32 struct { // Int32 will hold the value type Int32 struct { - Value int32 + Number int32 } // TestConfigI64 will hold an int64 value for testing @@ -55,7 +55,7 @@ type TestConfigI64 struct { // Int64 will hold the value type Int64 struct { - Value int64 + Number int64 } // TestConfigU8 will hold an uint8 value for testing @@ -65,7 +65,7 @@ type TestConfigU8 struct { // Uint8 will hold the value type Uint8 struct { - Value uint8 + Number uint8 } // TestConfigU16 will hold an uint16 value for testing @@ -75,7 +75,7 @@ type TestConfigU16 struct { // Uint16 will hold the value type Uint16 struct { - Value uint16 + Number uint16 } // TestConfigU32 will hold an uint32 value for testing @@ -85,7 +85,7 @@ type TestConfigU32 struct { // Uint32 will hold the value type Uint32 struct { - Value uint32 + Number uint32 } // TestConfigU64 will hold an uint64 value for testing @@ -95,7 +95,7 @@ type TestConfigU64 struct { // Uint64 will hold the value type Uint64 struct { - Value uint64 + Number uint64 } // TestConfigF32 will hold a float32 value for testing @@ -105,7 +105,7 @@ type TestConfigF32 struct { // Float32 will hold the value type Float32 struct { - Value float32 + Number float32 } // TestConfigF64 will hold a float64 value for testing @@ -115,7 +115,7 @@ type TestConfigF64 struct { // Float64 will hold the value type Float64 struct { - Value float64 + Number float64 } // TestConfigStruct will hold a configuration struct for testing @@ -168,7 +168,12 @@ type MessageDescriptionOtherName struct { // TestMap will hold a map for testing type TestMap struct { - Value map[string]int + Map map[string]MapValues +} + +// MapValues will hold a value for map +type MapValues struct { + Number int } // TestInterface will hold an interface for testing diff --git a/testscommon/toml/config.toml b/testscommon/toml/config.toml index af54141fe5f..91512d5e664 100644 --- a/testscommon/toml/config.toml +++ b/testscommon/toml/config.toml @@ -48,5 +48,6 @@ Text = "Config Nested Struct" Mesage = { Public = true, MessageDescription = [{ Text = "Text1" }, { Text = "Text2"}] } -[TestMap] - Value = { "key" = 0 } +[Map] + [Map.Key1] + Number = 999 diff --git a/testscommon/toml/overwrite.toml b/testscommon/toml/overwrite.toml index 5d1e6690caf..63f74b7828c 100644 --- a/testscommon/toml/overwrite.toml +++ b/testscommon/toml/overwrite.toml @@ -1,38 +1,40 @@ OverridableConfigTomlValues = [ - { File = "config.toml", Path = "TestConfigI8.Int8", Value = 127 }, - { File = "config.toml", Path = "TestConfigI8.Int8", Value = 128 }, - { File = "config.toml", Path = "TestConfigI8.Int8", Value = -128 }, - { File = "config.toml", Path = "TestConfigI8.Int8", Value = -129 }, - { File = "config.toml", Path = "TestConfigI16.Int16", Value = 32767 }, - { File = "config.toml", Path = "TestConfigI16.Int16", Value = 32768 }, - { File = "config.toml", Path = "TestConfigI16.Int16", Value = -32768 }, - { File = "config.toml", Path = "TestConfigI16.Int16", Value = -32769 }, - { File = "config.toml", Path = "TestConfigI32.Int32", Value = 2147483647 }, - { File = "config.toml", Path = "TestConfigI32.Int32", Value = 2147483648 }, - { File = "config.toml", Path = "TestConfigI32.Int32", Value = -2147483648 }, - { File = "config.toml", Path = "TestConfigI32.Int32", Value = -2147483649 }, - { File = "config.toml", Path = "TestConfigI32.Int64", Value = 9223372036854775807 }, - { File = "config.toml", Path = "TestConfigI32.Int64", Value = -9223372036854775808 }, - { File = "config.toml", Path = "TestConfigU8.Uint8", Value = 255 }, - { File = "config.toml", Path = "TestConfigU8.Uint8", Value = 256 }, - { File = "config.toml", Path = "TestConfigU8.Uint8", Value = -256 }, - { File = "config.toml", Path = "TestConfigU16.Uint16", Value = 65535 }, - { File = "config.toml", Path = "TestConfigU16.Uint16", Value = 65536 }, - { File = "config.toml", Path = "TestConfigU16.Uint16", Value = -65536 }, - { File = "config.toml", Path = "TestConfigU32.Uint32", Value = 4294967295 }, - { File = "config.toml", Path = "TestConfigU32.Uint32", Value = 4294967296 }, - { File = "config.toml", Path = "TestConfigU32.Uint32", Value = -4294967296 }, - { File = "config.toml", Path = "TestConfigU64.Uint64", Value = 9223372036854775807 }, - { File = "config.toml", Path = "TestConfigU64.Uint64", Value = -9223372036854775808 }, - { File = "config.toml", Path = "TestConfigF32.Float32", Value = 3.4 }, - { File = "config.toml", Path = "TestConfigF32.Float32", Value = 3.4e+39 }, - { File = "config.toml", Path = "TestConfigF32.Float32", Value = -3.4 }, - { File = "config.toml", Path = "TestConfigF32.Float32", Value = -3.4e+40 }, - { File = "config.toml", Path = "TestConfigF64.Float64", Value = 1.7e+308 }, - { File = "config.toml", Path = "TestConfigF64.Float64", Value = -1.7e+308 }, + { File = "config.toml", Path = "TestConfigI8.Int8.Number", Value = 127 }, + { File = "config.toml", Path = "TestConfigI8.Int8.Number", Value = 128 }, + { File = "config.toml", Path = "TestConfigI8.Int8.Number", Value = -128 }, + { File = "config.toml", Path = "TestConfigI8.Int8.Number", Value = -129 }, + { File = "config.toml", Path = "TestConfigI16.Int16.Number", Value = 32767 }, + { File = "config.toml", Path = "TestConfigI16.Int16.Number", Value = 32768 }, + { File = "config.toml", Path = "TestConfigI16.Int16.Number", Value = -32768 }, + { File = "config.toml", Path = "TestConfigI16.Int16.Number", Value = -32769 }, + { File = "config.toml", Path = "TestConfigI32.Int32.Number", Value = 2147483647 }, + { File = "config.toml", Path = "TestConfigI32.Int32.Number", Value = 2147483648 }, + { File = "config.toml", Path = "TestConfigI32.Int32.Number", Value = -2147483648 }, + { File = "config.toml", Path = "TestConfigI32.Int32.Number", Value = -2147483649 }, + { File = "config.toml", Path = "TestConfigI64.Int64.Number", Value = 9223372036854775807 }, + { File = "config.toml", Path = "TestConfigI64.Int64.Number", Value = -9223372036854775808 }, + { File = "config.toml", Path = "TestConfigU8.Uint8.Number", Value = 255 }, + { File = "config.toml", Path = "TestConfigU8.Uint8.Number", Value = 256 }, + { File = "config.toml", Path = "TestConfigU8.Uint8.Number", Value = -256 }, + { File = "config.toml", Path = "TestConfigU16.Uint16.Number", Value = 65535 }, + { File = "config.toml", Path = "TestConfigU16.Uint16.Number", Value = 65536 }, + { File = "config.toml", Path = "TestConfigU16.Uint16.Number", Value = -65536 }, + { File = "config.toml", Path = "TestConfigU32.Uint32.Number", Value = 4294967295 }, + { File = "config.toml", Path = "TestConfigU32.Uint32.Number", Value = 4294967296 }, + { File = "config.toml", Path = "TestConfigU32.Uint32.Number", Value = -4294967296 }, + { File = "config.toml", Path = "TestConfigU64.Uint64.Number", Value = 9223372036854775807 }, + { File = "config.toml", Path = "TestConfigU64.Uint64.Number", Value = -9223372036854775808 }, + { File = "config.toml", Path = "TestConfigF32.Float32.Number", Value = 3.4 }, + { File = "config.toml", Path = "TestConfigF32.Float32.Number", Value = 3.4e+39 }, + { File = "config.toml", Path = "TestConfigF32.Float32.Number", Value = -3.4 }, + { File = "config.toml", Path = "TestConfigF32.Float32.Number", Value = -3.4e+40 }, + { File = "config.toml", Path = "TestConfigF64.Float64.Number", Value = 1.7e+308 }, + { File = "config.toml", Path = "TestConfigF64.Float64.Number", Value = -1.7e+308 }, { File = "config.toml", Path = "TestConfigStruct.ConfigStruct.Description", Value = { Number = 11 } }, { File = "config.toml", Path = "TestConfigStruct.ConfigStruct.Description", Value = { Nr = 222 } }, { File = "config.toml", Path = "TestConfigStruct.ConfigStruct.Description", Value = { Number = "11" } }, { File = "config.toml", Path = "TestConfigNestedStruct.ConfigNestedStruct", Value = { Text = "Overwritten text", Message = { Public = false, MessageDescription = [{ Text = "Overwritten Text1" }] } } }, { File = "config.toml", Path = "TestConfigNestedStruct.ConfigNestedStruct.Message.MessageDescription", Value = [{ Text = "Overwritten Text1" }, { Text = "Overwritten Text2" }] }, + { File = "config.toml", Path = "TestMap.Map", Value = { "Key1" = { Number = 10 }, "Key2" = { Number = 11 } } }, + { File = "config.toml", Path = "TestMap.Map", Value = { "Key2" = { Number = 2 }, "Key3" = { Number = 3 } } }, ]