Skip to content

Commit

Permalink
Add missing test cases that weren't covered before.
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthew Witkowski committed Sep 13, 2023
1 parent 5309ea1 commit acbb807
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions cmd/provenanced/config/manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,27 @@ func (s *ConfigManagerTestSuite) TestUnmanagedConfig() {
assert.Equal(t, "stuff", actual, "unmanaged field value")
})

s.T().Run("unmanaged config is read with invalid packed files", func(t *testing.T) {
dCmd := s.makeDummyCmd()
uFile := GetFullPathToUnmanagedConf(dCmd)
pFile := GetFullPathToPackedConf(dCmd)
SaveConfigs(dCmd, DefaultAppConfig(), DefaultTmConfig(), DefaultClientConfig(), false)
require.NoError(t, os.WriteFile(uFile, []byte("my-custom-entry = \"stuff\"\n"), 0o644), "writing unmanaged config")
require.NoError(t, os.WriteFile(pFile, []byte("kl234508923u5jl"), 0o644), "writing invalid data to packed config")
require.EqualError(t, LoadConfigFromFiles(dCmd), "packed config file parse error: invalid character 'k' looking for beginning of value", "should throw error with invalid packed config")
require.NoError(t, os.Remove(pFile), "removing packed config")
})

s.T().Run("unmanaged config is read with invalid unpacked files", func(t *testing.T) {
dCmd := s.makeDummyCmd()
uFile := GetFullPathToUnmanagedConf(dCmd)
pFile := GetFullPathToAppConf(dCmd)
SaveConfigs(dCmd, DefaultAppConfig(), DefaultTmConfig(), DefaultClientConfig(), false)
require.NoError(t, os.WriteFile(uFile, []byte("my-custom-entry = \"stuff\"\n"), 0o644), "writing unmanaged config")
require.NoError(t, os.WriteFile(pFile, []byte("kl234508923u5jl"), 0o644), "writing invalid data to app config")
require.EqualError(t, LoadConfigFromFiles(dCmd), "app config file merge error: While parsing config: toml: expected = after a key, but the document ends there", "should throw error with invalid packed config")
})

s.T().Run("unmanaged config is read with packed config", func(t *testing.T) {
dCmd := s.makeDummyCmd()
uFile := GetFullPathToUnmanagedConf(dCmd)
Expand Down

0 comments on commit acbb807

Please sign in to comment.