diff options
author | Brian Picciano <mediocregopher@gmail.com> | 2023-01-19 16:02:27 +0100 |
---|---|---|
committer | Brian Picciano <mediocregopher@gmail.com> | 2023-01-19 16:02:27 +0100 |
commit | c23030733fe4cba578b14ad2c1d1292891202562 (patch) | |
tree | 05e200767b1a99e686dfcd18455e08fa977ebb56 /src/gmi/gemtext_test.go | |
parent | e7b5b55f6718b25a437a891a06a26c21384b6818 (diff) |
Add support for gemtext posts
Diffstat (limited to 'src/gmi/gemtext_test.go')
-rw-r--r-- | src/gmi/gemtext_test.go | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/src/gmi/gemtext_test.go b/src/gmi/gemtext_test.go new file mode 100644 index 0000000..23cb97f --- /dev/null +++ b/src/gmi/gemtext_test.go @@ -0,0 +1,51 @@ +package gmi + +import ( + "bytes" + "strconv" + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestGemtextToMarkdown(t *testing.T) { + + 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", + }, + } + + 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)) + assert.NoError(t, err) + assert.Equal(t, test.exp, got.String()) + }) + } +} |