Skip to content

Commit f9e5e2e

Browse files
committed
Add simple integration test
1 parent 6e09898 commit f9e5e2e

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

routers/api/packages/pypi/pypi.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,8 @@ func UploadPackageFile(ctx *context.Context) {
147147
homepageURL := ctx.Req.FormValue("home_page")
148148
if len(homepageURL) == 0 {
149149
projectURLs := ctx.Req.Form["project_urls"]
150-
for _, url := range projectURLs {
151-
label, url, found := strings.Cut(url, ",")
150+
for _, purl := range projectURLs {
151+
label, url, found := strings.Cut(purl, ",")
152152
if !found {
153153
continue
154154
}

tests/integration/api_packages_pypi_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ func TestPackagePyPI(t *testing.T) {
3232
packageVersion := "1!1.0.1+r1234"
3333
packageAuthor := "KN4CK3R"
3434
packageDescription := "Test Description"
35+
projectURL := "https://example.com"
3536

3637
content := "test"
3738
hashSHA256 := "9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08"
@@ -51,6 +52,8 @@ func TestPackagePyPI(t *testing.T) {
5152
writer.WriteField("description", packageDescription)
5253
writer.WriteField("sha256_digest", hashSHA256)
5354
writer.WriteField("requires_python", "3.6")
55+
writer.WriteField("project_urls", "DOCUMENTATION , https://readthedocs.org")
56+
writer.WriteField("project_urls", fmt.Sprintf("Home-page, %s", projectURL))
5457

5558
_ = writer.Close()
5659

@@ -74,6 +77,7 @@ func TestPackagePyPI(t *testing.T) {
7477
assert.NoError(t, err)
7578
assert.Nil(t, pd.SemVer)
7679
assert.IsType(t, &pypi.Metadata{}, pd.Metadata)
80+
assert.Equal(t, projectURL, pd.Metadata.(*pypi.Metadata).ProjectURL)
7781
assert.Equal(t, packageName, pd.Package.Name)
7882
assert.Equal(t, packageVersion, pd.Version.Version)
7983

0 commit comments

Comments
 (0)