Skip to content

Commit 8998542

Browse files
committed
Add unit test
1 parent e85ae5d commit 8998542

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

runner/loop_test.go

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package runner_test
2+
3+
import (
4+
"bytes"
5+
"testing"
6+
7+
"github.com/devlights/try-golang/mapping"
8+
"github.com/devlights/try-golang/runner"
9+
)
10+
11+
func TestLoop(t *testing.T) {
12+
r := new(runner.SilentRegister)
13+
14+
m := mapping.NewSampleMapping()
15+
m.MakeMapping(r)
16+
17+
buf := new(bytes.Buffer)
18+
buf.WriteString("silent\n")
19+
20+
a := runner.NewLoopArgs(buf, true, m)
21+
e := runner.NewLoop(a)
22+
23+
if err := e.Run(); err != nil {
24+
t.Errorf("should not raise error (%s)", err)
25+
}
26+
27+
if !r.Target.Called {
28+
t.Errorf("never called the target example")
29+
}
30+
}

0 commit comments

Comments
 (0)