Skip to content

Commit

Permalink
chore: gofumpt -w . (#202)
Browse files Browse the repository at this point in the history
Signed-off-by: Sasha Melentyev <[email protected]>
  • Loading branch information
sashamelentyev committed Sep 11, 2024
1 parent 70a5e8c commit 60372e3
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 23 deletions.
6 changes: 4 additions & 2 deletions gomock/call.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,10 @@ func newCall(t TestHelper, receiver any, method string, methodType reflect.Type,
}
return rets
}}
return &Call{t: t, receiver: receiver, method: method, methodType: methodType,
args: mArgs, origin: origin, minCalls: 1, maxCalls: 1, actions: actions}
return &Call{
t: t, receiver: receiver, method: method, methodType: methodType,
args: mArgs, origin: origin, minCalls: 1, maxCalls: 1, actions: actions,
}
}

// AnyTimes allows the expectation to be called 0 or more times
Expand Down
2 changes: 2 additions & 0 deletions gomock/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ type cancelReporter struct {
func (r *cancelReporter) Errorf(format string, args ...any) {
r.t.Errorf(format, args...)
}

func (r *cancelReporter) Fatalf(format string, args ...any) {
defer r.cancel()
r.t.Fatalf(format, args...)
Expand Down Expand Up @@ -156,6 +157,7 @@ type nopTestHelper struct {
func (h *nopTestHelper) Errorf(format string, args ...any) {
h.t.Errorf(format, args...)
}

func (h *nopTestHelper) Fatalf(format string, args ...any) {
h.t.Fatalf(format, args...)
}
Expand Down
8 changes: 4 additions & 4 deletions gomock/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -563,8 +563,8 @@ func TestSetArgSlice(t *testing.T) {
_, ctrl := createFixtures(t)
subject := new(Subject)

var in = []byte{4, 5, 6}
var set = []byte{1, 2, 3}
in := []byte{4, 5, 6}
set := []byte{1, 2, 3}
ctrl.RecordCall(subject, "SetArgMethod", in, nil, nil).SetArg(0, set)
ctrl.Call(subject, "SetArgMethod", in, nil, nil)

Expand All @@ -584,8 +584,8 @@ func TestSetArgMap(t *testing.T) {
_, ctrl := createFixtures(t)
subject := new(Subject)

var in = map[any]any{"int": 1, "string": "random string", 1: "1", 0: 0}
var set = map[any]any{"int": 2, 1: "2", 2: 100}
in := map[any]any{"int": 1, "string": "random string", 1: "1", 0: 0}
set := map[any]any{"int": 2, 1: "2", 2: 100}
ctrl.RecordCall(subject, "SetArgMethod", nil, nil, in).SetArg(2, set)
ctrl.Call(subject, "SetArgMethod", nil, nil, in)

Expand Down
28 changes: 18 additions & 10 deletions gomock/matchers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,12 @@ import (
"go.uber.org/mock/gomock/internal/mock_gomock"
)

type A []string
type B struct {
Name string
}
type (
A []string
B struct {
Name string
}
)

func TestMatchers(t *testing.T) {
type e any
Expand All @@ -39,21 +41,27 @@ func TestMatchers(t *testing.T) {
yes, no []e
}{
{"test Any", gomock.Any(), []e{3, nil, "foo"}, nil},
{"test AnyOf", gomock.AnyOf(gomock.Nil(), gomock.Len(2), 1, 2, 3),
{
"test AnyOf", gomock.AnyOf(gomock.Nil(), gomock.Len(2), 1, 2, 3),
[]e{nil, "hi", "to", 1, 2, 3},
[]e{"s", "", 0, 4, 10}},
[]e{"s", "", 0, 4, 10},
},
{"test All", gomock.Eq(4), []e{4}, []e{3, "blah", nil, int64(4)}},
{"test Nil", gomock.Nil(),
{
"test Nil", gomock.Nil(),
[]e{nil, (error)(nil), (chan bool)(nil), (*int)(nil)},
[]e{"", 0, make(chan bool), errors.New("err"), new(int)}},
[]e{"", 0, make(chan bool), errors.New("err"), new(int)},
},
{"test Not", gomock.Not(gomock.Eq(4)), []e{3, "blah", nil, int64(4)}, []e{4}},
{"test Regex", gomock.Regex("[0-9]{2}:[0-9]{2}"), []e{"23:02", "[23:02]: Hello world", []byte("23:02")}, []e{4, "23-02", "hello world", true, []byte("23-02")}},
{"test All", gomock.All(gomock.Any(), gomock.Eq(4)), []e{4}, []e{3, "blah", nil, int64(4)}},
{"test Len", gomock.Len(2),
{
"test Len", gomock.Len(2),
[]e{[]int{1, 2}, "ab", map[string]int{"a": 0, "b": 1}, [2]string{"a", "b"}},
[]e{[]int{1}, "a", 42, 42.0, false, [1]string{"a"}},
},
{"test assignable types", gomock.Eq(A{"a", "b"}),
{
"test assignable types", gomock.Eq(A{"a", "b"}),
[]e{[]string{"a", "b"}, A{"a", "b"}},
[]e{[]string{"a"}, A{"b"}},
},
Expand Down
2 changes: 1 addition & 1 deletion mockgen/internal/tests/sanitization/any/any.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ package any

// Any is a type of a package that tests the sanitization of imported packages
// named any.
type Any struct {}
type Any struct{}
1 change: 0 additions & 1 deletion mockgen/model/model_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ func TestImpPath(t *testing.T) {
nonVendor := "github.com/foo/bar"
if nonVendor != impPath(nonVendor) {
t.Errorf("")

}
testCases := []struct {
input string
Expand Down
4 changes: 2 additions & 2 deletions mockgen/reflect.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,13 +142,13 @@ func runInDir(program []byte, dir string) (*model.Package, error) {
}
}()
const progSource = "prog.go"
var progBinary = "prog.bin"
progBinary := "prog.bin"
if runtime.GOOS == "windows" {
// Windows won't execute a program unless it has a ".exe" suffix.
progBinary += ".exe"
}

if err := os.WriteFile(filepath.Join(tmpDir, progSource), program, 0600); err != nil {
if err := os.WriteFile(filepath.Join(tmpDir, progSource), program, 0o600); err != nil {
return nil, err
}

Expand Down
6 changes: 3 additions & 3 deletions sample/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ package user

// Random bunch of imports to test mockgen.
import (
"io"

btz "bytes"
"hash"
"io"
"log"
"net"
"net/http"

btz "bytes"

// Two imports with the same base name.
t1 "html/template"

Expand Down

0 comments on commit 60372e3

Please sign in to comment.