Skip to content

Commit

Permalink
Merge branch 'matryer:main' into update-deps
Browse files Browse the repository at this point in the history
  • Loading branch information
arkadiuszos4chain authored Aug 22, 2024
2 parents db64c7b + 8bc5adb commit 1d3ef20
Show file tree
Hide file tree
Showing 30 changed files with 78 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.19
go-version: 1.22
cache: true
check-latest: true

Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
go-version: [1.18.x, 1.19.x]
go-version: [oldstable, stable]
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#example-expanding-configurations
include:
- os: windows-latest
go-version: 1.19.x
go-version: stable
- os: macos-latest
go-version: 1.19.x
go-version: stable

steps:
- name: Checkout code
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ The mocked structure implements the interface, where each method calls the assoc
* Name arguments in the interface for a better experience
* Use closured variables inside your test function to capture details about the calls to the methods
* Use `.MethodCalls()` to track the calls
* Use `.ResetCalls()` to reset calls within an invidual mock's context
* Use `.ResetCalls()` to reset calls within an individual mock's context
* Use `go:generate` to invoke the `moq` command
* If Moq fails with a `go/format` error, it indicates the generated code was not valid.
You can run the same command with `-fmt noop` to print the generated source code without attempting to format it.
Expand Down
1 change: 1 addition & 0 deletions internal/template/template_data.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ func (m MethodData) ReturnArgNameList() string {
return strings.Join(params, ", ")
}

// TypeParamData extends ParamData with a constraint.
type TypeParamData struct {
ParamData
Constraint types.Type
Expand Down
1 change: 1 addition & 0 deletions pkg/moq/testpackages/anonimport/iface.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
)

// Example is a test interface.
type Example interface {
Ctx(ctx context.Context)
}
2 changes: 1 addition & 1 deletion pkg/moq/testpackages/anonimport/second_file.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package anonimport

import (
_ "context"
_ "context" // import for side effects
)
1 change: 1 addition & 0 deletions pkg/moq/testpackages/blankid/swallower.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package blankid

// Swallower is a test interface.
type Swallower interface {
Swallow(_ string)
}
2 changes: 2 additions & 0 deletions pkg/moq/testpackages/genericreturn/genericreturn.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ package genericreturn

import "github.com/matryer/moq/pkg/moq/testpackages/genericreturn/otherpackage"

// GenericBar is a test type.
type GenericBar[T any] struct {
Bar T
}

