Skip to content

Commit

Permalink
feat: added tests for gitDownload
Browse files Browse the repository at this point in the history
Signed-off-by: Asish Kumar <[email protected]>
  • Loading branch information
officialasishkumar committed May 29, 2024
1 parent aa19024 commit f76ef15
Showing 1 changed file with 30 additions and 4 deletions.
34 changes: 30 additions & 4 deletions pkg/downloader/downloader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,13 @@ func getTestDir(subDir string) string {
}

func TestOciDownloader(t *testing.T) {
path := getTestDir("test_oci")
path_oci := getTestDir("test_oci")
if err := os.MkdirAll(path_oci, os.ModePerm); err != nil {
t.Fatal(err)
}

defer func() {
_ = os.RemoveAll(path)
_ = os.RemoveAll(path_oci)
}()

ociDownloader := OciDownloader{
Expand All @@ -39,9 +42,32 @@ func TestOciDownloader(t *testing.T) {
Tag: "0.0.3",
},
}),
WithLocalPath(path),
WithLocalPath(path_oci),
))

assert.Equal(t, err, nil)
assert.Equal(t, true, utils.DirExists(filepath.Join(path_oci, "artifact.tgz")))

path_git := getTestDir("test_git")
if err := os.MkdirAll(path_oci, os.ModePerm); err != nil {
t.Fatal(err)
}

defer func() {
_ = os.RemoveAll(path_git)
}()

gitDownloader := GitDownloader{}

err = gitDownloader.Download(*NewDownloadOptions(
WithSource(pkg.Source{
Git: &pkg.Git{
Url: "https://github.com/kcl-lang/flask-demo-kcl-manifests.git",
Commit: "ade147b",
},
}),
WithLocalPath(path_git),
))

assert.Equal(t, err, nil)
assert.Equal(t, true, utils.DirExists(filepath.Join(path, "artifact.tgz")))
}

0 comments on commit f76ef15

Please sign in to comment.