Skip to content

Commit

Permalink
Updated tests
Browse files Browse the repository at this point in the history
Signed-off-by: nathannaveen <42319948+nathannaveen@users.noreply.github.com>
  • Loading branch information
nathannaveen committed Feb 26, 2024
1 parent 65302e0 commit 5ff7adb
Showing 1 changed file with 37 additions and 35 deletions.
72 changes: 37 additions & 35 deletions internal/testing/backend/search_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,7 @@ func TestFindSoftware(t *testing.T) {
name: "default package",
InPkg: []*model.PkgInputSpec{testdata.P1},
searchText: "tensorflow",
want: []model.PackageSourceOrArtifact{
model.Package{
Type: "pypi",
Namespaces: []*model.PackageNamespace{{
Names: []*model.PackageName{{
Name: "tensorflow",
Versions: []*model.PackageVersion{{
Version: "",
Qualifiers: []*model.PackageQualifier{},
}},
}},
},
},
}},
want: []model.PackageSourceOrArtifact{*testdata.P1out},
},
{
name: "package no match",
Expand All @@ -52,7 +39,7 @@ func TestFindSoftware(t *testing.T) {
InArt: []*model.ArtifactInputSpec{
{
Algorithm: "sha256",
Digest: "testdigest",
Digest: "testdigest", // using a custom digest, so we aren't using testdata.A1
},
},
searchText: "test",
Expand All @@ -75,39 +62,54 @@ func TestFindSoftware(t *testing.T) {
want: []model.PackageSourceOrArtifact{},
},
{
name: "default source",
name: "default source",
InSrc: []*model.SourceInputSpec{testdata.S1},
searchText: "jeff",
want: []model.PackageSourceOrArtifact{*testdata.S1out},
},
{
name: "source no match",
InSrc: []*model.SourceInputSpec{testdata.S1},
searchText: "invalid",
want: []model.PackageSourceOrArtifact{},
},
{
name: "source and package match",
InPkg: []*model.PkgInputSpec{
{
Type: "p",
Name: "sourceAndPackageName",
},
},
InSrc: []*model.SourceInputSpec{
{
Type: "git",
Namespace: "github.com/jeff",
Name: "myrepo",
Type: "s",
Namespace: "testSourceNamespace",
Name: "sourceAndPackageName",
},
},
searchText: "jeff",
searchText: "sourceAndPackage",
want: []model.PackageSourceOrArtifact{
model.Package{
Type: "p",
Namespaces: []*model.PackageNamespace{{
Names: []*model.PackageName{{
Name: "sourceAndPackageName",
Versions: []*model.PackageVersion{{}},
}},
}},
},
model.Source{
Type: "git",
Type: "s",
Namespaces: []*model.SourceNamespace{{
Namespace: "github.com/jeff",
Namespace: "testSourceNamespace",
Names: []*model.SourceName{{
Name: "myrepo",
Name: "sourceAndPackageName",
}},
}},
},
},
},
{
name: "source no match",
InSrc: []*model.SourceInputSpec{
{
Type: "git",
Namespace: "github.com/jeff",
Name: "myrepo",
},
},
searchText: "invalid",
want: []model.PackageSourceOrArtifact{},
},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
Expand Down

0 comments on commit 5ff7adb

Please sign in to comment.