test: generate a minimal RPM in pure Go instead of a committed fixture
ci/woodpecker/pr/pre-commit Pipeline was successful
ci/woodpecker/pr/test Pipeline was successful
ci/woodpecker/pr/build Pipeline was successful

Removes the committed .rpm binary (gitignored, so it broke clean checkouts)
and the rpmbuild dependency. testsupport.MinimalRPM builds a valid-enough
RPM header in-memory for cavaliergopher/rpm to parse, used by both the rpm
provider test and the full-stack server repodata test.
This commit is contained in:
2026-07-03 14:25:30 +10:00
parent 1009bc7c69
commit 35719984e6
3 changed files with 62 additions and 11 deletions
+2 -7
View File
@@ -7,16 +7,14 @@ import (
"io"
"net/http"
"net/http/httptest"
"os"
"strings"
"testing"
"git.unkin.net/unkin/artifactapi/internal/provider"
"git.unkin.net/unkin/artifactapi/internal/testsupport"
"git.unkin.net/unkin/artifactapi/pkg/models"
)
const fixtureRPM = "testdata/e2e-testpkg-1.0-1.noarch.rpm"
type fakeBlobReader struct{ data []byte }
func (f fakeBlobReader) Download(_ context.Context, _ string) (io.ReadCloser, int64, error) {
@@ -82,10 +80,7 @@ func TestRPMValidateUpload(t *testing.T) {
}
func TestRPMAfterUpload(t *testing.T) {
data, err := os.ReadFile(fixtureRPM)
if err != nil {
t.Fatalf("fixture: %v", err)
}
data := testsupport.MinimalRPM("e2e-testpkg", "1.0", "1", "noarch")
store := &fakeMetaStore{}
(&Provider{}).AfterUpload(context.Background(), "myrepo", "Packages/e2e-testpkg-1.0-1.noarch.rpm",
"sha256:deadbeef", fakeBlobReader{data: data}, store)