From 1615c6869fe1a2af38ad8e445c79ca9388a7d741 Mon Sep 17 00:00:00 2001 From: nkanaev Date: Tue, 4 Mar 2025 13:14:54 +0000 Subject: [PATCH] fix tests --- src/content/sanitizer/sanitizer_test.go | 57 +++++++++++++------------ 1 file changed, 29 insertions(+), 28 deletions(-) diff --git a/src/content/sanitizer/sanitizer_test.go b/src/content/sanitizer/sanitizer_test.go index 8f49f05..53ffb3d 100644 --- a/src/content/sanitizer/sanitizer_test.go +++ b/src/content/sanitizer/sanitizer_test.go @@ -8,10 +8,11 @@ import "testing" func TestValidInput(t *testing.T) { input := `

This is a text with an image: Test.

` - output := Sanitize("http://example.org/", input) + want := `

This is a text with an image: Test.

` + have := Sanitize("http://example.org/", input) - if input != output { - t.Errorf(`Wrong output: "%s" != "%s"`, input, output) + if have != want { + t.Errorf("Wrong output: \nwant: %#v\nhave: %#v", want, have) } } @@ -27,31 +28,31 @@ func TestImgWithTextDataURL(t *testing.T) { func TestImgWithDataURL(t *testing.T) { input := `Example` - expected := `Example` - output := Sanitize("http://example.org/", input) + want := `Example` + have := Sanitize("http://example.org/", input) - if output != expected { - t.Errorf(`Wrong output: %s`, output) + if have != want { + t.Errorf("Wrong output:\nwant: %s\nhave: %s", want, have) } } func TestImgWithSrcset(t *testing.T) { input := `Example` - expected := `Example` - output := Sanitize("http://example.org/", input) + want := `Example` + have := Sanitize("http://example.org/", input) - if output != expected { - t.Errorf(`Wrong output: %s`, output) + if have != want { + t.Errorf("Wrong output:\nwant: %s\nhave: %s", want, have) } } func TestImgWithSrcsetAndDataURL(t *testing.T) { input := `Example` - expected := `Example` - output := Sanitize("http://example.org/", input) + want := `Example` + have := Sanitize("http://example.org/", input) - if output != expected { - t.Errorf(`Wrong output: %s`, output) + if have != want { + t.Errorf("Wrong output:\nwant: %s\nhave: %s", want, have) } } @@ -67,16 +68,16 @@ func TestSourceWithSrcsetAndMedia(t *testing.T) { func TestMediumImgWithSrcset(t *testing.T) { input := `Image for post` - expected := `Image for post` - output := Sanitize("http://example.org/", input) + want := `Image for post` + have := Sanitize("http://example.org/", input) - if output != expected { - t.Errorf(`Wrong output: %s`, output) + if have != want { + t.Errorf("Wrong output:\nwant: %s\nhave: %s", want, have) } } func TestSelfClosingTags(t *testing.T) { - input := `

This
is a text
with an image: Test.

` + input := `

This
is a text
.

` output := Sanitize("http://example.org/", input) if input != output { @@ -95,11 +96,11 @@ func TestTable(t *testing.T) { func TestRelativeURL(t *testing.T) { input := `This link is relative and this image: ` - expected := `This link is relative and this image: ` - output := Sanitize("http://example.org/", input) + want := `This link is relative and this image: ` + have := Sanitize("http://example.org/", input) - if expected != output { - t.Errorf(`Wrong output: "%s" != "%s"`, expected, output) + if want != have { + t.Errorf("Wrong output:\nwant: %s\nhave: %s", want, have) } } @@ -165,11 +166,11 @@ func TestInvalidNestedTag(t *testing.T) { func TestValidIFrame(t *testing.T) { input := `` - expected := `` - output := Sanitize("http://example.org/", input) + want := `` + have := Sanitize("http://example.org/", input) - if expected != output { - t.Errorf("Wrong output:\nwant: %s\nhave: %s", expected, output) + if want != have { + t.Errorf("Wrong output:\nwant: %s\nhave: %s", want, have) } }