Skip to content

Commit ac9ea68

Browse files
author
Corin Lawson
committed
test: introduce basic tests for i/cmd/vermockgen
Prior to this change, there were no test files for the package: github.com/Versent/go-vermock/internal/cmd/vermockgen. This change introduces limited tests for SetFlags and Execute methods.
1 parent 81a63ae commit ac9ea68

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package vermockgen_test
2+
3+
import (
4+
"bytes"
5+
"flag"
6+
"log"
7+
"testing"
8+
9+
vermockgen "github.com/Versent/go-vermock/internal/cmd/vermockgen"
10+
)
11+
12+
func TestSetFlags(t *testing.T) {
13+
f := flag.NewFlagSet("vermockgen", flag.ContinueOnError)
14+
vermockgen.NewGenCmd(nil, f)
15+
expected := []string{"header", "tags"}
16+
f.VisitAll(func(f *flag.Flag) {
17+
if len(expected) == 0 {
18+
t.Errorf("unexpected flag %q", f.Name)
19+
return
20+
}
21+
22+
var got, want string
23+
got, want, expected = f.Name, expected[0], expected[1:]
24+
if got != want {
25+
t.Errorf("unexpected name, got %q, want %q", got, want)
26+
}
27+
})
28+
}
29+
30+
func TestExecute(t *testing.T) {
31+
var buf bytes.Buffer
32+
l := log.New(&buf, "", 0)
33+
f := flag.NewFlagSet("vermockgen", flag.ContinueOnError)
34+
vermockgen.NewGenCmd(l, f)
35+
36+
}

0 commit comments

Comments
 (0)