Skip to content
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
16 changes: 16 additions & 0 deletions assert/cmd/gty-migrate-from-testify/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
"os"
"os/exec"
"testing"

"github.com/google/go-cmp/cmp"
Expand All @@ -11,6 +12,14 @@ import (
"gotest.tools/v3/golden"
)

func goGet(t *testing.T, pkg string) {
t.Log("go get", pkg)
cmd := exec.Command("go", "get", pkg)
if err := cmd.Run(); err != nil {
t.Fatal(err)
}
}

func TestRun(t *testing.T) {
setupLogging(&options{})
dir := fs.NewDir(t, "test-run",
Expand All @@ -19,6 +28,13 @@ func TestRun(t *testing.T) {

defer env.Patch(t, "GO111MODULE", "off")()
defer env.Patch(t, "GOPATH", dir.Path())()

// Fetch dependencies in GOPATH mode
// Check list in testdata/full/some_test.go
goGet(t, "gopkg.in/check.v1")
goGet(t, "github.com/stretchr/testify/assert")
goGet(t, "github.com/stretchr/testify/require")

err := run(options{
pkgs: []string{"example.com/example"},
showLoaderErrors: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"
"testing"

"github.com/go-check/check"
"gopkg.in/check.v1"
"gotest.tools/v3/assert"
"gotest.tools/v3/assert/cmp"
)
Expand Down Expand Up @@ -134,9 +134,13 @@ func TestTableTest(t *testing.T) {
}
}

func TestWithChecker(c *check.C) {
type MySuite struct{}

var _ = check.Suite(&MySuite{})

func (s *MySuite) TestWithChecker(c *check.C) {
var err error
assert.Check(c, err)
c.Assert(err, check.Equals, nil)
}

func HelperWithAssertTestingT(t assert.TestingT) {
Expand Down
10 changes: 7 additions & 3 deletions assert/cmd/gty-migrate-from-testify/testdata/full/some_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import (
"fmt"
"testing"

"github.com/go-check/check"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"gopkg.in/check.v1"
)

type mystruct struct {
Expand Down Expand Up @@ -135,9 +135,13 @@ func TestTableTest(t *testing.T) {
}
}

func TestWithChecker(c *check.C) {
type MySuite struct{}

var _ = check.Suite(&MySuite{})

func (s *MySuite) TestWithChecker(c *check.C) {
var err error
assert.NoError(c, err)
c.Assert(err, check.Equals, nil)
}

func HelperWithAssertTestingT(t assert.TestingT) {
Expand Down