Skip to content

Commit

Permalink
chore: update deps (#80)
Browse files Browse the repository at this point in the history
Signed-off-by: Tronje Krop <[email protected]>
  • Loading branch information
tkrop committed Aug 28, 2024
1 parent 1541b19 commit d225800
Show file tree
Hide file tree
Showing 14 changed files with 47 additions and 166 deletions.
2 changes: 2 additions & 0 deletions .codacy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@ engines:
- "**/*_test.go"
revive:
exclude_paths:
- "**/zz_generated.*.go"
- "**/mock_*_test.go"
- "**/mock_*.go"
2 changes: 1 addition & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.22.2
go-version: 1.23.0

- name: Build and tests
env:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.22.2
go-version: 1.23.0

- name: Release new version
env:
Expand All @@ -22,4 +22,4 @@ jobs:
env:
GH_TOKEN: ${{ github.token }}
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
run: make --trace version-publish || true
run: sleep 60 && make --trace version-publish || true
20 changes: 11 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,26 +1,28 @@
SHELL := /bin/bash

# Include custom variables to modify behavior.
ifneq ("$(wildcard Makefile.vars)","")
GITROOT ?= $(shell git rev-parse --show-toplevel 2>/dev/null || echo $(CURDIR))
ifneq ("$(wildcard $(GITROOT)/Makefile.vars)","")
include Makefile.vars
else
$(warning warning: please customize variables in Makefile.vars)
endif

# Setup default go compiler environment.
export GO ?= go
export GOPATH ?= $(shell $(GO) env GOPATH)
export GOBIN ?= $(GOPATH)/bin
# Setup go-make to utilize desired build and config scripts.
GOMAKE_DEP ?= github.com/tkrop/[email protected]

# Setup go-make version to use desired build and config scripts.
GOMAKE_DEP ?= github.com/tkrop/[email protected]
INSTALL_FLAGS ?= -mod=readonly -buildvcs=auto
# Request targets from go-make targets target.
TARGETS := $(shell command -v $(GOBIN)/go-make >/dev/null || \
$(GO) install $(GOMAKE_DEP) >/dev/stderr && \
$(GO) install $(INSTALL_FLAGS) $(GOMAKE_DEP) >/dev/stderr && \
$(GOBIN)/go-make show-targets 2>/dev/null)
# Declare all targets phony to make them available for auto-completion.
.PHONY:: $(TARGETS)

# Delegate all targets to go-make in a single call stubbing other targets.
$(eval $(wordlist 1,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS))::;@:)
$(firstword $(MAKECMDGOALS) all)::
# Delegate all targets to go-make in a single stubbing call.
GOAL := $(firstword $(MAKECMDGOALS) all)
$(eval $(MAKECMDGOALS)::;@:)
$(GOAL):: $(GOBIN)/go-make
@$(GOBIN)/go-make $(MAKECMDGOALS);
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.0.9
0.0.10
8 changes: 4 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
module github.com/tkrop/go-testing

go 1.22.2
go 1.23.0

require (
github.com/golang/mock v1.6.0
github.com/h2non/gock v1.2.0
github.com/huandu/go-clone v1.6.0
github.com/stretchr/testify v1.9.0
golang.org/x/exp v0.0.0-20240325151524-a685a6edb6d8
golang.org/x/text v0.13.0
golang.org/x/tools v0.19.0
golang.org/x/tools v0.24.0
)

require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/h2non/parth v0.0.0-20190131123155-b4df798d6542 // indirect
github.com/kr/pretty v0.3.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
golang.org/x/mod v0.16.0 // indirect
golang.org/x/mod v0.20.0 // indirect
golang.org/x/sync v0.8.0 // indirect
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
14 changes: 6 additions & 8 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,16 @@ github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/exp v0.0.0-20240325151524-a685a6edb6d8 h1:aAcj0Da7eBAtrTp03QXWvm88pSyOt+UgdZw2BFZ+lEw=
golang.org/x/exp v0.0.0-20240325151524-a685a6edb6d8/go.mod h1:CQ1k9gNrJ50XIzaKCRR2hssIjF07kZFEiieALBM/ARQ=
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.16.0 h1:QX4fJ0Rr5cPQCF7O9lh9Se4pmwfwskqZfq5moyldzic=
golang.org/x/mod v0.16.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
golang.org/x/mod v0.20.0 h1:utOm6MM3R3dnawAiJgn0y+xvuYRsm1RKM/4giyfDgV0=
golang.org/x/mod v0.20.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ=
golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ=
golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
Expand All @@ -58,8 +56,8 @@ golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
golang.org/x/tools v0.19.0 h1:tfGCXNR1OsFG+sVdLAitlpjAvD/I6dHDKnYrpEZUHkw=
golang.org/x/tools v0.19.0/go.mod h1:qoJWxmGSIBmAeriMx19ogtrEPrGtDbPK634QFIcLAhc=
golang.org/x/tools v0.24.0 h1:J1shsA93PJUEVaUSaay7UXAyE8aimq3GW0pjlolpa24=
golang.org/x/tools v0.24.0/go.mod h1:YhNqVBIfWHdzvTLs0d8LCuMhkKUgSUKldakyV7W/WDQ=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
Expand Down
4 changes: 2 additions & 2 deletions gock/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ services (gateways) by mocking the network communication using [`gock`][gock].

**Note:** Since the controller is focused on testing, it does not support the
same networking and observation features of [`gock`][gock] and requires manual
transport interception setup. However, the interface is mainly compatible with.
transport interception setup. However, the interface is mainly compatible.


## Example usage

