Skip to content

Commit

Permalink
Add tests for module streams
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrewgdewar committed Nov 15, 2024
1 parent 57dcd92 commit 279626c
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 1 deletion.
45 changes: 45 additions & 0 deletions internal/test/integration/rpm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ const testRepoURL = "https://rverdile.fedorapeople.org/dummy-repos/comps/repo1/"
const testRepoURLTwo = "https://rverdile.fedorapeople.org/dummy-repos/comps/repo2/"
const testRepoNameWithErrata = "multiple-errata"
const testRepoURLWithErrata = "https://stephenw.fedorapeople.org/fakerepos/multiple_errata/"
const rpmNameWithModule = "rpm-with-modules"
const rpmUrlWithModule = "https://fixtures.pulpproject.org/rpm-with-modules-modified/"

func (r *RpmSuite) CreateTestRepository(t *testing.T, repoName string, repoUrl string) {
_, err := r.client.LookupOrCreateDomain(r.domainName)
Expand Down Expand Up @@ -372,6 +374,49 @@ func (r *RpmSuite) TestRpmRepositoryVersionErrataListSort() {
assert.Equal(r.T(), total, 6)
}

func (r *RpmSuite) TestRpmRepositoryVersionModuleStreams() {
resp, err := r.client.GetRpmRepositoryByName(r.domainName, testRepoName)
require.NoError(r.T(), err)
firstVersionHref := resp.LatestVersionHref
require.NotNil(r.T(), firstVersionHref)

// expect empty
singleList, total, err := r.tangy.RpmRepositoryVersionModuleStreams(context.Background(), []string{*firstVersionHref}, []string{}, "", tangy.PageOptions{})
require.NoError(r.T(), err)
assert.Empty(r.T(), singleList)
assert.Equal(r.T(), total, 0)

r.CreateTestRepository(r.T(), rpmNameWithModule, rpmUrlWithModule)
resp, err = r.client.GetRpmRepositoryByName(r.domainName, rpmNameWithModule)
require.NoError(r.T(), err)
require.NotNil(r.T(), resp.LatestVersionHref)
firstVersionHref = resp.LatestVersionHref

// Expect populated
singleList, total, err = r.tangy.RpmRepositoryVersionModuleStreams(context.Background(), []string{*firstVersionHref}, []string{}, "", tangy.PageOptions{})
require.NoError(r.T(), err)
assert.NotEmpty(r.T(), singleList)
assert.Equal(r.T(), 3, total)

// Test search
singleList, total, err = r.tangy.RpmRepositoryVersionModuleStreams(context.Background(), []string{*firstVersionHref}, []string{}, "Duck", tangy.PageOptions{})
require.NoError(r.T(), err)
assert.NotEmpty(r.T(), singleList)
assert.Equal(r.T(), 1, total)

// Test package name list filter
singleList, total, err = r.tangy.RpmRepositoryVersionModuleStreams(context.Background(), []string{*firstVersionHref}, []string{"walrus", "kangaroo"}, "", tangy.PageOptions{})
require.NoError(r.T(), err)
assert.NotEmpty(r.T(), singleList)
assert.Equal(r.T(), 2, total)

// Confirm no error on not found rpm name
singleList, total, err = r.tangy.RpmRepositoryVersionModuleStreams(context.Background(), []string{*firstVersionHref}, []string{"banana"}, "", tangy.PageOptions{})
require.NoError(r.T(), err)
assert.Empty(r.T(), singleList)
assert.Equal(r.T(), 0, total)
}

func (r *RpmSuite) TestRpmRepositoryVersionPackageListNameFilter() {
resp, err := r.client.GetRpmRepositoryByName(r.domainName, testRepoName)
require.NoError(r.T(), err)
Expand Down
2 changes: 1 addition & 1 deletion pkg/tangy/rpm.go
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ func (t *tangyImpl) RpmRepositoryVersionModuleStreams(ctx context.Context, hrefs

var countTotal int

err = conn.QueryRow(ctx, countQueryOpen+innerUnion+filter+")", args).Scan(&countTotal)
err = conn.QueryRow(ctx, countQueryOpen+innerUnion+filter+") as list", args).Scan(&countTotal)

if err != nil {
if err == pgx.ErrNoRows {
Expand Down

0 comments on commit 279626c

Please sign in to comment.