// IFooBar is a test interface.
type IFooBar interface {
Foobar() GenericBar[otherpackage.Foo]
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package otherpackage

// Foo is a test struct.
type Foo struct {
A int
B string
Expand Down
6 changes: 6 additions & 0 deletions pkg/moq/testpackages/generics/generics.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,32 @@ import (
"fmt"
)

// GenericStore1 is a test interface.
type GenericStore1[T Key1, S any] interface {
Get(ctx context.Context, id T) (S, error)
Create(ctx context.Context, id T, value S) error
}

// GenericStore2 is a test interface.
type GenericStore2[T Key2, S any] interface {
Get(ctx context.Context, id T) (S, error)
Create(ctx context.Context, id T, value S) error
}

// AliasStore is a test interface.
type AliasStore GenericStore1[KeyImpl, bool]

// Key1 is a test interface.
type Key1 interface {
fmt.Stringer
}

// Key2 is a test interface.
type Key2 interface {
~[]byte | string
}

// KeyImpl is a test type.
type KeyImpl []byte

func (x KeyImpl) String() string {
Expand Down
5 changes: 4 additions & 1 deletion pkg/moq/testpackages/genparamname/iface.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,13 @@ import (
)

type (
Go func()
// Go is a test function.
Go func()

myType struct{}
)

// Interface is a test interface.
type Interface interface {
Method(
*myType,
Expand Down
1 change: 1 addition & 0 deletions pkg/moq/testpackages/importalias/middleman.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
tgtclient "github.com/matryer/moq/pkg/moq/testpackages/importalias/target/client"
)

// MiddleMan is a test interface.
type MiddleMan interface {
Connect(src srcclient.Client, tgt tgtclient.Client)
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
package client

// Client is a test struct.
type Client struct{}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
package client

// Client is a test struct.
type Client struct{}
1 change: 1 addition & 0 deletions pkg/moq/testpackages/paramconflict/iface.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package paramconflict

import "time"

// Interface is a test interface.
type Interface interface {
Method(string, bool, string, bool, int, int32, int64, float32, float64, time.Time, time.Time)
}
1 change: 1 addition & 0 deletions pkg/moq/testpackages/shadow/http/thing.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package http

import "net/http"

// Thing is a test interface.
type Thing interface {
Blah(w http.ResponseWriter, r *http.Request)
}
20 changes: 20 additions & 0 deletions pkg/moq/testpackages/shadowtypes/shadowtypes.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,52 @@ import (
"github.com/matryer/moq/pkg/moq/testpackages/shadowtypes/types"
)

// ShadowTypes is a test interface.
type ShadowTypes interface {
// ShadowString is a test method.
ShadowString(string, types.String)

// ShadowInt is a test method.
ShadowInt(int, types.Int)
// ShadowInt8 is a test method.
ShadowInt8(int8, types.Int8)
// ShadowInt16 is a test method.
ShadowInt16(int16, types.Int16)
// ShadowInt32 is a test method.
ShadowInt32(int32, types.Int32)
// ShadowInt64 is a test method.
ShadowInt64(int64, types.Int64)

// ShadowUint is a test method.
ShadowUint(uint, types.Uint)
// ShadowUint8 is a test method.
ShadowUint8(uint8, types.Uint8)
// ShadowUint16 is a test method.
ShadowUint16(uint16, types.Uint16)
// ShadowUint32 is a test method.
ShadowUint32(uint32, types.Uint32)
// ShadowUint64 is a test method.
ShadowUint64(uint64, types.Uint64)

// ShadowFloat32 is a test method.
ShadowFloat32(float32, types.Float32)
// ShadowFloat64 is a test method.
ShadowFloat64(float64, types.Float64)

// ShadowByte is a test method.
ShadowByte(byte, types.Byte)

// ShadowRune is a test method.
ShadowRune(rune, types.Rune)

// ShadowBool is a test method.
ShadowBool(bool, types.Bool)

// ShadowComplex64 is a test method.
ShadowComplex64(complex64, types.Complex64)
// ShadowComplex128 is a test method.
ShadowComplex128(complex128, types.Complex128)

// ShadowUintptr is a test method.
ShadowUintptr(uintptr, types.Uintptr)
}
19 changes: 19 additions & 0 deletions pkg/moq/testpackages/shadowtypes/types/types.go
Original file line number Diff line number Diff line change
@@ -1,29 +1,48 @@
package types

// String is a test type.
type String string

// Int is a test type.
type Int int
// Int8 is a test type.
type Int8 int8
// Int16 is a test type.
type Int16 int16
// Int32 is a test type.
type Int32 int32
// Int64 is a test type.
type Int64 int64

// Uint is a test type.
type Uint uint
// Uint8 is a test type.
type Uint8 uint
// Uint16 is a test type.
type Uint16 uint
// Uint32 is a test type.
type Uint32 uint
// Uint64 is a test type.
type Uint64 uint

// Float32 is a test type.
type Float32 float32
// Float64 is a test type.
type Float64 float64

// Byte is a test type.
type Byte byte

// Rune is a test type.
type Rune rune

// Bool is a test type.
type Bool bool

// Complex64 is a test type.
type Complex64 complex64
// Complex128 is a test type.
type Complex128 complex128

// Uintptr is a test type.
type Uintptr uintptr
1 change: 1 addition & 0 deletions pkg/moq/testpackages/syncimport/sync/thing.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
package sync

// Thing is a test type.
type Thing string
1 change: 1 addition & 0 deletions pkg/moq/testpackages/syncimport/syncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"github.com/matryer/moq/pkg/moq/testpackages/syncimport/sync"
)

// Syncer is a test interface.
type Syncer interface {
Blah(s sync.Thing, wg *stdsync.WaitGroup)
}
1 change: 1 addition & 0 deletions pkg/moq/testpackages/transientimport/base/type.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
two "github.com/matryer/moq/pkg/moq/testpackages/transientimport/two/app/v1"
)

// Transient is a test interface.
type Transient interface {
DoSomething(onev1.Zero, one.One, two.Two, three.Three, four.Four)
}
1 change: 1 addition & 0 deletions pkg/moq/testpackages/transientimport/four/app/v1/four.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
package v1

// Four is a test type.
type Four string
1 change: 1 addition & 0 deletions pkg/moq/testpackages/transientimport/one/v1/one.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
package v1

// One is a test type.
type One string
1 change: 1 addition & 0 deletions pkg/moq/testpackages/transientimport/onev1/zero.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
package onev1

// Zero is a test type.
type Zero string
1 change: 1 addition & 0 deletions pkg/moq/testpackages/transientimport/three/v1/three.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
package v1

// Three is a test type.
type Three string
1 change: 1 addition & 0 deletions pkg/moq/testpackages/transientimport/transient.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ import (
"github.com/matryer/moq/pkg/moq/testpackages/transientimport/base"
)

// Transient is a test interface.
type Transient = base.Transient
1 change: 1 addition & 0 deletions pkg/moq/testpackages/transientimport/two/app/v1/two.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
package v1

// Two is a test type.
type Two string
1 change: 1 addition & 0 deletions pkg/moq/testpackages/variadic/echoer.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package variadic

// Echoer is an interface.
type Echoer interface {
Echo(ss ...string) []string
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 1d3ef20

Please sign in to comment.