Merge pull request #1421 from samalba/fix-mod-tests
mod: fix unit tests since dagger/universe is no more available
This commit is contained in:
commit
2f92d8db4e
@ -17,17 +17,17 @@ func TestClone(t *testing.T) {
|
|||||||
{
|
{
|
||||||
name: "resolving branch name",
|
name: "resolving branch name",
|
||||||
require: Require{
|
require: Require{
|
||||||
cloneRepo: "github.com/dagger/universe",
|
cloneRepo: "github.com/dagger/dagger-action",
|
||||||
clonePath: "stdlib",
|
clonePath: "",
|
||||||
version: "main",
|
version: "main",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "resolving tag",
|
name: "resolving tag",
|
||||||
require: Require{
|
require: Require{
|
||||||
cloneRepo: "github.com/dagger/universe",
|
cloneRepo: "github.com/dagger/dagger-action",
|
||||||
clonePath: "stdlib",
|
clonePath: "",
|
||||||
version: "v0.1.0",
|
version: "v1.0.0",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
// FIXME: disabled until we find a fix: "repo_test.go:56: ssh: handshake failed: knownhosts: key mismatch"
|
// 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()
|
ctx := context.TODO()
|
||||||
|
|
||||||
r, err := clone(ctx, &Require{
|
r, err := clone(ctx, &Require{
|
||||||
cloneRepo: "github.com/dagger/universe",
|
cloneRepo: "github.com/dagger/dagger-action",
|
||||||
clonePath: "stdlib",
|
clonePath: "",
|
||||||
version: "",
|
version: "",
|
||||||
}, tmpDir, "", "")
|
}, tmpDir, "", "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -98,22 +98,22 @@ func TestVersionConstraint(t *testing.T) {
|
|||||||
ctx := context.TODO()
|
ctx := context.TODO()
|
||||||
|
|
||||||
r, err := clone(ctx, &Require{
|
r, err := clone(ctx, &Require{
|
||||||
cloneRepo: "github.com/dagger/universe",
|
cloneRepo: "github.com/dagger/dagger-action",
|
||||||
clonePath: "stdlib",
|
clonePath: "",
|
||||||
version: "",
|
version: "",
|
||||||
}, tmpDir, "", "")
|
}, tmpDir, "", "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
tagVersion, err := r.latestTag(ctx, "<= 0.1.0")
|
tagVersion, err := r.latestTag(ctx, "<= 1.1.0")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure we select the right version based on constraint
|
// Make sure we select the right version based on constraint
|
||||||
if tagVersion != "v0.1.0" {
|
if tagVersion != "v1.1.0" {
|
||||||
t.Errorf("wrong version: expected 0.1.0, got %v", tagVersion)
|
t.Errorf("wrong version: expected v1.1.0, got %v", tagVersion)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure an invalid constraint (version out of range) returns an error
|
// Make sure an invalid constraint (version out of range) returns an error
|
||||||
|
@ -71,8 +71,8 @@ func parseDaggerRepoName(repoName, versionConstraint string) (*Require, error) {
|
|||||||
version: repoMatches[2],
|
version: repoMatches[2],
|
||||||
versionConstraint: versionConstraint,
|
versionConstraint: versionConstraint,
|
||||||
|
|
||||||
cloneRepo: "github.com/dagger/universe",
|
cloneRepo: "github.com/dagger/examples",
|
||||||
clonePath: path.Join("/stdlib", repoMatches[1]),
|
clonePath: path.Join("/helloapp", repoMatches[1]),
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,46 +96,46 @@ func TestParseArgument(t *testing.T) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Custom git provider without folder",
|
name: "Custom git provider without folder",
|
||||||
in: "git.blocklayer.com/dagger/universe.git@main",
|
in: "git.blocklayer.com/dagger/test.git@main",
|
||||||
want: &Require{
|
want: &Require{
|
||||||
repo: "git.blocklayer.com/dagger/universe.git",
|
repo: "git.blocklayer.com/dagger/test.git",
|
||||||
path: "",
|
path: "",
|
||||||
version: "main",
|
version: "main",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Custom git provider with folder and version",
|
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{
|
want: &Require{
|
||||||
repo: "git.blocklayer.com/dagger/universe.git",
|
repo: "git.blocklayer.com/dagger/test.git",
|
||||||
path: "/stdlib/alpha.dagger.io/dagger",
|
path: "/test",
|
||||||
version: "v0.1.0",
|
version: "v1.1.0",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Custom git provider with folder and version",
|
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{
|
want: &Require{
|
||||||
repo: "git.blocklayer.com/dagger/universe.git",
|
repo: "git.blocklayer.com/dagger/test.git",
|
||||||
path: "/stdlib",
|
path: "/test",
|
||||||
version: "v5",
|
version: "v1.1.0",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Custom git provider without folder",
|
name: "Custom git provider without folder",
|
||||||
in: "git.blocklayer.com/dagger/universe.git",
|
in: "git.blocklayer.com/dagger/test.git",
|
||||||
want: &Require{
|
want: &Require{
|
||||||
repo: "git.blocklayer.com/dagger/universe.git",
|
repo: "git.blocklayer.com/dagger/test.git",
|
||||||
path: "",
|
path: "",
|
||||||
version: "",
|
version: "",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Custom git provider with folder, no 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{
|
want: &Require{
|
||||||
repo: "git.blocklayer.com/dagger/universe.git",
|
repo: "git.blocklayer.com/dagger/test.git",
|
||||||
path: "/stdlib/alpha.dagger.io/dagger",
|
path: "/test",
|
||||||
version: "",
|
version: "",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -163,15 +163,15 @@ func TestParseArgument(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if got.repo != c.want.repo {
|
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 {
|
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 {
|
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)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user