MCPcopy
hub / github.com/tdewolff/minify / TestMinifyErrorPropagation

Function TestMinifyErrorPropagation

html/html_test.go:528–555  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

526}
527
528func TestMinifyErrorPropagation(t *testing.T) {
529 errorTests := []struct {
530 html string
531 err string
532 }{
533 {"line\n<script><</script>", "unexpected < in expression on line 2 and column 9"},
534 {"line\n<script> <</script>", "unexpected < in expression on line 2 and column 10"},
535 {"<div onclick='<'>", "unexpected < in expression on line 1 and column 15"},
536 }
537
538 m := minify.New()
539 m.AddFunc("application/javascript", js.Minify)
540 for _, tt := range errorTests {
541 t.Run(tt.html, func(t *testing.T) {
542 r := bytes.NewBufferString(tt.html)
543 w := &bytes.Buffer{}
544 err := Minify(m, w, r, nil)
545 if err == nil {
546 test.Fail(t)
547 }
548 errMessage := err.Error()
549 if i := strings.IndexByte(errMessage, '\n'); i != -1 {
550 errMessage = errMessage[:i]
551 }
552 test.String(t, errMessage, tt.err)
553 })
554 }
555}
556
557////////////////////////////////////////////////////////////////
558

Callers

nothing calls this directly

Calls 4

AddFuncMethod · 0.80
RunMethod · 0.80
MinifyFunction · 0.70
StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…