mod: fix unit tests since dagger/universe is no more available

Signed-off-by: Sam Alba <samalba@users.noreply.github.com>
This commit is contained in:
Sam Alba 2022-01-13 15:06:45 -08:00
parent 447307b3be
commit 42c4cd7c3e
3 changed files with 32 additions and 32 deletions

View File

@ -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

View File

@ -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
}

View File

@ -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)
}
})
}