Just create a new controller on each test, connect it to your HTTP clients or
client wrappers, and than use it to create HTTP mock request/response cycles
client wrappers, and then use it to create HTTP mock request/response cycles
as usual.


Expand Down
2 changes: 1 addition & 1 deletion gock/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func (s *MockStore) Match(req *http.Request) (gock.Mock, error) {
return mock, nil
}
}
return nil, nil
return nil, nil //nolint:nilnil // externally defined behavior
}

// IsDone returns true if all the registered HTTP request/response mocks have
Expand Down
30 changes: 0 additions & 30 deletions internal/math/math.go

This file was deleted.

90 changes: 0 additions & 90 deletions internal/math/math_test.go

This file was deleted.

25 changes: 12 additions & 13 deletions internal/reflect/reflect.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ import (
"fmt"
"reflect"
"unsafe"

"github.com/tkrop/go-testing/internal/math"
)

// Aliases for types.
Expand Down Expand Up @@ -79,8 +77,9 @@ func FieldArgOf(v reflect.Value, i int) any {

// Get the field value from the copy.
vf = vr.Field(i)
// #nosec G103 -- is necessary
rf := reflect.NewAt(vf.Type(), unsafe.Pointer(vf.UnsafeAddr())).Elem()
// #nosec G103 G115 -- is necessary.
rf := reflect.NewAt(vf.Type(),
unsafe.Pointer(vf.UnsafeAddr())).Elem()

var value any
reflect.ValueOf(&value).Elem().Set(rf)
Expand All @@ -93,27 +92,27 @@ func ArgOf(v reflect.Value) any {
return nil
}

switch v.Type().Kind() { //nolint:exhaustive // covered by default
switch v.Type().Kind() { //nolint:exhaustive // covered by default.
case reflect.Bool:
return v.Bool()
case reflect.Int:
return int(v.Int())
case reflect.Int8:
return int8(v.Int())
return int8(v.Int()) // #nosec G115 // checked by type switch.
case reflect.Int16:
return int16(v.Int())
return int16(v.Int()) // #nosec G115 // checked by type switch.
case reflect.Int32:
return int32(v.Int())
return int32(v.Int()) // #nosec G115 // checked by type switch.
case reflect.Int64:
return v.Int()
case reflect.Uint:
return uint(v.Uint())
case reflect.Uint8:
return uint8(v.Uint())
return uint8(v.Uint()) // #nosec G115 // checked by type switch.
case reflect.Uint16:
return uint16(v.Uint())
return uint16(v.Uint()) // #nosec G115 // checked by type switch.
case reflect.Uint32:
return uint32(v.Uint())
return uint32(v.Uint()) // #nosec G115 // checked by type switch.
case reflect.Uint64:
return v.Uint()
// TODO find test case.
Expand Down Expand Up @@ -280,12 +279,12 @@ func AnyFuncOf(args int, variadic bool) reflect.Type {
// arguments. Use `1` to remove the first argument, or `NumIn/NumOut` to remove
// all arguments.
func BaseFuncOf(mtype reflect.Type, in, out int) reflect.Type {
it := make([]reflect.Type, 0, math.Max(mtype.NumIn()-in, 0))
it := make([]reflect.Type, 0, max(mtype.NumIn()-in, 0))
for i := in; i < mtype.NumIn(); i++ {
it = append(it, mtype.In(i))
}

ot := make([]reflect.Type, 0, math.Max(mtype.NumOut()-out, 0))
ot := make([]reflect.Type, 0, max(mtype.NumOut()-out, 0))
for i := out; i < mtype.NumOut(); i++ {
ot = append(ot, mtype.Out(i))
}
Expand Down
File renamed without changes.
10 changes: 5 additions & 5 deletions mock/mock_test.go → mock/mocks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (

//revive:disable:line-length-limit // go:generate line length

//go:generate mockgen -package=mock_test -destination=mock_iface_test.go -source=mock_test.go IFace,XFace
//go:generate mockgen -package=mock_test -destination=mock_iface_test.go -source=mocks_test.go IFace,XFace

//revive:enable:line-length-limit

Expand Down Expand Up @@ -82,7 +82,7 @@ var (
}()
// CallerCallA provides the file with the line number of the `CallA` call
// in mock.
CallerCallA = path.Join(SourceDir, "mock/mock_test.go:35")
CallerCallA = path.Join(SourceDir, "mock/mocks_test.go:35")
)

type MockParams struct {
Expand Down Expand Up @@ -120,7 +120,7 @@ var testMockParams = map[string]MockParams{
},
"single mock with unexpected call": {
failSetup: test.UnexpectedCall(NewMockIFace,
"CallA", path.Join(SourceDir, "mock_test.go:125"), "ok"),
"CallA", path.Join(SourceDir, "mocks_test.go:125"), "ok"),
call: func(_ test.Test, mocks *mock.Mocks) {
mock.Get(mocks, NewMockIFace).CallA("ok")
},
Expand All @@ -130,8 +130,8 @@ var testMockParams = map[string]MockParams{
CallA("ok"),
),
failSetup: test.ConsumedCall(NewMockIFace,
"CallA", path.Join(SourceDir, "mock_test.go:137"),
path.Join(SourceDir, "mock_test.go:37"), "ok"),
"CallA", path.Join(SourceDir, "mocks_test.go:137"),
path.Join(SourceDir, "mocks_test.go:37"), "ok"),
call: func(_ test.Test, mocks *mock.Mocks) {
mock.Get(mocks, NewMockIFace).CallA("ok")
mock.Get(mocks, NewMockIFace).CallA("ok")
Expand Down

0 comments on commit d225800

Please sign in to comment.