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)
| 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. |
| 594 | func 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 | } |
no test coverage detected