From 4c04177c05355ddb92d3d31a4c5cfbaa86555a13 Mon Sep 17 00:00:00 2001 From: Brian Picciano Date: Sat, 14 May 2022 16:14:11 -0600 Subject: Move template rendering logic into api package --- srv/src/post/renderer_test.go | 92 ------------------------------------------- 1 file changed, 92 deletions(-) delete mode 100644 srv/src/post/renderer_test.go (limited to 'srv/src/post/renderer_test.go') diff --git a/srv/src/post/renderer_test.go b/srv/src/post/renderer_test.go deleted file mode 100644 index 5c01cd2..0000000 --- a/srv/src/post/renderer_test.go +++ /dev/null @@ -1,92 +0,0 @@ -package post - -import ( - "bytes" - "strconv" - "strings" - "testing" - "time" - - "github.com/stretchr/testify/assert" -) - -func TestMarkdownBodyToHTML(t *testing.T) { - - tests := []struct { - body string - exp string - }{ - { - body: ` -# Foo -`, - exp: `

Foo

`, - }, - { - body: ` -this is a body - -this is another -`, - exp: ` -

this is a body

- -

this is another

`, - }, - { - body: `this is a [link](somewhere.html)`, - exp: `

this is a link

`, - }, - } - - for i, test := range tests { - t.Run(strconv.Itoa(i), func(t *testing.T) { - - outB := mdBodyToHTML([]byte(test.body)) - out := string(outB) - - // just to make the tests nicer - out = strings.TrimSpace(out) - test.exp = strings.TrimSpace(test.exp) - - assert.Equal(t, test.exp, out) - }) - } -} - -func TestMarkdownToHTMLRenderer(t *testing.T) { - - r := NewMarkdownToHTMLRenderer() - - post := RenderablePost{ - StoredPost: StoredPost{ - Post: Post{ - ID: "foo", - Title: "Foo", - Description: "Bar.", - Body: "This is the body.", - Series: "baz", - }, - PublishedAt: time.Now(), - }, - - SeriesPrevious: &StoredPost{ - Post: Post{ - ID: "foo-prev", - Title: "Foo Prev", - }, - }, - - SeriesNext: &StoredPost{ - Post: Post{ - ID: "foo-next", - Title: "Foo Next", - }, - }, - } - - buf := new(bytes.Buffer) - err := r.Render(buf, post) - assert.NoError(t, err) - t.Log(buf.String()) -} -- cgit v1.2.3