MCPcopy
hub / github.com/spf13/viper / TestSafeWriteConfig

Function TestSafeWriteConfig

viper_test.go:1943–1955  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1941}
1942
1943func TestSafeWriteConfig(t *testing.T) {
1944 v := New()
1945 fs := afero.NewMemMapFs()
1946 v.SetFs(fs)
1947 v.AddConfigPath("/test")
1948 v.SetConfigName("c")
1949 v.SetConfigType("yaml")
1950 require.NoError(t, v.ReadConfig(bytes.NewBuffer(yamlExample)))
1951 require.NoError(t, v.SafeWriteConfig())
1952 read, err := afero.ReadFile(fs, testutil.AbsFilePath(t, "/test/c.yaml"))
1953 require.NoError(t, err)
1954 assert.YAMLEq(t, string(yamlWriteExpected), string(read))
1955}
1956
1957func TestSafeWriteConfigWithMissingConfigPath(t *testing.T) {
1958 v := New()

Callers

nothing calls this directly

Calls 8

AbsFilePathFunction · 0.92
NewFunction · 0.85
SetFsMethod · 0.80
AddConfigPathMethod · 0.80
SetConfigNameMethod · 0.80
SetConfigTypeMethod · 0.80
ReadConfigMethod · 0.80
SafeWriteConfigMethod · 0.80

Tested by

no test coverage detected