aboutsummaryrefslogtreecommitdiff
path: root/tvsaver/saver2v2/save_package_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'tvsaver/saver2v2/save_package_test.go')
-rw-r--r--tvsaver/saver2v2/save_package_test.go114
1 files changed, 58 insertions, 56 deletions
diff --git a/tvsaver/saver2v2/save_package_test.go b/tvsaver/saver2v2/save_package_test.go
index 72d1de2..f9960f0 100644
--- a/tvsaver/saver2v2/save_package_test.go
+++ b/tvsaver/saver2v2/save_package_test.go
@@ -49,27 +49,29 @@ multi-line external ref comment`,
}
pkg := &spdx.Package2_2{
- PackageName: "p1",
- PackageSPDXIdentifier: spdx.ElementID("p1"),
- PackageVersion: "0.1.0",
- PackageFileName: "p1-0.1.0-master.tar.gz",
- PackageSupplierOrganization: "John Doe, Inc.",
- PackageOriginatorPerson: "John Doe",
- PackageDownloadLocation: "http://example.com/p1/p1-0.1.0-master.tar.gz",
- FilesAnalyzed: true,
- IsFilesAnalyzedTagPresent: true,
- PackageVerificationCode: "0123456789abcdef0123456789abcdef01234567",
- PackageVerificationCodeExcludedFile: "p1-0.1.0.spdx",
- PackageChecksums: map[spdx.ChecksumAlgorithm]spdx.Checksum{
- spdx.SHA1: spdx.Checksum{
+ PackageName: "p1",
+ PackageSPDXIdentifier: spdx.ElementID("p1"),
+ PackageVersion: "0.1.0",
+ PackageFileName: "p1-0.1.0-master.tar.gz",
+ PackageSupplier: &spdx.Supplier{SupplierType: "Organization", Supplier: "John Doe, Inc."},
+ PackageOriginator: &spdx.Originator{Originator: "John Doe", OriginatorType: "Person"},
+ PackageDownloadLocation: "http://example.com/p1/p1-0.1.0-master.tar.gz",
+ FilesAnalyzed: true,
+ IsFilesAnalyzedTagPresent: true,
+ PackageVerificationCode: spdx.PackageVerificationCode{
+ Value: "0123456789abcdef0123456789abcdef01234567",
+ ExcludedFiles: []string{"p1-0.1.0.spdx"},
+ },
+ PackageChecksums: []spdx.Checksum{
+ {
Algorithm: spdx.SHA1,
Value: "85ed0817af83a24ad8da68c2b5094de69833983c",
},
- spdx.SHA256: spdx.Checksum{
+ {
Algorithm: spdx.SHA256,
Value: "11b6d3ee554eedf79299905a98f9b9a04e498210b59f15094c916c91d150efcd",
},
- spdx.MD5: spdx.Checksum{
+ {
Algorithm: spdx.MD5,
Value: "624c1abb3664f4b35547e7c73864ad24",
},
@@ -154,26 +156,26 @@ func TestSaver2_2PackageSavesTextCombo2(t *testing.T) {
// PackageVerificationCodeExcludedFile is empty
pkg := &spdx.Package2_2{
- PackageName: "p1",
- PackageSPDXIdentifier: spdx.ElementID("p1"),
- PackageVersion: "0.1.0",
- PackageFileName: "p1-0.1.0-master.tar.gz",
- PackageSupplierNOASSERTION: true,
- PackageOriginatorOrganization: "John Doe, Inc.",
- PackageDownloadLocation: "http://example.com/p1/p1-0.1.0-master.tar.gz",
- FilesAnalyzed: true,
- IsFilesAnalyzedTagPresent: false,
- PackageVerificationCode: "0123456789abcdef0123456789abcdef01234567",
- PackageChecksums: map[spdx.ChecksumAlgorithm]spdx.Checksum{
- spdx.SHA1: spdx.Checksum{
+ PackageName: "p1",
+ PackageSPDXIdentifier: spdx.ElementID("p1"),
+ PackageVersion: "0.1.0",
+ PackageFileName: "p1-0.1.0-master.tar.gz",
+ PackageSupplier: &spdx.Supplier{Supplier: "NOASSERTION"},
+ PackageOriginator: &spdx.Originator{OriginatorType: "Organization", Originator: "John Doe, Inc."},
+ PackageDownloadLocation: "http://example.com/p1/p1-0.1.0-master.tar.gz",
+ FilesAnalyzed: true,
+ IsFilesAnalyzedTagPresent: false,
+ PackageVerificationCode: spdx.PackageVerificationCode{Value: "0123456789abcdef0123456789abcdef01234567"},
+ PackageChecksums: []spdx.Checksum{
+ {
Algorithm: spdx.SHA1,
Value: "85ed0817af83a24ad8da68c2b5094de69833983c",
},
- spdx.SHA256: spdx.Checksum{
+ {
Algorithm: spdx.SHA256,
Value: "11b6d3ee554eedf79299905a98f9b9a04e498210b59f15094c916c91d150efcd",
},
- spdx.MD5: spdx.Checksum{
+ {
Algorithm: spdx.MD5,
Value: "624c1abb3664f4b35547e7c73864ad24",
},
@@ -245,28 +247,28 @@ func TestSaver2_2PackageSavesTextCombo3(t *testing.T) {
// three PackageAttributionTexts, one with multi-line text
pkg := &spdx.Package2_2{
- PackageName: "p1",
- PackageSPDXIdentifier: spdx.ElementID("p1"),
- PackageVersion: "0.1.0",
- PackageFileName: "p1-0.1.0-master.tar.gz",
- PackageSupplierPerson: "John Doe",
- PackageOriginatorNOASSERTION: true,
- PackageDownloadLocation: "http://example.com/p1/p1-0.1.0-master.tar.gz",
- FilesAnalyzed: false,
- IsFilesAnalyzedTagPresent: true,
+ PackageName: "p1",
+ PackageSPDXIdentifier: spdx.ElementID("p1"),
+ PackageVersion: "0.1.0",
+ PackageFileName: "p1-0.1.0-master.tar.gz",
+ PackageSupplier: &spdx.Supplier{Supplier: "John Doe", SupplierType: "Person"},
+ PackageOriginator: &spdx.Originator{Originator: "NOASSERTION"},
+ PackageDownloadLocation: "http://example.com/p1/p1-0.1.0-master.tar.gz",
+ FilesAnalyzed: false,
+ IsFilesAnalyzedTagPresent: true,
// NOTE that verification code MUST be omitted from output
// since FilesAnalyzed is false
- PackageVerificationCode: "0123456789abcdef0123456789abcdef01234567",
- PackageChecksums: map[spdx.ChecksumAlgorithm]spdx.Checksum{
- spdx.SHA1: spdx.Checksum{
+ PackageVerificationCode: spdx.PackageVerificationCode{Value: "0123456789abcdef0123456789abcdef01234567"},
+ PackageChecksums: []spdx.Checksum{
+ {
Algorithm: spdx.SHA1,
Value: "85ed0817af83a24ad8da68c2b5094de69833983c",
},
- spdx.SHA256: spdx.Checksum{
+ {
Algorithm: spdx.SHA256,
Value: "11b6d3ee554eedf79299905a98f9b9a04e498210b59f15094c916c91d150efcd",
},
- spdx.MD5: spdx.Checksum{
+ {
Algorithm: spdx.MD5,
Value: "624c1abb3664f4b35547e7c73864ad24",
},
@@ -387,29 +389,29 @@ func TestSaver2_2PackageSavesFilesIfPresent(t *testing.T) {
f1 := &spdx.File2_2{
FileName: "/tmp/whatever1.txt",
FileSPDXIdentifier: spdx.ElementID("File1231"),
- FileChecksums: map[spdx.ChecksumAlgorithm]spdx.Checksum{
- spdx.SHA1: spdx.Checksum{
+ Checksums: []spdx.Checksum{
+ {
Algorithm: spdx.SHA1,
Value: "85ed0817af83a24ad8da68c2b5094de69833983c",
},
},
- LicenseConcluded: "Apache-2.0",
- LicenseInfoInFile: []string{"Apache-2.0"},
- FileCopyrightText: "Copyright (c) Jane Doe",
+ LicenseConcluded: "Apache-2.0",
+ LicenseInfoInFiles: []string{"Apache-2.0"},
+ FileCopyrightText: "Copyright (c) Jane Doe",
}
f2 := &spdx.File2_2{
FileName: "/tmp/whatever2.txt",
FileSPDXIdentifier: spdx.ElementID("File1232"),
- FileChecksums: map[spdx.ChecksumAlgorithm]spdx.Checksum{
- spdx.SHA1: spdx.Checksum{
+ Checksums: []spdx.Checksum{
+ {
Algorithm: spdx.SHA1,
Value: "85ed0817af83a24ad8da68c2b5094de69833983d",
},
},
- LicenseConcluded: "MIT",
- LicenseInfoInFile: []string{"MIT"},
- FileCopyrightText: "Copyright (c) John Doe",
+ LicenseConcluded: "MIT",
+ LicenseInfoInFiles: []string{"MIT"},
+ FileCopyrightText: "Copyright (c) John Doe",
}
pkg := &spdx.Package2_2{
@@ -430,9 +432,9 @@ func TestSaver2_2PackageSavesFilesIfPresent(t *testing.T) {
},
PackageLicenseDeclared: "Apache-2.0 OR GPL-2.0-or-later",
PackageCopyrightText: "Copyright (c) John Doe, Inc.",
- Files: map[spdx.ElementID]*spdx.File2_2{
- spdx.ElementID("File1231"): f1,
- spdx.ElementID("File1232"): f2,
+ Files: []*spdx.File2_2{
+ f1,
+ f2,
},
}