Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump gotest.tools/v3 from 3.3.0 to 3.4.0 #5

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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 go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ require (
gopkg.in/square/go-jose.v2 v2.6.0
gopkg.in/yaml.v2 v2.4.0
gotest.tools v2.2.0+incompatible
gotest.tools/v3 v3.3.0
gotest.tools/v3 v3.4.0
k8s.io/api v0.23.9
k8s.io/apimachinery v0.23.9
k8s.io/cli-runtime v0.23.9
Expand Down
3 changes: 2 additions & 1 deletion go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -4008,8 +4008,9 @@ gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81
gotest.tools/v3 v3.0.2/go.mod h1:3SzNCllyD9/Y+b5r9JIKQ474KzkZyqLqEfYqMsX94Bk=
gotest.tools/v3 v3.0.3/go.mod h1:Z7Lb0S5l+klDB31fvDQX8ss/FlKDxtlFlw3Oa8Ymbl8=
gotest.tools/v3 v3.1.0/go.mod h1:fHy7eyTmJFO5bQbUsEGQ1v4m2J3Jz9eWL54TP2/ZuYQ=
gotest.tools/v3 v3.3.0 h1:MfDY1b1/0xN1CyMlQDac0ziEy9zJQd9CXBRRDHw2jJo=
gotest.tools/v3 v3.3.0/go.mod h1:Mcr9QNxkg0uMvy/YElmo4SpXgJKWgQvYrT7Kw5RzJ1A=
gotest.tools/v3 v3.4.0 h1:ZazjZUfuVeZGLAmlKKuyv3IKP5orXcwtOwDQH6YVr6o=
gotest.tools/v3 v3.4.0/go.mod h1:CtbdzLSsqVhDgMtKsx03ird5YTGB3ar27v0u/yKBW5g=
honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
Expand Down
58 changes: 28 additions & 30 deletions vendor/gotest.tools/v3/assert/assert.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
/*Package assert provides assertions for comparing expected values to actual
/*
Package assert provides assertions for comparing expected values to actual
values in tests. When an assertion fails a helpful error message is printed.

Example usage
# Example usage

All the assertions in this package use testing.T.Helper to mark themselves as
test helpers. This allows the testing package to print the filename and line
Expand Down Expand Up @@ -64,7 +65,7 @@ message is omitted from these examples for brevity.
assert.Assert(t, ref != nil) // use Assert for NotNil
// assertion failed: ref is nil

Assert and Check
# Assert and Check

Assert and Check are very similar, they both accept a Comparison, and fail
the test when the comparison fails. The one difference is that Assert uses
Expand All @@ -76,20 +77,18 @@ Like testing.T.FailNow, Assert must be called from the goroutine running the tes
not from other goroutines created during the test. Check is safe to use from any
goroutine.

Comparisons
# Comparisons

Package http://pkg.go.dev/gotest.tools/v3/assert/cmp provides
many common comparisons. Additional comparisons can be written to compare
values in other ways. See the example Assert (CustomComparison).

Automated migration from testify
# Automated migration from testify

gty-migrate-from-testify is a command which translates Go source code from
testify assertions to the assertions provided by this package.

See http://pkg.go.dev/gotest.tools/v3/assert/cmd/gty-migrate-from-testify.


*/
package assert // import "gotest.tools/v3/assert"

Expand Down Expand Up @@ -119,19 +118,18 @@ type helperT interface {
//
// The comparison argument may be one of three types:
//
// bool
// True is success. False is a failure. The failure message will contain
// the literal source code of the expression.
//
// cmp.Comparison
// Uses cmp.Result.Success() to check for success or failure.
// The comparison is responsible for producing a helpful failure message.
// http://pkg.go.dev/gotest.tools/v3/assert/cmp provides many common comparisons.
// bool
// True is success. False is a failure. The failure message will contain
// the literal source code of the expression.
//
// error
// A nil value is considered success, and a non-nil error is a failure.
// The return value of error.Error is used as the failure message.
// cmp.Comparison
// Uses cmp.Result.Success() to check for success or failure.
// The comparison is responsible for producing a helpful failure message.
// http://pkg.go.dev/gotest.tools/v3/assert/cmp provides many common comparisons.
//
// error
// A nil value is considered success, and a non-nil error is a failure.
// The return value of error.Error is used as the failure message.
//
// Extra details can be added to the failure message using msgAndArgs. msgAndArgs
// may be either a single string, or a format string and args that will be
Expand Down Expand Up @@ -187,8 +185,8 @@ func NilError(t TestingT, err error, msgAndArgs ...interface{}) {
// x and y as part of the failure message to identify the actual and expected
// values.
//
// assert.Equal(t, actual, expected)
// // main_test.go:41: assertion failed: 1 (actual int) != 21 (expected int32)
// assert.Equal(t, actual, expected)
// // main_test.go:41: assertion failed: 1 (actual int) != 21 (expected int32)
//
// If either x or y are a multi-line string the failure message will include a
// unified diff of the two values. If the values only differ by whitespace
Expand Down Expand Up @@ -269,19 +267,19 @@ func ErrorContains(t TestingT, err error, substring string, msgAndArgs ...interf
//
// Expected can be one of:
//
// func(error) bool
// The function should return true if the error is the expected type.
// func(error) bool
// The function should return true if the error is the expected type.
//
// struct{} or *struct{}
// A struct or a pointer to a struct. The assertion fails if the error is
// not of the same type.
// struct{} or *struct{}
// A struct or a pointer to a struct. The assertion fails if the error is
// not of the same type.
//
// *interface{}
// A pointer to an interface type. The assertion fails if err does not
// implement the interface.
// *interface{}
// A pointer to an interface type. The assertion fails if err does not
// implement the interface.
//
// reflect.Type
// The assertion fails if err does not implement the reflect.Type.
// reflect.Type
// The assertion fails if err does not implement the reflect.Type.
//
// ErrorType uses t.FailNow to fail the test. Like t.FailNow, ErrorType
// must be called from the goroutine running the test function, not from other
Expand Down
25 changes: 17 additions & 8 deletions vendor/gotest.tools/v3/assert/cmp/compare.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,10 @@ type RegexOrPattern interface{}
// Regexp succeeds if value v matches regular expression re.
//
// Example:
// assert.Assert(t, cmp.Regexp("^[0-9a-f]{32}$", str))
// r := regexp.MustCompile("^[0-9a-f]{32}$")
// assert.Assert(t, cmp.Regexp(r, str))
//
// assert.Assert(t, cmp.Regexp("^[0-9a-f]{32}$", str))
// r := regexp.MustCompile("^[0-9a-f]{32}$")
// assert.Assert(t, cmp.Regexp(r, str))
func Regexp(re RegexOrPattern, v string) Comparison {
match := func(re *regexp.Regexp) Result {
return toResult(
Expand Down Expand Up @@ -248,7 +249,7 @@ type causer interface {
}

func formatErrorMessage(err error) string {
// nolint: errorlint // unwrapping is not appropriate here
//nolint:errorlint // unwrapping is not appropriate here
if _, ok := err.(causer); ok {
return fmt.Sprintf("%q\n%+v", err, err)
}
Expand Down Expand Up @@ -288,15 +289,23 @@ func isNil(obj interface{}, msgFunc func(reflect.Value) string) Comparison {
// ErrorType succeeds if err is not nil and is of the expected type.
//
// Expected can be one of:
// func(error) bool
//
// func(error) bool
//
// Function should return true if the error is the expected type.
// type struct{}, type &struct{}
//
// type struct{}, type &struct{}
//
// A struct or a pointer to a struct.
// Fails if the error is not of the same type as expected.
// type &interface{}
//
// type &interface{}
//
// A pointer to an interface type.
// Fails if err does not implement the interface.
// reflect.Type
//
// reflect.Type
//
// Fails if err does not implement the reflect.Type
func ErrorType(err error, expected interface{}) Comparison {
return func() Result {
Expand Down
14 changes: 6 additions & 8 deletions vendor/gotest.tools/v3/fs/file.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/*Package fs provides tools for creating temporary files, and testing the
/*
Package fs provides tools for creating temporary files, and testing the
contents and structure of a directory.
*/
package fs // import "gotest.tools/v3/fs"

import (
"io/ioutil"
"os"
"path/filepath"
"runtime"
Expand Down Expand Up @@ -45,7 +45,7 @@ func NewFile(t assert.TestingT, prefix string, ops ...PathOp) *File {
if ht, ok := t.(helperT); ok {
ht.Helper()
}
tempfile, err := ioutil.TempFile("", cleanPrefix(prefix)+"-")
tempfile, err := os.CreateTemp("", cleanPrefix(prefix)+"-")
assert.NilError(t, err)

file := &File{path: tempfile.Name()}
Expand All @@ -71,8 +71,7 @@ func (f *File) Path() string {

// Remove the file
func (f *File) Remove() {
// nolint: errcheck
os.Remove(f.path)
_ = os.Remove(f.path)
}

// Dir is a temporary directory
Expand All @@ -89,7 +88,7 @@ func NewDir(t assert.TestingT, prefix string, ops ...PathOp) *Dir {
if ht, ok := t.(helperT); ok {
ht.Helper()
}
path, err := ioutil.TempDir("", cleanPrefix(prefix)+"-")
path, err := os.MkdirTemp("", cleanPrefix(prefix)+"-")
assert.NilError(t, err)
dir := &Dir{path: path}
cleanup.Cleanup(t, dir.Remove)
Expand All @@ -105,8 +104,7 @@ func (d *Dir) Path() string {

// Remove the directory
func (d *Dir) Remove() {
// nolint: errcheck
os.RemoveAll(d.path)
_ = os.RemoveAll(d.path)
}

// Join returns a new path with this directory as the base of the path
Expand Down
9 changes: 6 additions & 3 deletions vendor/gotest.tools/v3/fs/manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package fs
import (
"fmt"
"io"
"io/ioutil"
"os"
"path/filepath"

Expand Down Expand Up @@ -84,7 +83,7 @@ func manifestFromDir(path string) (Manifest, error) {

func newDirectory(path string, info os.FileInfo) (*directory, error) {
items := make(map[string]dirEntry)
children, err := ioutil.ReadDir(path)
children, err := os.ReadDir(path)
if err != nil {
return nil, err
}
Expand All @@ -103,7 +102,11 @@ func newDirectory(path string, info os.FileInfo) (*directory, error) {
}, nil
}

func getTypedResource(path string, info os.FileInfo) (dirEntry, error) {
func getTypedResource(path string, entry os.DirEntry) (dirEntry, error) {
info, err := entry.Info()
if err != nil {
return nil, err
}
switch {
case info.IsDir():
return newDirectory(path, info)
Expand Down
55 changes: 29 additions & 26 deletions vendor/gotest.tools/v3/fs/ops.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"bytes"
"fmt"
"io"
"io/ioutil"
"os"
"path/filepath"
"strings"
Expand Down Expand Up @@ -43,29 +42,29 @@ type manifestDirectory interface {
func WithContent(content string) PathOp {
return func(path Path) error {
if m, ok := path.(manifestFile); ok {
m.SetContent(ioutil.NopCloser(strings.NewReader(content)))
m.SetContent(io.NopCloser(strings.NewReader(content)))
return nil
}
return ioutil.WriteFile(path.Path(), []byte(content), defaultFileMode)
return os.WriteFile(path.Path(), []byte(content), defaultFileMode)
}
}

// WithBytes write bytes to a file at Path
func WithBytes(raw []byte) PathOp {
return func(path Path) error {
if m, ok := path.(manifestFile); ok {
m.SetContent(ioutil.NopCloser(bytes.NewReader(raw)))
m.SetContent(io.NopCloser(bytes.NewReader(raw)))
return nil
}
return ioutil.WriteFile(path.Path(), raw, defaultFileMode)
return os.WriteFile(path.Path(), raw, defaultFileMode)
}
}

// WithReaderContent copies the reader contents to the file at Path
func WithReaderContent(r io.Reader) PathOp {
return func(path Path) error {
if m, ok := path.(manifestFile); ok {
m.SetContent(ioutil.NopCloser(r))
m.SetContent(io.NopCloser(r))
return nil
}
f, err := os.OpenFile(path.Path(), os.O_WRONLY, defaultFileMode)
Expand Down Expand Up @@ -107,7 +106,7 @@ func WithFile(filename, content string, ops ...PathOp) PathOp {
}

func createFile(fullpath string, content string) error {
return ioutil.WriteFile(fullpath, []byte(content), defaultFileMode)
return os.WriteFile(fullpath, []byte(content), defaultFileMode)
}

// WithFiles creates all the files in the directory at path with their content
Expand Down Expand Up @@ -191,34 +190,38 @@ func WithMode(mode os.FileMode) PathOp {
}

func copyDirectory(source, dest string) error {
entries, err := ioutil.ReadDir(source)
entries, err := os.ReadDir(source)
if err != nil {
return err
}
for _, entry := range entries {
sourcePath := filepath.Join(source, entry.Name())
destPath := filepath.Join(dest, entry.Name())
switch {
case entry.IsDir():
if err := os.Mkdir(destPath, 0755); err != nil {
return err
}
if err := copyDirectory(sourcePath, destPath); err != nil {
return err
}
case entry.Mode()&os.ModeSymlink != 0:
if err := copySymLink(sourcePath, destPath); err != nil {
return err
}
default:
if err := copyFile(sourcePath, destPath); err != nil {
return err
}
err = copyEntry(entry, destPath, sourcePath)
if err != nil {
return err
}
}
return nil
}

func copyEntry(entry os.DirEntry, destPath string, sourcePath string) error {
if entry.IsDir() {
if err := os.Mkdir(destPath, 0755); err != nil {
return err
}
return copyDirectory(sourcePath, destPath)
}
info, err := entry.Info()
if err != nil {
return err
}
if info.Mode()&os.ModeSymlink != 0 {
return copySymLink(sourcePath, destPath)
}
return copyFile(sourcePath, destPath)
}

func copySymLink(source, dest string) error {
link, err := os.Readlink(source)
if err != nil {
Expand All @@ -228,11 +231,11 @@ func copySymLink(source, dest string) error {
}

func copyFile(source, dest string) error {
content, err := ioutil.ReadFile(source)
content, err := os.ReadFile(source)
if err != nil {
return err
}
return ioutil.WriteFile(dest, content, 0644)
return os.WriteFile(dest, content, 0644)
}

// WithSymlink creates a symlink in the directory which links to target.
Expand Down
Loading