package web import ( "errors" "net/http" "strings" "testing" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "sourcecraft.dev/bigbes/sr-ht-dolt/browse" "sourcecraft.dev/bigbes/sr-ht-dolt/core" ) // --- the rendering itself ------------------------------------------------------ // // These render with no index at all — the nil receiver, which is what a page // gets when the database listing failed. Everything asserted here is therefore // about the markdown and about what is allowed to reach the browser, not about // the links. // renderMemory is one memory body, rendered by a memoryLinks that knows no // database. func renderMemory(src string) string { var noLinks *memoryLinks return string(noLinks.Body(src)) } // The shapes the memories are actually written in: a bold leader, code spans, a // bullet list, a fenced recipe, and hard-wrapped prose that reflows into one // paragraph rather than keeping the width its author's terminal had. func TestMemoryBodyRendersMarkdown(t *testing.T) { got := renderMemory("**Why:** the networks are declared `external: true` everywhere,\n" + "and compose cannot create one.\n" + "\n" + "- first, `./prepare.sh`\n" + "- then `labng push backup`\n" + "\n" + "```\n" + "dolt clone https://dolt.srht.bigb.es/~bigbes/x\n" + "```\n") assert.Contains(t, got, "Why:") assert.Contains(t, got, "external: true") assert.Contains(t, got, "