Skip to content
This repository has been archived by the owner on Sep 9, 2020. It is now read-only.

Commit

Permalink
rename testgo to Helper
Browse files Browse the repository at this point in the history
TestgoData has been renamed to Helper and Testgo to NewHelper.
  • Loading branch information
Miguel Molina authored and sdboyer committed Jan 31, 2017
1 parent 76df5ce commit 8e957c3
Show file tree
Hide file tree
Showing 8 changed files with 324 additions and 325 deletions.
48 changes: 24 additions & 24 deletions cmd/dep/ensure_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ func TestEnsureOverrides(t *testing.T) {
test.NeedsExternalNetwork(t)
test.NeedsGit(t)

tg := test.Testgo(t)
defer tg.Cleanup()
h := test.NewHelper(t)
defer h.Cleanup()

tg.TempDir("src")
tg.Setenv("GOPATH", tg.Path("."))
h.TempDir("src")
h.Setenv("GOPATH", h.Path("."))

m := `package main
Expand All @@ -34,11 +34,11 @@ func main() {
logrus.Info("hello world")
}`

tg.TempFile("src/thing/thing.go", m)
tg.Cd(tg.Path("src/thing"))
h.TempFile("src/thing/thing.go", m)
h.Cd(h.Path("src/thing"))

tg.Run("init")
tg.Run("ensure", "-override", "github.com/Sirupsen/logrus@0.11.0")
h.Run("init")
h.Run("ensure", "-override", "github.com/Sirupsen/logrus@0.11.0")

expectedManifest := `{
"overrides": {
Expand All @@ -49,12 +49,12 @@ func main() {
}
`

manifest := tg.ReadManifest()
manifest := h.ReadManifest()
if manifest != expectedManifest {
t.Fatalf("expected %s, got %s", expectedManifest, manifest)
}

sysCommit := tg.GetCommit("go.googlesource.com/sys")
sysCommit := h.GetCommit("go.googlesource.com/sys")
expectedLock := `{
"memo": "57d20ba0289c2df60025bf6127220a5403483251bd5e523a7f9ea17752bd5482",
"projects": [
Expand Down Expand Up @@ -85,7 +85,7 @@ func main() {
]
}
`
lock := tg.ReadLock()
lock := h.ReadLock()
if lock != expectedLock {
t.Fatalf("expected %s, got %s", expectedLock, lock)
}
Expand All @@ -95,11 +95,11 @@ func TestEnsureEmptyRepoNoArgs(t *testing.T) {
test.NeedsExternalNetwork(t)
test.NeedsGit(t)

tg := test.Testgo(t)
defer tg.Cleanup()
h := test.NewHelper(t)
defer h.Cleanup()

tg.TempDir("src")
tg.Setenv("GOPATH", tg.Path("."))
h.TempDir("src")
h.Setenv("GOPATH", h.Path("."))

m := `package main
Expand All @@ -111,25 +111,25 @@ func main() {
logrus.Info("hello world")
}`

tg.TempFile("src/thing/thing.go", m)
tg.Cd(tg.Path("src/thing"))
h.TempFile("src/thing/thing.go", m)
h.Cd(h.Path("src/thing"))

tg.Run("init")
tg.Run("ensure")
h.Run("init")
h.Run("ensure")

// make sure vendor exists
tg.MustExist(tg.Path("src/thing/vendor/github.com/Sirupsen/logrus"))
h.MustExist(h.Path("src/thing/vendor/github.com/Sirupsen/logrus"))

expectedManifest := `{}
`

manifest := tg.ReadManifest()
manifest := h.ReadManifest()
if manifest != expectedManifest {
t.Fatalf("expected %s, got %s", expectedManifest, manifest)
}

sysCommit := tg.GetCommit("go.googlesource.com/sys")
logrusCommit := tg.GetCommit("github.com/Sirupsen/logrus")
sysCommit := h.GetCommit("go.googlesource.com/sys")
logrusCommit := h.GetCommit("github.com/Sirupsen/logrus")
expectedLock := `{
"memo": "d4a7b45d366ece090464407f4038cdb62a031c29ef3254f197b8a3d5e6993cca",
"projects": [
Expand All @@ -153,7 +153,7 @@ func main() {
}
`

lock := tg.ReadLock()
lock := h.ReadLock()
if lock != expectedLock {
t.Fatalf("expected %s, got %s", expectedLock, lock)
}
Expand Down
28 changes: 14 additions & 14 deletions cmd/dep/init_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ func TestInit(t *testing.T) {
test.NeedsExternalNetwork(t)
test.NeedsGit(t)

tg := test.Testgo(t)
defer tg.Cleanup()
h := test.NewHelper(t)
defer h.Cleanup()

tg.TempDir("src")
tg.Setenv("GOPATH", tg.Path("."))
h.TempDir("src")
h.Setenv("GOPATH", h.Path("."))

importPaths := map[string]string{
"github.com/pkg/errors": "v0.8.0", // semver
Expand All @@ -55,9 +55,9 @@ func TestInit(t *testing.T) {

// checkout the specified revisions
for ip, rev := range importPaths {
tg.RunGo("get", ip)
repoDir := tg.Path("src/" + ip)
tg.RunGit(repoDir, "checkout", rev)
h.RunGo("get", ip)
repoDir := h.Path("src/" + ip)
h.RunGit(repoDir, "checkout", rev)
}

// Build a fake consumer of these packages.
Expand All @@ -79,16 +79,16 @@ func main() {
logrus.Info(bar.Qux)
}`

tg.TempFile("src/"+root+"/foo/thing.go", m)
h.TempFile("src/"+root+"/foo/thing.go", m)

m = `package bar
const Qux = "yo yo!"
`
tg.TempFile("src/"+root+"/foo/bar/bar.go", m)
h.TempFile("src/"+root+"/foo/bar/bar.go", m)

tg.Cd(tg.Path("src/" + root))
tg.Run("init")
h.Cd(h.Path("src/" + root))
h.Run("init")

expectedManifest := `{
"dependencies": {
Expand All @@ -101,12 +101,12 @@ const Qux = "yo yo!"
}
}
`
manifest := tg.ReadManifest()
manifest := h.ReadManifest()
if manifest != expectedManifest {
t.Fatalf("expected %s, got %s", expectedManifest, manifest)
}

sysCommit := tg.GetCommit("go.googlesource.com/sys")
sysCommit := h.GetCommit("go.googlesource.com/sys")
expectedLock := `{
"memo": "668fe45796bc4e85a5a6c0a0f1eb6fab9e23588d1eb33f3a12b2ad5599a3575e",
"projects": [
Expand Down Expand Up @@ -136,7 +136,7 @@ const Qux = "yo yo!"
]
}
`
lock := tg.ReadLock()
lock := h.ReadLock()
if lock != expectedLock {
t.Fatalf("expected %s, got %s", expectedLock, lock)
}
Expand Down
48 changes: 24 additions & 24 deletions cmd/dep/remove_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ func TestRemove(t *testing.T) {
test.NeedsExternalNetwork(t)
test.NeedsGit(t)

tg := test.Testgo(t)
defer tg.Cleanup()
h := test.NewHelper(t)
defer h.Cleanup()

tg.TempDir("src")
tg.Setenv("GOPATH", tg.Path("."))
h.TempDir("src")
h.Setenv("GOPATH", h.Path("."))

importPaths := map[string]string{
"github.com/pkg/errors": "v0.8.0", // semver
Expand All @@ -27,9 +27,9 @@ func TestRemove(t *testing.T) {

// checkout the specified revisions
for ip, rev := range importPaths {
tg.RunGo("get", ip)
repoDir := tg.Path("src/" + ip)
tg.RunGit(repoDir, "checkout", rev)
h.RunGo("get", ip)
repoDir := h.Path("src/" + ip)
h.RunGit(repoDir, "checkout", rev)
}

// Build a fake consumer of these packages.
Expand All @@ -49,7 +49,7 @@ func main() {
logrus.Info("whatev")
}`

tg.TempFile("src/"+root+"/thing.go", m)
h.TempFile("src/"+root+"/thing.go", m)
origm := `{
"dependencies": {
"github.com/not/used": {
Expand All @@ -76,44 +76,44 @@ func main() {
}
`

tg.TempFile("src/"+root+"/manifest.json", origm)
h.TempFile("src/"+root+"/manifest.json", origm)

tg.Cd(tg.Path("src/" + root))
tg.Run("remove", "-unused")
h.Cd(h.Path("src/" + root))
h.Run("remove", "-unused")

manifest := tg.ReadManifest()
manifest := h.ReadManifest()
if manifest != expectedManifest {
t.Fatalf("expected %s, got %s", expectedManifest, manifest)
}

tg.TempFile("src/"+root+"/manifest.json", origm)
tg.Run("remove", "github.com/not/used")
h.TempFile("src/"+root+"/manifest.json", origm)
h.Run("remove", "github.com/not/used")

manifest = tg.ReadManifest()
manifest = h.ReadManifest()
if manifest != expectedManifest {
t.Fatalf("expected %s, got %s", expectedManifest, manifest)
}

if err := tg.DoRun([]string{"remove", "-unused", "github.com/not/used"}); err == nil {
if err := h.DoRun([]string{"remove", "-unused", "github.com/not/used"}); err == nil {
t.Fatal("rm with both -unused and arg should have failed")
}

if err := tg.DoRun([]string{"remove", "github.com/not/present"}); err == nil {
if err := h.DoRun([]string{"remove", "github.com/not/present"}); err == nil {
t.Fatal("rm with arg not in manifest should have failed")
}

if err := tg.DoRun([]string{"remove", "github.com/not/used", "github.com/not/present"}); err == nil {
if err := h.DoRun([]string{"remove", "github.com/not/used", "github.com/not/present"}); err == nil {
t.Fatal("rm with one arg not in manifest should have failed")
}

if err := tg.DoRun([]string{"remove", "github.com/pkg/errors"}); err == nil {
if err := h.DoRun([]string{"remove", "github.com/pkg/errors"}); err == nil {
t.Fatal("rm of arg in manifest and imports should have failed without -force")
}

tg.TempFile("src/"+root+"/manifest.json", origm)
tg.Run("remove", "-force", "github.com/pkg/errors", "github.com/not/used")
h.TempFile("src/"+root+"/manifest.json", origm)
h.Run("remove", "-force", "github.com/pkg/errors", "github.com/not/used")

manifest = tg.ReadManifest()
manifest = h.ReadManifest()
if manifest != `{
"dependencies": {
"github.com/Sirupsen/logrus": {
Expand All @@ -125,7 +125,7 @@ func main() {
t.Fatalf("expected %s, got %s", expectedManifest, manifest)
}

sysCommit := tg.GetCommit("go.googlesource.com/sys")
sysCommit := h.GetCommit("go.googlesource.com/sys")
expectedLock := `{
"memo": "7769242a737ed497aa39831eecfdc4a1bf59517df898907accc6bdc0f789a69b",
"projects": [
Expand Down Expand Up @@ -155,7 +155,7 @@ func main() {
]
}
`
lock := tg.ReadLock()
lock := h.ReadLock()
if lock != expectedLock {
t.Fatalf("expected %s, got %s", expectedLock, lock)
}
Expand Down
1 change: 0 additions & 1 deletion cmd/dep/status_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
)

func TestStatusFormatVersion(t *testing.T) {

tests := map[gps.Version]string{
nil: "",
gps.NewBranch("master"): "branch master",
Expand Down
Loading

0 comments on commit 8e957c3

Please sign in to comment.