test: generate a minimal RPM in pure Go instead of a committed fixture
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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user