diff options
Diffstat (limited to 'tvsaver/saver2v2/save_document_test.go')
-rw-r--r-- | tvsaver/saver2v2/save_document_test.go | 104 |
1 files changed, 41 insertions, 63 deletions
diff --git a/tvsaver/saver2v2/save_document_test.go b/tvsaver/saver2v2/save_document_test.go index 1970580..552cdab 100644 --- a/tvsaver/saver2v2/save_document_test.go +++ b/tvsaver/saver2v2/save_document_test.go @@ -14,13 +14,8 @@ func TestSaver2_2DocumentSavesText(t *testing.T) { // Creation Info section ci := &spdx.CreationInfo2_2{ - SPDXVersion: "SPDX-2.2", - DataLicense: "CC0-1.0", - SPDXIdentifier: spdx.ElementID("DOCUMENT"), - DocumentName: "tools-golang-0.0.1.abcdef", - DocumentNamespace: "https://github.com/spdx/spdx-docs/tools-golang/tools-golang-0.0.1.abcdef.whatever", - CreatorPersons: []string{ - "John Doe", + Creators: []spdx.Creator{ + {Creator: "John Doe", CreatorType: "Person"}, }, Created: "2018-10-10T06:20:00Z", } @@ -29,51 +24,39 @@ func TestSaver2_2DocumentSavesText(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{ - Algorithm: spdx.SHA1, - Value: "85ed0817af83a24ad8da68c2b5094de69833983c", - }, - }, - LicenseConcluded: "Apache-2.0", - LicenseInfoInFile: []string{"Apache-2.0"}, - FileCopyrightText: "Copyright (c) Jane Doe", + Checksums: []spdx.Checksum{{Value: "85ed0817af83a24ad8da68c2b5094de69833983c", Algorithm: spdx.SHA1}}, + 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{ - Algorithm: spdx.SHA1, - Value: "85ed0817af83a24ad8da68c2b5094de69833983d", - }, - }, - LicenseConcluded: "MIT", - LicenseInfoInFile: []string{"MIT"}, - FileCopyrightText: "Copyright (c) John Doe", + Checksums: []spdx.Checksum{{Value: "85ed0817af83a24ad8da68c2b5094de69833983d", Algorithm: spdx.SHA1}}, + LicenseConcluded: "MIT", + LicenseInfoInFiles: []string{"MIT"}, + FileCopyrightText: "Copyright (c) John Doe", } - unFiles := map[spdx.ElementID]*spdx.File2_2{ - spdx.ElementID("File1231"): f1, - spdx.ElementID("File1232"): f2, + unFiles := []*spdx.File2_2{ + f1, + f2, } // Package 1: packaged files with snippets sn1 := &spdx.Snippet2_2{ SnippetSPDXIdentifier: "Snippet19", - SnippetFromFileSPDXIdentifier: spdx.MakeDocElementID("", "FileHasSnippets"), - SnippetByteRangeStart: 17, - SnippetByteRangeEnd: 209, + SnippetFromFileSPDXIdentifier: spdx.MakeDocElementID("", "FileHasSnippets").ElementRefID, + Ranges: []spdx.SnippetRange{{StartPointer: spdx.SnippetRangePointer{Offset: 17}, EndPointer: spdx.SnippetRangePointer{Offset: 209}}}, SnippetLicenseConcluded: "GPL-2.0-or-later", SnippetCopyrightText: "Copyright (c) John Doe 20x6", } sn2 := &spdx.Snippet2_2{ SnippetSPDXIdentifier: "Snippet20", - SnippetFromFileSPDXIdentifier: spdx.MakeDocElementID("", "FileHasSnippets"), - SnippetByteRangeStart: 268, - SnippetByteRangeEnd: 309, + SnippetFromFileSPDXIdentifier: spdx.MakeDocElementID("", "FileHasSnippets").ElementRefID, + Ranges: []spdx.SnippetRange{{StartPointer: spdx.SnippetRangePointer{Offset: 268}, EndPointer: spdx.SnippetRangePointer{Offset: 309}}}, SnippetLicenseConcluded: "WTFPL", SnippetCopyrightText: "NOASSERTION", } @@ -81,14 +64,9 @@ func TestSaver2_2DocumentSavesText(t *testing.T) { f3 := &spdx.File2_2{ FileName: "/tmp/file-with-snippets.txt", FileSPDXIdentifier: spdx.ElementID("FileHasSnippets"), - FileChecksums: map[spdx.ChecksumAlgorithm]spdx.Checksum{ - spdx.SHA1: spdx.Checksum{ - Algorithm: spdx.SHA1, - Value: "85ed0817af83a24ad8da68c2b5094de69833983e", - }, - }, - LicenseConcluded: "GPL-2.0-or-later AND WTFPL", - LicenseInfoInFile: []string{ + Checksums: []spdx.Checksum{{Value: "85ed0817af83a24ad8da68c2b5094de69833983e", Algorithm: spdx.SHA1}}, + LicenseConcluded: "GPL-2.0-or-later AND WTFPL", + LicenseInfoInFiles: []string{ "Apache-2.0", "GPL-2.0-or-later", "WTFPL", @@ -103,15 +81,10 @@ func TestSaver2_2DocumentSavesText(t *testing.T) { f4 := &spdx.File2_2{ FileName: "/tmp/another-file.txt", FileSPDXIdentifier: spdx.ElementID("FileAnother"), - FileChecksums: map[spdx.ChecksumAlgorithm]spdx.Checksum{ - spdx.SHA1: spdx.Checksum{ - Algorithm: spdx.SHA1, - Value: "85ed0817af83a24ad8da68c2b5094de69833983f", - }, - }, - LicenseConcluded: "BSD-3-Clause", - LicenseInfoInFile: []string{"BSD-3-Clause"}, - FileCopyrightText: "Copyright (c) Jane Doe LLC", + Checksums: []spdx.Checksum{{Value: "85ed0817af83a24ad8da68c2b5094de69833983f", Algorithm: spdx.SHA1}}, + LicenseConcluded: "BSD-3-Clause", + LicenseInfoInFiles: []string{"BSD-3-Clause"}, + FileCopyrightText: "Copyright (c) Jane Doe LLC", } pkgWith := &spdx.Package2_2{ @@ -120,7 +93,7 @@ func TestSaver2_2DocumentSavesText(t *testing.T) { PackageDownloadLocation: "http://example.com/p1/p1-0.1.0-master.tar.gz", FilesAnalyzed: true, IsFilesAnalyzedTagPresent: true, - PackageVerificationCode: "0123456789abcdef0123456789abcdef01234567", + PackageVerificationCode: spdx.PackageVerificationCode{Value: "0123456789abcdef0123456789abcdef01234567"}, PackageLicenseConcluded: "GPL-2.0-or-later AND BSD-3-Clause AND WTFPL", PackageLicenseInfoFromFiles: []string{ "Apache-2.0", @@ -130,9 +103,9 @@ func TestSaver2_2DocumentSavesText(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("FileHasSnippets"): f3, - spdx.ElementID("FileAnother"): f4, + Files: []*spdx.File2_2{ + f3, + f4, }, } @@ -172,8 +145,8 @@ blah blah blah blah`, // Annotations ann1 := &spdx.Annotation2_2{ - Annotator: "John Doe", - AnnotatorType: "Person", + Annotator: spdx.Annotator{Annotator: "John Doe", + AnnotatorType: "Person"}, AnnotationDate: "2018-10-10T17:52:00Z", AnnotationType: "REVIEW", AnnotationSPDXIdentifier: spdx.MakeDocElementID("", "DOCUMENT"), @@ -181,8 +154,8 @@ blah blah blah blah`, } ann2 := &spdx.Annotation2_2{ - Annotator: "John Doe, Inc.", - AnnotatorType: "Organization", + Annotator: spdx.Annotator{Annotator: "John Doe, Inc.", + AnnotatorType: "Organization"}, AnnotationDate: "2018-10-10T17:52:00Z", AnnotationType: "REVIEW", AnnotationSPDXIdentifier: spdx.MakeDocElementID("", "p1"), @@ -204,11 +177,16 @@ blah blah blah blah`, // now, build the document doc := &spdx.Document2_2{ - CreationInfo: ci, - Packages: map[spdx.ElementID]*spdx.Package2_2{ - spdx.ElementID("p1"): pkgWith, + SPDXVersion: "SPDX-2.2", + DataLicense: "CC0-1.0", + SPDXIdentifier: spdx.ElementID("DOCUMENT"), + DocumentName: "tools-golang-0.0.1.abcdef", + DocumentNamespace: "https://github.com/spdx/spdx-docs/tools-golang/tools-golang-0.0.1.abcdef.whatever", + CreationInfo: ci, + Packages: []*spdx.Package2_2{ + pkgWith, }, - UnpackagedFiles: unFiles, + Files: unFiles, OtherLicenses: []*spdx.OtherLicense2_2{ ol1, ol2, |