aboutsummaryrefslogtreecommitdiff
path: root/rdfloader/rdfloader_test.go
blob: ed044a8ffd560d4f2082d10af22a122e22212f1c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package rdfloader

import (
	"io"
	"strings"
	"testing"
)

func TestLoad2_2(t *testing.T) {
	var reader io.Reader
	var err error

	// TestCase 1: invalid rdf/xml must raise an error
	reader = strings.NewReader("")
	_, err = Load2_2(reader)
	if err == nil {
		t.Errorf("expected an EOF error reading an empty file, got %v", err)
	}

	// TestCase 2: Valid rdf/xml but invalid spdx document must raise an error
	reader = strings.NewReader(`
		<rdf:RDF
			xmlns:spdx="http://spdx.org/rdf/terms#"
			xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
			xmlns="http://spdx.org/spdxdocs/spdx-example-444504E0-4F89-41D3-9A0C-0305E82C3301#">
		</rdf:RDF>
	`)
	_, err = Load2_2(reader)
	if err == nil {
		t.Errorf("expected an error due to no SpdxDocument Node in the document")
	}
}