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

Function TestSafeWriteConfigWithExistingFile

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

Source from the content-addressed store, hash-verified

1964}
1965
1966func TestSafeWriteConfigWithExistingFile(t *testing.T) {
1967 v := New()
1968 fs := afero.NewMemMapFs()
1969 fs.Create(testutil.AbsFilePath(t, "/test/c.yaml"))
1970 v.SetFs(fs)
1971 v.AddConfigPath("/test")
1972 v.SetConfigName("c")
1973 v.SetConfigType("yaml")
1974 err := v.SafeWriteConfig()
1975 require.Error(t, err)
1976 _, ok := err.(ConfigFileAlreadyExistsError)
1977 assert.True(t, ok, "Expected ConfigFileAlreadyExistsError")
1978}
1979
1980func TestSafeWriteAsConfig(t *testing.T) {
1981 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
SafeWriteConfigMethod · 0.80
ErrorMethod · 0.45

Tested by

no test coverage detected