Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pull test data from upstream instead of maintaining a local copy #49

Merged
merged 1 commit into from
Jun 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ jobs:
go-version: ${{ matrix.go-version }}
- name: Checkout code
uses: actions/checkout@v2
- name: Download test data
run: curl -L https://raw.githubusercontent.com/package-url/purl-spec/master/test-suite-data.json -o testdata/test-suite-data.json
- name: Test go fmt
run: test -z $(go fmt ./...)
- name: Golangci-lint
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@

# Project-local glide cache, RE: https://github.com/Masterminds/glide/issues/736
.glide/

testdata/test-suite-data.json
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
.PHONY: test clean lint

test:
curl -Ls https://raw.githubusercontent.com/package-url/purl-spec/master/test-suite-data.json -o testdata/test-suite-data.json
go test -v -cover ./...

lint:
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func main() {
Testing using the normal ``go test`` command. Using ``make test`` will pull the test fixtures shared between all package-url projects and then execute the tests.

```
$ make test
curl -Ls https://raw.githubusercontent.com/package-url/purl-spec/master/test-suite-data.json -o testdata/test-suite-data.json
go test -v -cover ./...
=== RUN TestFromStringExamples
--- PASS: TestFromStringExamples (0.00s)
Expand All @@ -69,6 +69,6 @@ go test -v -cover ./...
=== RUN TestQualifiersMapConversion
--- PASS: TestQualifiersMapConversion (0.00s)
PASS
coverage: 90.7% of statements
github.com/package-url/packageurl-go coverage: 90.7% of statements
ok github.com/package-url/packageurl-go 0.004s coverage: 90.7% of statements
```
7 changes: 4 additions & 3 deletions packageurl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ var qualifiersMapPattern = regexp.MustCompile(`^\{.*\}$`)
// UnmarshalJSON unmarshals the qualifiers field for a TestFixture. The
// qualifiers field is given as a json object such as:
//
// "qualifiers": {"arch": "i386", "distro": "fedora-25"}
// "qualifiers": {"arch": "i386", "distro": "fedora-25"}
//
// This function performs in-order parsing of these values into an OrderedMap to
// preserve items in order of declaration. Note that parsing as a
Expand Down Expand Up @@ -199,8 +199,9 @@ func TestToStringExamples(t *testing.T) {
continue
}
instance := packageurl.NewPackageURL(
tc.PackageType, tc.Namespace, tc.Name,
tc.Version, tc.Qualifiers(), tc.Subpath)
tc.PackageType, tc.Namespace, tc.Name, tc.Version,
// Use QualifiersFromMap so that the qualifiers have a defined order, which is needed for string comparisons
packageurl.QualifiersFromMap(tc.Qualifiers().Map()), tc.Subpath)
result := instance.ToString()

// NOTE: We create a purl with ToString and then load into a PackageURL
Expand Down
Loading