File: reader_test.go

package info (click to toggle)
golang-github-spdx-tools-golang 0.5.5-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,252 kB
  • sloc: xml: 428; makefile: 22; ansic: 5; python: 2
file content (32 lines) | stat: -rw-r--r-- 766 bytes parent folder | download
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 rdf

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

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

	// TestCase 1: invalid rdf/xml must raise an error
	reader = strings.NewReader("")
	_, err = Read(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 = Read(reader)
	if err == nil {
		t.Errorf("expected an error due to no SpdxDocument Node in the document")
	}
}