diff options
author | Brian Picciano <mediocregopher@gmail.com> | 2024-05-17 23:37:43 +0200 |
---|---|---|
committer | Brian Picciano <mediocregopher@gmail.com> | 2024-05-18 14:47:09 +0200 |
commit | 8d7e708d98a3a46ba3ba08f9c8deeb4838bb8ca5 (patch) | |
tree | 6662c3e4c6c3baaea058a3deaba0d9cfc8e9cc40 /src/gmi/gemtext_test.go | |
parent | fac06df97a47cda6e8989bfc5f40f2a627279b92 (diff) |
Render posts completely using common rendering methods
The aim is to reduce reliance on custom logic in the handlers for every
protocol, eventually outsourcing all of it into `render.Methods`,
leaving each protocol to simply direct calls to the correct template.
Diffstat (limited to 'src/gmi/gemtext_test.go')
-rw-r--r-- | src/gmi/gemtext_test.go | 66 |
1 files changed, 0 insertions, 66 deletions
diff --git a/src/gmi/gemtext_test.go b/src/gmi/gemtext_test.go deleted file mode 100644 index 75da9df..0000000 --- a/src/gmi/gemtext_test.go +++ /dev/null @@ -1,66 +0,0 @@ -package gmi - -import ( - "bytes" - "net/url" - "strconv" - "testing" - - "github.com/stretchr/testify/assert" -) - -func TestGemtextToMarkdown(t *testing.T) { - - gmiGateway, _ := url.Parse("https://gateway.com/x/") - - tests := []struct { - in, exp string - }{ - { - in: "", - exp: "", - }, - { - in: "=> foo", - exp: "[Link](foo)\n", - }, - { - in: "what\n=> foo\n=> bar", - exp: "what\n[Link](foo)\n[Link](bar)\n", - }, - { - in: "=> foo description is here ", - exp: "[description is here](foo)\n", - }, - { - in: "=> img.png", - exp: "![Image](img.png)\n", - }, - { - in: "=> img.png description is here ", - exp: "![description is here](img.png)\n", - }, - { - in: "=> gemini://somewhere.com/foo Somewhere", - exp: "[Somewhere](https://gateway.com/x/somewhere.com/foo)\n", - }, - { - in: "=> gemini://somewhere.com:420/foo Somewhere", - exp: "[Somewhere](https://gateway.com/x/somewhere.com:420/foo)\n", - }, - { - in: "=> gemini://somewhere.com:420/foo?bar=baz Somewhere", - exp: "[Somewhere](https://gateway.com/x/somewhere.com:420/foo?bar=baz)\n", - }, - } - - for i, test := range tests { - t.Run(strconv.Itoa(i), func(t *testing.T) { - - got := new(bytes.Buffer) - err := GemtextToMarkdown(got, bytes.NewBufferString(test.in), gmiGateway) - assert.NoError(t, err) - assert.Equal(t, test.exp, got.String()) - }) - } -} |