Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion autogold.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func update() bool {
//
// If the input value is of type Raw, its contents will be directly used instead of the value being
// formatted as a Go literal.
func ExpectFile(t *testing.T, got interface{}, opts ...Option) {
func ExpectFile(t *testing.T, got any, opts ...Option) {
t.Helper()
dir := testdataDir(opts)
fileName := testName(t, opts)
Expand Down
2 changes: 1 addition & 1 deletion diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func diff(got, want string, opts []Option) string {
// Raw denotes a raw string.
type Raw string

func stringify(v interface{}, opts []Option) string {
func stringify(v any, opts []Option) string {
var (
allowRaw, trailingNewline bool
valastOpt = &valast.Options{}
Expand Down
10 changes: 5 additions & 5 deletions expect.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ import (
// Value describes a desired value for a Go test, see Expect for more information.
type Value interface {
// Equal checks if `got` matches the desired test value, invoking t.Fatal otherwise.
Equal(t *testing.T, got interface{}, opts ...Option)
Equal(t *testing.T, got any, opts ...Option)
}

type value struct {
line int
equal func(t *testing.T, got interface{}, opts ...Option)
equal func(t *testing.T, got any, opts ...Option)
}

func (v value) Equal(t *testing.T, got interface{}, opts ...Option) {
func (v value) Equal(t *testing.T, got any, opts ...Option) {
t.Helper()
v.equal(t, got, opts...)
}
Expand Down Expand Up @@ -88,11 +88,11 @@ find:
// When `-update` is specified, autogold will find and replace in the test file by looking for an
// invocation of `autogold.Expect(...)` at the same line as the callstack indicates for this function
// call, rewriting the `want` value parameter for you.
func Expect(want interface{}) Value {
func Expect(want any) Value {
_, _, line, _ := runtime.Caller(1)
return value{
line: line,
equal: func(t *testing.T, got interface{}, opts ...Option) {
equal: func(t *testing.T, got any, opts ...Option) {
t.Helper()
var (
profGetPackageNameAndPath time.Duration
Expand Down
2 changes: 0 additions & 2 deletions expect_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,6 @@ func Test_replaceExpect_multiple(t *testing.T) {
}

for _, r := range replacements {
r := r
_, err := replaceExpect(t, tmpFile, r.testName, r.line, r.replacement, true)
if err != nil {
t.Log("\ngot:\n", err, "\nwant:\n", err)
Expand Down Expand Up @@ -244,7 +243,6 @@ func testEqualSubtestSameNames(t *testing.T) {
}

for _, name := range testTable {
name := name

t.Run(name, func(t *testing.T) {
// Subtests are intentionally not run in parallel, as that makes this issue more easily reproducible
Expand Down
1 change: 0 additions & 1 deletion parallel_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ func testParallel(t *testing.T, prefix string) {
}

for _, name := range testTable {
name := name

t.Run(name, func(t *testing.T) {
t.Parallel()
Expand Down