diff options
Diffstat (limited to 'internal/web/web_test.go')
| -rw-r--r-- | internal/web/web_test.go | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/internal/web/web_test.go b/internal/web/web_test.go index 6e53bae..6c8072e 100644 --- a/internal/web/web_test.go +++ b/internal/web/web_test.go @@ -7,7 +7,9 @@ import ( "strings" "testing" + "github.com/google/uuid" "github.com/gramanas/blogspace/internal/config" + "github.com/gramanas/blogspace/internal/store" ) func TestHostname(t *testing.T) { @@ -104,3 +106,17 @@ func TestSubdomainWebadminRedirect(t *testing.T) { t.Errorf("got %d %q, want 303 %q", rec.Code, rec.Header().Get("Location"), want) } } + +func TestAppendImageMD(t *testing.T) { + img := &store.Image{ID: uuid.MustParse("6ba7b810-9dad-11d1-80b4-00c04fd430c8"), Filename: "cat].png"} + line := "" + if got := appendImageMD("", img); got != line+"\n" { + t.Errorf("empty body: %q", got) + } + if got := appendImageMD("hello\n", img); got != "hello\n\n"+line+"\n" { + t.Errorf("with body: %q", got) + } + if got := appendImageMD("hello", nil); got != "hello" { + t.Errorf("nil image should not change the body: %q", got) + } +} |
