Skip to content

Commit

Permalink
Add some renderer tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ascandella committed Nov 10, 2016
1 parent eacb256 commit 3a66964
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions render/godoc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,37 @@
// limitations under the License.

package render

import (
"bytes"
"testing"

"github.com/stretchr/testify/assert"
)

func TestDocumentHeader(t *testing.T) {
out := &bytes.Buffer{}
g := &GodocRenderer{
pkg: "fun",
}
g.DocumentHeader(out)
assert.Equal(t, out.String(), "/*\nPackage fun is the ")
}

func TestDocumentFooter(t *testing.T) {
out := &bytes.Buffer{}
g := &GodocRenderer{
pkg: "fun",
}
g.DocumentFooter(out)
assert.Equal(t, out.String(), "*/\npackage fun\n")
}

func TestBlockCode(t *testing.T) {
buff := &bytes.Buffer{}
code := []byte(`fmt.Println("Hello, world")`)
g := &GodocRenderer{}
g.blockCode(buff, code, "go")

assert.Equal(t, buff.String(), ` fmt.Println("Hello, world")`)
}

0 comments on commit 3a66964

Please sign in to comment.