aboutsummaryrefslogtreecommitdiff
path: root/tvsaver/saver2v1/save_file_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'tvsaver/saver2v1/save_file_test.go')
-rw-r--r--tvsaver/saver2v1/save_file_test.go48
1 files changed, 48 insertions, 0 deletions
diff --git a/tvsaver/saver2v1/save_file_test.go b/tvsaver/saver2v1/save_file_test.go
index 9e652b6..9d6b09b 100644
--- a/tvsaver/saver2v1/save_file_test.go
+++ b/tvsaver/saver2v1/save_file_test.go
@@ -247,3 +247,51 @@ Copyright (c) John Doe</text>
t.Errorf("Expected %v, got %v", want.String(), got.String())
}
}
+
+func TestSaver2_1FileWrapsCommentsAndNoticesMultiLine(t *testing.T) {
+ f := &spdx.File2_1{
+ FileName: "/tmp/whatever.txt",
+ FileSPDXIdentifier: spdx.ElementID("File123"),
+ FileChecksumSHA1: "85ed0817af83a24ad8da68c2b5094de69833983c",
+ LicenseComments: `this is a
+multi-line license comment`,
+ LicenseConcluded: "Apache-2.0",
+ LicenseInfoInFile: []string{
+ "Apache-2.0",
+ },
+ FileCopyrightText: "Copyright (c) Jane Doe",
+ FileComment: `this is a
+multi-line file comment`,
+ FileNotice: `This file may be used
+under either Apache-2.0 or Apache-1.1.`,
+ }
+
+ // what we want to get, as a buffer of bytes
+ want := bytes.NewBufferString(`FileName: /tmp/whatever.txt
+SPDXID: SPDXRef-File123
+FileChecksum: SHA1: 85ed0817af83a24ad8da68c2b5094de69833983c
+LicenseConcluded: Apache-2.0
+LicenseInfoInFile: Apache-2.0
+LicenseComments: <text>this is a
+multi-line license comment</text>
+FileCopyrightText: Copyright (c) Jane Doe
+FileComment: <text>this is a
+multi-line file comment</text>
+FileNotice: <text>This file may be used
+under either Apache-2.0 or Apache-1.1.</text>
+
+`)
+
+ // render as buffer of bytes
+ var got bytes.Buffer
+ err := renderFile2_1(f, &got)
+ if err != nil {
+ t.Errorf("Expected nil error, got %v", err)
+ }
+
+ // check that they match
+ c := bytes.Compare(want.Bytes(), got.Bytes())
+ if c != 0 {
+ t.Errorf("Expected %v, got %v", want.String(), got.String())
+ }
+}