aboutsummaryrefslogtreecommitdiff
path: root/tvsaver/saver2v1/save_relationship_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'tvsaver/saver2v1/save_relationship_test.go')
-rw-r--r--tvsaver/saver2v1/save_relationship_test.go30
1 files changed, 30 insertions, 0 deletions
diff --git a/tvsaver/saver2v1/save_relationship_test.go b/tvsaver/saver2v1/save_relationship_test.go
index e8635b1..6fa03bd 100644
--- a/tvsaver/saver2v1/save_relationship_test.go
+++ b/tvsaver/saver2v1/save_relationship_test.go
@@ -62,3 +62,33 @@ func TestSaver2_1RelationshipOmitsOptionalFieldsIfEmpty(t *testing.T) {
t.Errorf("Expected %v, got %v", want.String(), got.String())
}
}
+
+func TestSaver2_1RelationshipWrapsCommentMultiLine(t *testing.T) {
+ rln := &spdx.Relationship2_1{
+ RefA: spdx.MakeDocElementID("", "DOCUMENT"),
+ RefB: spdx.MakeDocElementID("", "2"),
+ Relationship: "DESCRIBES",
+ RelationshipComment: `this is a
+multi-line comment`,
+ }
+
+ // what we want to get, as a buffer of bytes
+ // no trailing blank newline
+ want := bytes.NewBufferString(`Relationship: SPDXRef-DOCUMENT DESCRIBES SPDXRef-2
+RelationshipComment: <text>this is a
+multi-line comment</text>
+`)
+
+ // render as buffer of bytes
+ var got bytes.Buffer
+ err := renderRelationship2_1(rln, &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())
+ }
+}