forked from owulveryck/toscalib
-
Notifications
You must be signed in to change notification settings - Fork 4
/
parser_test.go
36 lines (29 loc) · 1.13 KB
/
parser_test.go
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
33
34
35
36
package toscalib
import (
"os"
"path/filepath"
"testing"
)
func TestAbsToParseSource(t *testing.T) {
testFiles := []string{"tests/tosca_helloworld.yaml", "tests/refapp/tosca_elk.yaml"}
std := &ServiceTemplateDefinition{}
dir, _ := os.Getwd()
for _, testFile := range testFiles {
if err := std.ParseSource(filepath.Join(dir, testFile), defaultResolver, ParserHooks{ParsedSTD: noop}); err != nil {
t.Errorf("ParseSource:: parsing absolute local TOSCA profile, expected %v, actual %v", nil, err.Error())
}
}
}
func TestRelativeToParseSource(t *testing.T) {
//testing relative local profile parsing with improper imports
testFiles := []string{"tests/refapp/tosca_elk.yaml"}
std := &ServiceTemplateDefinition{}
for _, testFile := range testFiles {
err := std.ParseSource(testFile, defaultResolver, ParserHooks{ParsedSTD: noop})
if err == nil {
t.Error("ParseSource:: parsing relative local TOSCA profile with wrong imports, expected pathError, actual got nil")
} else if !os.IsNotExist(err) {
t.Errorf("ParseSource:: parsing relative local TOSCA profile with wrong imports, expected pathError, actual %v", err.Error())
}
}
}