MCPcopy
hub / github.com/caddyserver/caddy / writeStringToTempFileOrDie

Function writeStringToTempFileOrDie

caddyconfig/caddyfile/parse_test.go:793–805  ·  view source on GitHub ↗
(t *testing.T, str string)

Source from the content-addressed store, hash-verified

791}
792
793func writeStringToTempFileOrDie(t *testing.T, str string) (pathToFile string) {
794 file, err := os.CreateTemp("", t.Name())
795 if err != nil {
796 panic(err) // get a stack trace so we know where this was called from.
797 }
798 if _, err := file.WriteString(str); err != nil {
799 panic(err)
800 }
801 if err := file.Close(); err != nil {
802 panic(err)
803 }
804 return file.Name()
805}
806
807func TestImportedFilesIgnoreNonDirectiveImportTokens(t *testing.T) {
808 fileName := writeStringToTempFileOrDie(t, `

Calls 2

NameMethod · 0.45
CloseMethod · 0.45

Tested by

no test coverage detected