MCPcopy
hub / github.com/nextdns/nextdns / writeConfigFile

Function writeConfigFile

host/service/config_test.go:32–44  ·  view source on GitHub ↗

writeConfigFile writes content to a temp file and returns its path.

(t *testing.T, content string)

Source from the content-addressed store, hash-verified

30
31// writeConfigFile writes content to a temp file and returns its path.
32func writeConfigFile(t *testing.T, content string) string {
33 t.Helper()
34 f, err := os.CreateTemp("", "nextdns-config-test-*.conf")
35 if err != nil {
36 t.Fatal(err)
37 }
38 if _, err := f.WriteString(content); err != nil {
39 t.Fatal(err)
40 }
41 f.Close()
42 t.Cleanup(func() { os.Remove(f.Name()) })
43 return f.Name()
44}
45
46// readFile reads the content of a file as a string.
47func readFile(t *testing.T, path string) string {

Calls 2

NameMethod · 0.65
CloseMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…