-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathwrite_markdown_test.go
47 lines (37 loc) · 967 Bytes
/
write_markdown_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package main
import (
"bytes"
"testing"
)
func TestWriteMarkdown(t *testing.T) {
expected := `Network policy viewer
=====================
|**Field** |**Value**|
|:--------------------------|:--------|
|percentageIsolated |20 |
|percentageNamespaceCoverage|30 |
`
var buffer bytes.Buffer
writeMarkdown(20, 30, &buffer)
s := buffer.String()
if s != expected {
t.Errorf("Markdown output faulty\nExpected:\n%s\nGot:\n%s\n", expected, s)
}
}
func TestMarkdownHeading(t *testing.T) {
expectedH1 := `Foobar
======
`
expectedH3 := `### Foobar
`
var bufferH1 bytes.Buffer
heading("Foobar", 1, &bufferH1)
if bufferH1.String() != expectedH1 {
t.Errorf("Markdown heading faulty\nExpected:\n%s\nGot:\n%s\n", expectedH1, bufferH1.String())
}
var bufferH3 bytes.Buffer
heading("Foobar", 3, &bufferH3)
if bufferH3.String() != expectedH3 {
t.Errorf("Expected:\n%s\nGot:\n%s\n", expectedH3, bufferH3.String())
}
}