MCPcopy
hub / github.com/grafana/dskit / writeValueToFile

Function writeValueToFile

runtimeconfig/manager_test.go:95–102  ·  view source on GitHub ↗
(t *testing.T, path string, v value)

Source from the content-addressed store, hash-verified

93}
94
95func writeValueToFile(t *testing.T, path string, v value) {
96 t.Helper()
97 buf, err := yaml.Marshal(v)
98 require.NoError(t, err)
99 require.NoError(t, os.WriteFile(path+".tmp", buf, 0777))
100 // Atomically replace file with new file, so that manager cannot see unfinished modification.
101 require.NoError(t, os.Rename(path+".tmp", path))
102}
103
104func newTestOverridesManagerConfig(t *testing.T, reloadPeriod time.Duration, loader func(reader io.Reader) (interface{}, error)) Config {
105 // create empty file

Calls 2

HelperMethod · 0.80
MarshalMethod · 0.45

Tested by

no test coverage detected