Skip to content

Commit

Permalink
test: introduce basic tests for i/cmd/vermockgen
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
au-phiware committed Mar 22, 2024
1 parent 81a63ae commit ac9ea68
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions internal/cmd/vermockgen/gen_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package vermockgen_test

import (
"bytes"
"flag"
"log"
"testing"

vermockgen "github.com/Versent/go-vermock/internal/cmd/vermockgen"
)

func TestSetFlags(t *testing.T) {
f := flag.NewFlagSet("vermockgen", flag.ContinueOnError)
vermockgen.NewGenCmd(nil, f)
expected := []string{"header", "tags"}
f.VisitAll(func(f *flag.Flag) {
if len(expected) == 0 {
t.Errorf("unexpected flag %q", f.Name)
return
}

var got, want string
got, want, expected = f.Name, expected[0], expected[1:]
if got != want {
t.Errorf("unexpected name, got %q, want %q", got, want)
}
})
}

func TestExecute(t *testing.T) {
var buf bytes.Buffer
l := log.New(&buf, "", 0)
f := flag.NewFlagSet("vermockgen", flag.ContinueOnError)
vermockgen.NewGenCmd(l, f)

}

0 comments on commit ac9ea68

Please sign in to comment.