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

Function newViperWithConfigFile

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

Source from the content-addressed store, hash-verified

2365}
2366
2367func newViperWithConfigFile(t *testing.T) (*Viper, string) {
2368 watchDir := t.TempDir()
2369 configFile := path.Join(watchDir, "config.yaml")
2370 err := os.WriteFile(configFile, []byte("foo: bar\n"), 0o640)
2371 require.NoError(t, err)
2372 v := New()
2373 v.SetConfigFile(configFile)
2374 err = v.ReadInConfig()
2375 require.NoError(t, err)
2376 require.Equal(t, "bar", v.Get("foo"))
2377 return v, configFile
2378}
2379
2380func newViperWithSymlinkedConfigFile(t *testing.T) (*Viper, string, string) {
2381 watchDir := t.TempDir()

Callers 1

TestWatchFileFunction · 0.85

Calls 4

NewFunction · 0.85
SetConfigFileMethod · 0.80
ReadInConfigMethod · 0.80
GetMethod · 0.65

Tested by

no test coverage detected