From 42c4cd7c3e4847497e8f52b7c68640b62564ba17 Mon Sep 17 00:00:00 2001 From: Sam Alba Date: Thu, 13 Jan 2022 15:06:45 -0800 Subject: [PATCH] mod: fix unit tests since dagger/universe is no more available Signed-off-by: Sam Alba --- mod/repo_test.go | 24 ++++++++++++------------ mod/require.go | 4 ++-- mod/require_test.go | 36 ++++++++++++++++++------------------ 3 files changed, 32 insertions(+), 32 deletions(-) diff --git a/mod/repo_test.go b/mod/repo_test.go index 61b2d4e4..460e59f4 100644 --- a/mod/repo_test.go +++ b/mod/repo_test.go @@ -17,17 +17,17 @@ func TestClone(t *testing.T) { { name: "resolving branch name", require: Require{ - cloneRepo: "github.com/dagger/universe", - clonePath: "stdlib", + cloneRepo: "github.com/dagger/dagger-action", + clonePath: "", version: "main", }, }, { name: "resolving tag", require: Require{ - cloneRepo: "github.com/dagger/universe", - clonePath: "stdlib", - version: "v0.1.0", + cloneRepo: "github.com/dagger/dagger-action", + clonePath: "", + version: "v1.0.0", }, }, // FIXME: disabled until we find a fix: "repo_test.go:56: ssh: handshake failed: knownhosts: key mismatch" @@ -70,8 +70,8 @@ func TestListTags(t *testing.T) { ctx := context.TODO() r, err := clone(ctx, &Require{ - cloneRepo: "github.com/dagger/universe", - clonePath: "stdlib", + cloneRepo: "github.com/dagger/dagger-action", + clonePath: "", version: "", }, tmpDir, "", "") if err != nil { @@ -98,22 +98,22 @@ func TestVersionConstraint(t *testing.T) { ctx := context.TODO() r, err := clone(ctx, &Require{ - cloneRepo: "github.com/dagger/universe", - clonePath: "stdlib", + cloneRepo: "github.com/dagger/dagger-action", + clonePath: "", version: "", }, tmpDir, "", "") if err != nil { t.Fatal(err) } - tagVersion, err := r.latestTag(ctx, "<= 0.1.0") + tagVersion, err := r.latestTag(ctx, "<= 1.1.0") if err != nil { t.Error(err) } // Make sure we select the right version based on constraint - if tagVersion != "v0.1.0" { - t.Errorf("wrong version: expected 0.1.0, got %v", tagVersion) + if tagVersion != "v1.1.0" { + t.Errorf("wrong version: expected v1.1.0, got %v", tagVersion) } // Make sure an invalid constraint (version out of range) returns an error diff --git a/mod/require.go b/mod/require.go index d5061fa2..0c9c57c3 100644 --- a/mod/require.go +++ b/mod/require.go @@ -71,8 +71,8 @@ func parseDaggerRepoName(repoName, versionConstraint string) (*Require, error) { version: repoMatches[2], versionConstraint: versionConstraint, - cloneRepo: "github.com/dagger/universe", - clonePath: path.Join("/stdlib", repoMatches[1]), + cloneRepo: "github.com/dagger/examples", + clonePath: path.Join("/helloapp", repoMatches[1]), }, nil } diff --git a/mod/require_test.go b/mod/require_test.go index 602abf45..88bd9b01 100644 --- a/mod/require_test.go +++ b/mod/require_test.go @@ -96,46 +96,46 @@ func TestParseArgument(t *testing.T) { }, { name: "Custom git provider without folder", - in: "git.blocklayer.com/dagger/universe.git@main", + in: "git.blocklayer.com/dagger/test.git@main", want: &Require{ - repo: "git.blocklayer.com/dagger/universe.git", + repo: "git.blocklayer.com/dagger/test.git", path: "", version: "main", }, }, { name: "Custom git provider with folder and version", - in: "git.blocklayer.com/dagger/universe.git/stdlib/alpha.dagger.io/dagger@v0.1.0", + in: "git.blocklayer.com/dagger/test.git/test@v1.1.0", want: &Require{ - repo: "git.blocklayer.com/dagger/universe.git", - path: "/stdlib/alpha.dagger.io/dagger", - version: "v0.1.0", + repo: "git.blocklayer.com/dagger/test.git", + path: "/test", + version: "v1.1.0", }, }, { name: "Custom git provider with folder and version", - in: "git.blocklayer.com/dagger/universe.git/stdlib@v5", + in: "git.blocklayer.com/dagger/test.git/test@v1.1.0", want: &Require{ - repo: "git.blocklayer.com/dagger/universe.git", - path: "/stdlib", - version: "v5", + repo: "git.blocklayer.com/dagger/test.git", + path: "/test", + version: "v1.1.0", }, }, { name: "Custom git provider without folder", - in: "git.blocklayer.com/dagger/universe.git", + in: "git.blocklayer.com/dagger/test.git", want: &Require{ - repo: "git.blocklayer.com/dagger/universe.git", + repo: "git.blocklayer.com/dagger/test.git", path: "", version: "", }, }, { name: "Custom git provider with folder, no version", - in: "git.blocklayer.com/dagger/universe.git/stdlib/alpha.dagger.io/dagger", + in: "git.blocklayer.com/dagger/test.git/test", want: &Require{ - repo: "git.blocklayer.com/dagger/universe.git", - path: "/stdlib/alpha.dagger.io/dagger", + repo: "git.blocklayer.com/dagger/test.git", + path: "/test", version: "", }, }, @@ -163,15 +163,15 @@ func TestParseArgument(t *testing.T) { } if got.repo != c.want.repo { - t.Errorf("repos differ: want %s, got %s", c.want.repo, got.repo) + t.Errorf("repos differ %q: want %s, got %s", c.in, c.want.repo, got.repo) } if got.path != c.want.path { - t.Errorf("paths differ: want %s, got %s", c.want.path, got.path) + t.Errorf("paths differ %q: want %s, got %s", c.in, c.want.path, got.path) } if got.version != c.want.version { - t.Errorf("versions differ: want %s, got %s", c.want.version, got.version) + t.Errorf("versions differ (%q): want %s, got %s", c.in, c.want.version, got.version) } }) }