diff --git a/config/config_test.go b/config/config_test.go index 98003598..8019ed5f 100644 --- a/config/config_test.go +++ b/config/config_test.go @@ -7,7 +7,7 @@ import ( "github.com/stretchr/testify/require" ) -func TestXxx(t *testing.T) { +func TestLoadDeafaultConfig(t *testing.T) { tmpFile, err := os.CreateTemp("", "ut_config") require.NoError(t, err) defer os.Remove(tmpFile.Name()) @@ -16,3 +16,33 @@ func TestXxx(t *testing.T) { require.NoError(t, err) require.NotNil(t, cfg) } + +const configWithUnexpectedFields = ` +[UnknownField] +Field = "value" +` + +func TestLoadConfigWithUnexpectedFields(t *testing.T) { + tmpFile, err := os.CreateTemp("", "ut_config") + require.NoError(t, err) + defer os.Remove(tmpFile.Name()) + tmpFile.Write([]byte(configWithUnexpectedFields)) + cfg, err := LoadFile(tmpFile.Name()) + require.NoError(t, err) + require.NotNil(t, cfg) +} + +const configWithForbiddenFields = ` +[aggregator.synchronizer.db] +name = "value" +` + +func TestLoadConfigWithForbiddenFields(t *testing.T) { + tmpFile, err := os.CreateTemp("", "ut_config") + require.NoError(t, err) + defer os.Remove(tmpFile.Name()) + tmpFile.Write([]byte(configWithForbiddenFields)) + cfg, err := LoadFile(tmpFile.Name()) + require.NoError(t, err) + require.NotNil(t, cfg) +}