@marcel91200 / caddy Mirror · read-only / commits / 9ea31083
Fork 0

Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS

Mirrored from https://github.com/Slazee/caddy.git

Synced Nov 10, 23:45 UTC

testing: remove temp file + stylistic edits (#8389)

Signed-off-by: Mohammed Al Sahaf <msaa1990@gmail.com>

Mohammed Al Sahaf committed Nov 9, 2026 at 06:29 UTC 9ea3108377d2abec102866808133c40ac9582162
1 file changed +15 -4
caddyconfig/caddyfile/parse_test.go
+15 -4
@@ -319,8 +319,12 @@ func TestParseOneAndImport(t *testing.T) {
319 dir1 "{}"`, false, []string{"localhost"}, []int{2}},
320
321 // quoted braces are literal arguments: they must not open/close blocks or swallow directives
322 - {"localhost {\n dir1 \"{\" `}`\n dir2 \"}\"\n dir3 \"{\"\n}",
323 - false, []string{"localhost"}, []int{3, 2, 2}},
322 + {
323 + "localhost {\n dir1 \"{\" `}`\n dir2 \"}\"\n dir3 \"{\"\n}",
324 + false,
325 + []string{"localhost"},
326 + []int{3, 2, 2},
327 + },
328
329 // quoted "{" as the last argument before a real block
330 {`localhost {
@@ -422,7 +426,8 @@ func TestRecursiveImport(t *testing.T) {
426 err = os.WriteFile(recursiveFile1, []byte(
427 `localhost
428 dir1
425 - import recursive_import_test2`), 0o644)
429 + import recursive_import_test2`,
430 + ), 0o644)
431 if err != nil {
432 t.Fatal(err)
433 }
@@ -456,7 +461,8 @@ func TestRecursiveImport(t *testing.T) {
461 err = os.WriteFile(recursiveFile1, []byte(
462 `localhost
463 dir1
459 - import `+recursiveFile2), 0o644)
464 + import `+recursiveFile2,
465 + ), 0o644)
466 if err != nil {
467 t.Fatal(err)
468 }
@@ -977,6 +983,11 @@ func writeStringToTempFileOrDie(t *testing.T, str string) (pathToFile string) {
983 if err != nil {
984 panic(err) // get a stack trace so we know where this was called from.
985 }
986 + t.Cleanup(func() {
987 + if err := os.Remove(file.Name()); err != nil {
988 + t.Logf("Failed to remove temp file %s: %v", file.Name(), err)
989 + }
990 + })
991 if _, err := file.WriteString(str); err != nil {
992 panic(err)
993 }