MCPcopy Create free account
hub / github.com/buildkite/agent-stack-k8s / createTempConfigFile

Function createTempConfigFile

cmd/controller/controller_test.go:594–608  ·  view source on GitHub ↗

createTempConfigFile creates a temporary config file with the given content and returns its path. The file is automatically cleaned up after the test.

(t *testing.T, content string)

Source from the content-addressed store, hash-verified

592// createTempConfigFile creates a temporary config file with the given content
593// and returns its path. The file is automatically cleaned up after the test.
594func createTempConfigFile(t *testing.T, content string) string {
595 t.Helper()
596 f, err := os.CreateTemp("", "config-*.yaml")
597 if err != nil {
598 t.Fatalf("failed to create temp config file: %v", err)
599 }
600 if _, err := f.WriteString(content); err != nil {
601 t.Fatalf("failed to write temp config file: %v", err)
602 }
603 if err := f.Close(); err != nil {
604 t.Fatalf("failed to close temp config file: %v", err)
605 }
606 t.Cleanup(func() { os.Remove(f.Name()) })
607 return f.Name()
608}

Calls 1

CloseMethod · 0.80

Tested by

no test coverage detected