Skip to content

Commit

Permalink
fix: add unit test case
Browse files Browse the repository at this point in the history
Signed-off-by: zongz <[email protected]>
  • Loading branch information
zong-zhe committed Nov 11, 2024
1 parent 0d08395 commit bf1256f
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions pkg/visitor/visitor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,3 +125,29 @@ func TestVisitedSpace(t *testing.T) {
})
assert.NilError(t, err)
}

func TestVisitedPkgWithDefaultVersion(t *testing.T) {
var buf bytes.Buffer
remotePkgVisitor := RemoteVisitor{
PkgVisitor: &PkgVisitor{
LogWriter: &buf,
Settings: settings.GetSettings(),
},
Downloader: &downloader.DepDownloader{},
}

buf.Reset()
source, err := downloader.NewSourceFromStr("oci://ghcr.io/kcl-lang/helloworld")
if err != nil {
t.Fatal(err)
}

source.ModSpec = &downloader.ModSpec{
Name: "subhelloworld",
}

err = remotePkgVisitor.Visit(source, func(pkg *pkg.KclPkg) error { return nil })
assert.Equal(t, source.ModSpec.Version, "0.0.1")
assert.Equal(t, source.Oci.Tag, "0.1.4")
assert.NilError(t, err)
}

0 comments on commit bf1256f

Please sign in to comment.