-
Notifications
You must be signed in to change notification settings - Fork 2
/
generate_test.go
34 lines (30 loc) · 1.07 KB
/
generate_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
package docsgen_test
import (
"strings"
"testing"
"go.flow.arcalot.io/docsgen"
)
func TestGenerate_missingPlaceholder(t *testing.T) {
_, err := docsgen.Generate([]byte(""), emptyTestSchema)
if err == nil {
t.Fatalf("Generate with no placeholder should result in an error.")
}
}
func TestGenerate_emptySchema(t *testing.T) {
result, err := docsgen.Generate([]byte(
"<!-- Autogenerated documentation by arcaflow-docsgen --><!-- End of autogenerated documentation -->"),
emptyTestSchema,
)
if err != nil {
t.Fatalf("Generate with an empty schema should not result in an error.")
}
if !strings.Contains(string(result), "<!-- Autogenerated documentation by arcaflow-docsgen -->") {
t.Fatalf("The result does not contain the placeholder.")
}
if !strings.Contains(string(result), "<!-- End of autogenerated documentation -->") {
t.Fatalf("The result does not contain the placeholder.")
}
if len(result) <= len("<!-- Autogenerated documentation by arcaflow-docsgen --><!-- End of autogenerated documentation -->") {
t.Fatalf("The result does not contain any content.")
}
}