Skip to content

Commit

Permalink
add unit test for download with git and package flag
Browse files Browse the repository at this point in the history
Signed-off-by: Asish Kumar <officialasishkumar@gmail.com>
  • Loading branch information
officialasishkumar committed Aug 19, 2024
1 parent a16e457 commit e4a4dd2
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions pkg/client/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,40 @@ func TestDownloadLatestOci(t *testing.T) {
assert.Equal(t, utils.DirExists(filepath.Join(getTestDir("download"), "helloworld")), false)
}

func TestDownloadGitWithPackage(t *testing.T) {
testPath := filepath.Join(getTestDir("download"), "a_random_name")

defer func() {
err := os.RemoveAll(getTestDir("download"))
if err != nil {
t.Errorf("Failed to remove directory: %v", err)
}
}()

err := os.MkdirAll(testPath, 0755)
assert.Equal(t, err, nil)

depFromGit := pkg.Dependency{
Name: "k8s",
Version: "",
Source: downloader.Source{
Git: &downloader.Git{
Url: "https://github.com/kcl-lang/modules.git",
Commit: "bdd4d00a88bc3534ae50affa8328df2927fd2171",
Package: "add-ndots",
},
},
}

kpmcli, err := NewKpmClient()
assert.Equal(t, err, nil)

dep, err := kpmcli.Download(&depFromGit, "", testPath)

assert.Equal(t, err, nil)
assert.Equal(t, dep.Source.Git.Package, "add-ndots")
}

func TestDependencyGraph(t *testing.T) {
testDir := getTestDir("test_dependency_graph")
assert.Equal(t, utils.DirExists(filepath.Join(testDir, "kcl.mod.lock")), false)
Expand Down

0 comments on commit e4a4dd2

Please sign in to comment.