adder_test.gno
0.75 Kb ยท 44 lines
1package adder
2
3import (
4 "testing"
5)
6
7func TestRenderAndAdd(t *testing.T) {
8 // Initial Render output
9 output := Render("")
10 expected := `# Add Example
11
12Current Number: 0
13
14Last Updated: Never
15
16[Increase Number](/r/docs/adder$help&func=Add&n=42)
17`
18 if output != expected {
19 t.Errorf("Initial Render failed, got:\n%s", output)
20 }
21
22 // Call Add with a value of 10
23 Add(10)
24
25 // Call Add again with a value of -5
26 Add(-5)
27
28 // Render after two Add calls
29 finalOutput := Render("")
30
31 // Initial Render output
32 output = Render("")
33 expected = `# Add Example
34
35Current Number: 5
36
37Last Updated: 2009-02-13 23:31:30
38
39[Increase Number](/r/docs/adder$help&func=Add&n=42)
40`
41 if output != expected {
42 t.Errorf("Final Render failed, got:\n%s\nexpected:\n%s", output, finalOutput)
43 }
44}