diff options
author | Brandon Lum <lumjjb@gmail.com> | 2022-07-19 16:43:48 -0400 |
---|---|---|
committer | Brandon Lum <lumjjb@gmail.com> | 2022-07-19 22:43:24 -0400 |
commit | 9ae1bd2f8e0dabb0845f1225b54f23e8f3a429f1 (patch) | |
tree | a43213aadfb9bde3d9ec15634a39305f19ff38b2 /tvsaver/saver2v2/save_document_test.go | |
parent | 41d2272711255f5a25e16e3507ec3318bc550189 (diff) | |
download | spdx-tools-9ae1bd2f8e0dabb0845f1225b54f23e8f3a429f1.tar.gz |
replace all v2_1, v2_2 with new convention
Signed-off-by: Brandon Lum <lumjjb@gmail.com>
Diffstat (limited to 'tvsaver/saver2v2/save_document_test.go')
-rw-r--r-- | tvsaver/saver2v2/save_document_test.go | 113 |
1 files changed, 57 insertions, 56 deletions
diff --git a/tvsaver/saver2v2/save_document_test.go b/tvsaver/saver2v2/save_document_test.go index 552cdab..39146dd 100644 --- a/tvsaver/saver2v2/save_document_test.go +++ b/tvsaver/saver2v2/save_document_test.go @@ -6,65 +6,66 @@ import ( "bytes" "testing" - "github.com/spdx/tools-golang/spdx" + "github.com/spdx/tools-golang/spdx/common" + "github.com/spdx/tools-golang/spdx/v2_2" ) // ===== entire Document Saver tests ===== func TestSaver2_2DocumentSavesText(t *testing.T) { // Creation Info section - ci := &spdx.CreationInfo2_2{ - Creators: []spdx.Creator{ + ci := &v2_2.CreationInfo{ + Creators: []common.Creator{ {Creator: "John Doe", CreatorType: "Person"}, }, Created: "2018-10-10T06:20:00Z", } // unpackaged files - f1 := &spdx.File2_2{ + f1 := &v2_2.File{ FileName: "/tmp/whatever1.txt", - FileSPDXIdentifier: spdx.ElementID("File1231"), - Checksums: []spdx.Checksum{{Value: "85ed0817af83a24ad8da68c2b5094de69833983c", Algorithm: spdx.SHA1}}, + FileSPDXIdentifier: common.ElementID("File1231"), + Checksums: []common.Checksum{{Value: "85ed0817af83a24ad8da68c2b5094de69833983c", Algorithm: common.SHA1}}, LicenseConcluded: "Apache-2.0", LicenseInfoInFiles: []string{"Apache-2.0"}, FileCopyrightText: "Copyright (c) Jane Doe", } - f2 := &spdx.File2_2{ + f2 := &v2_2.File{ FileName: "/tmp/whatever2.txt", - FileSPDXIdentifier: spdx.ElementID("File1232"), - Checksums: []spdx.Checksum{{Value: "85ed0817af83a24ad8da68c2b5094de69833983d", Algorithm: spdx.SHA1}}, + FileSPDXIdentifier: common.ElementID("File1232"), + Checksums: []common.Checksum{{Value: "85ed0817af83a24ad8da68c2b5094de69833983d", Algorithm: common.SHA1}}, LicenseConcluded: "MIT", LicenseInfoInFiles: []string{"MIT"}, FileCopyrightText: "Copyright (c) John Doe", } - unFiles := []*spdx.File2_2{ + unFiles := []*v2_2.File{ f1, f2, } // Package 1: packaged files with snippets - sn1 := &spdx.Snippet2_2{ + sn1 := &v2_2.Snippet{ SnippetSPDXIdentifier: "Snippet19", - SnippetFromFileSPDXIdentifier: spdx.MakeDocElementID("", "FileHasSnippets").ElementRefID, - Ranges: []spdx.SnippetRange{{StartPointer: spdx.SnippetRangePointer{Offset: 17}, EndPointer: spdx.SnippetRangePointer{Offset: 209}}}, + SnippetFromFileSPDXIdentifier: common.MakeDocElementID("", "FileHasSnippets").ElementRefID, + Ranges: []common.SnippetRange{{StartPointer: common.SnippetRangePointer{Offset: 17}, EndPointer: common.SnippetRangePointer{Offset: 209}}}, SnippetLicenseConcluded: "GPL-2.0-or-later", SnippetCopyrightText: "Copyright (c) John Doe 20x6", } - sn2 := &spdx.Snippet2_2{ + sn2 := &v2_2.Snippet{ SnippetSPDXIdentifier: "Snippet20", - SnippetFromFileSPDXIdentifier: spdx.MakeDocElementID("", "FileHasSnippets").ElementRefID, - Ranges: []spdx.SnippetRange{{StartPointer: spdx.SnippetRangePointer{Offset: 268}, EndPointer: spdx.SnippetRangePointer{Offset: 309}}}, + SnippetFromFileSPDXIdentifier: common.MakeDocElementID("", "FileHasSnippets").ElementRefID, + Ranges: []common.SnippetRange{{StartPointer: common.SnippetRangePointer{Offset: 268}, EndPointer: common.SnippetRangePointer{Offset: 309}}}, SnippetLicenseConcluded: "WTFPL", SnippetCopyrightText: "NOASSERTION", } - f3 := &spdx.File2_2{ + f3 := &v2_2.File{ FileName: "/tmp/file-with-snippets.txt", - FileSPDXIdentifier: spdx.ElementID("FileHasSnippets"), - Checksums: []spdx.Checksum{{Value: "85ed0817af83a24ad8da68c2b5094de69833983e", Algorithm: spdx.SHA1}}, + FileSPDXIdentifier: common.ElementID("FileHasSnippets"), + Checksums: []common.Checksum{{Value: "85ed0817af83a24ad8da68c2b5094de69833983e", Algorithm: common.SHA1}}, LicenseConcluded: "GPL-2.0-or-later AND WTFPL", LicenseInfoInFiles: []string{ "Apache-2.0", @@ -72,28 +73,28 @@ func TestSaver2_2DocumentSavesText(t *testing.T) { "WTFPL", }, FileCopyrightText: "Copyright (c) Jane Doe", - Snippets: map[spdx.ElementID]*spdx.Snippet2_2{ - spdx.ElementID("Snippet19"): sn1, - spdx.ElementID("Snippet20"): sn2, + Snippets: map[common.ElementID]*v2_2.Snippet{ + common.ElementID("Snippet19"): sn1, + common.ElementID("Snippet20"): sn2, }, } - f4 := &spdx.File2_2{ + f4 := &v2_2.File{ FileName: "/tmp/another-file.txt", - FileSPDXIdentifier: spdx.ElementID("FileAnother"), - Checksums: []spdx.Checksum{{Value: "85ed0817af83a24ad8da68c2b5094de69833983f", Algorithm: spdx.SHA1}}, + FileSPDXIdentifier: common.ElementID("FileAnother"), + Checksums: []common.Checksum{{Value: "85ed0817af83a24ad8da68c2b5094de69833983f", Algorithm: common.SHA1}}, LicenseConcluded: "BSD-3-Clause", LicenseInfoInFiles: []string{"BSD-3-Clause"}, FileCopyrightText: "Copyright (c) Jane Doe LLC", } - pkgWith := &spdx.Package2_2{ + pkgWith := &v2_2.Package{ PackageName: "p1", - PackageSPDXIdentifier: spdx.ElementID("p1"), + PackageSPDXIdentifier: common.ElementID("p1"), PackageDownloadLocation: "http://example.com/p1/p1-0.1.0-master.tar.gz", FilesAnalyzed: true, IsFilesAnalyzedTagPresent: true, - PackageVerificationCode: spdx.PackageVerificationCode{Value: "0123456789abcdef0123456789abcdef01234567"}, + PackageVerificationCode: common.PackageVerificationCode{Value: "0123456789abcdef0123456789abcdef01234567"}, PackageLicenseConcluded: "GPL-2.0-or-later AND BSD-3-Clause AND WTFPL", PackageLicenseInfoFromFiles: []string{ "Apache-2.0", @@ -103,14 +104,14 @@ func TestSaver2_2DocumentSavesText(t *testing.T) { }, PackageLicenseDeclared: "Apache-2.0 OR GPL-2.0-or-later", PackageCopyrightText: "Copyright (c) John Doe, Inc.", - Files: []*spdx.File2_2{ + Files: []*v2_2.File{ f3, f4, }, } // Other Licenses 1 and 2 - ol1 := &spdx.OtherLicense2_2{ + ol1 := &v2_2.OtherLicense{ LicenseIdentifier: "LicenseRef-1", ExtractedText: `License 1 text blah blah blah @@ -118,57 +119,57 @@ blah blah blah blah`, LicenseName: "License 1", } - ol2 := &spdx.OtherLicense2_2{ + ol2 := &v2_2.OtherLicense{ LicenseIdentifier: "LicenseRef-2", ExtractedText: `License 2 text - this is a license that does some stuff`, LicenseName: "License 2", } // Relationships - rln1 := &spdx.Relationship2_2{ - RefA: spdx.MakeDocElementID("", "DOCUMENT"), - RefB: spdx.MakeDocElementID("", "p1"), + rln1 := &v2_2.Relationship{ + RefA: common.MakeDocElementID("", "DOCUMENT"), + RefB: common.MakeDocElementID("", "p1"), Relationship: "DESCRIBES", } - rln2 := &spdx.Relationship2_2{ - RefA: spdx.MakeDocElementID("", "DOCUMENT"), - RefB: spdx.MakeDocElementID("", "File1231"), + rln2 := &v2_2.Relationship{ + RefA: common.MakeDocElementID("", "DOCUMENT"), + RefB: common.MakeDocElementID("", "File1231"), Relationship: "DESCRIBES", } - rln3 := &spdx.Relationship2_2{ - RefA: spdx.MakeDocElementID("", "DOCUMENT"), - RefB: spdx.MakeDocElementID("", "File1232"), + rln3 := &v2_2.Relationship{ + RefA: common.MakeDocElementID("", "DOCUMENT"), + RefB: common.MakeDocElementID("", "File1232"), Relationship: "DESCRIBES", } // Annotations - ann1 := &spdx.Annotation2_2{ - Annotator: spdx.Annotator{Annotator: "John Doe", + ann1 := &v2_2.Annotation{ + Annotator: common.Annotator{Annotator: "John Doe", AnnotatorType: "Person"}, AnnotationDate: "2018-10-10T17:52:00Z", AnnotationType: "REVIEW", - AnnotationSPDXIdentifier: spdx.MakeDocElementID("", "DOCUMENT"), + AnnotationSPDXIdentifier: common.MakeDocElementID("", "DOCUMENT"), AnnotationComment: "This is an annotation about the SPDX document", } - ann2 := &spdx.Annotation2_2{ - Annotator: spdx.Annotator{Annotator: "John Doe, Inc.", + ann2 := &v2_2.Annotation{ + Annotator: common.Annotator{Annotator: "John Doe, Inc.", AnnotatorType: "Organization"}, AnnotationDate: "2018-10-10T17:52:00Z", AnnotationType: "REVIEW", - AnnotationSPDXIdentifier: spdx.MakeDocElementID("", "p1"), + AnnotationSPDXIdentifier: common.MakeDocElementID("", "p1"), AnnotationComment: "This is an annotation about Package p1", } // Reviews - rev1 := &spdx.Review2_2{ + rev1 := &v2_2.Review{ Reviewer: "John Doe", ReviewerType: "Person", ReviewDate: "2018-10-14T10:28:00Z", } - rev2 := &spdx.Review2_2{ + rev2 := &v2_2.Review{ Reviewer: "Jane Doe LLC", ReviewerType: "Organization", ReviewDate: "2018-10-14T10:28:00Z", @@ -176,31 +177,31 @@ blah blah blah blah`, } // now, build the document - doc := &spdx.Document2_2{ + doc := &v2_2.Document{ SPDXVersion: "SPDX-2.2", DataLicense: "CC0-1.0", - SPDXIdentifier: spdx.ElementID("DOCUMENT"), + SPDXIdentifier: common.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{ + Packages: []*v2_2.Package{ pkgWith, }, Files: unFiles, - OtherLicenses: []*spdx.OtherLicense2_2{ + OtherLicenses: []*v2_2.OtherLicense{ ol1, ol2, }, - Relationships: []*spdx.Relationship2_2{ + Relationships: []*v2_2.Relationship{ rln1, rln2, rln3, }, - Annotations: []*spdx.Annotation2_2{ + Annotations: []*v2_2.Annotation{ ann1, ann2, }, - Reviews: []*spdx.Review2_2{ + Reviews: []*v2_2.Review{ rev1, rev2, }, @@ -332,7 +333,7 @@ ReviewComment: I have reviewed this SPDX document and it is awesome } func TestSaver2_2DocumentReturnsErrorIfNilCreationInfo(t *testing.T) { - doc := &spdx.Document2_2{} + doc := &v2_2.Document{} var got bytes.Buffer err := RenderDocument2_2(doc, &got) |