forked from owulveryck/toscalib
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathservice_template_test.go
53 lines (47 loc) · 1.02 KB
/
service_template_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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package toscalib
import (
"fmt"
"io/ioutil"
"os"
"testing"
)
func TestParse(t *testing.T) {
files, _ := ioutil.ReadDir("./tests")
for _, f := range files {
if !f.IsDir() {
fname := fmt.Sprintf("./tests/%v", f.Name())
var s ServiceTemplateDefinition
o, err := os.Open(fname)
if err != nil {
t.Fatal(err)
}
err = s.Parse(o)
if err != nil {
t.Log("Error in processing", fname)
t.Fatal(err)
}
}
}
}
func TestScalar(t *testing.T) {
var tests []Scalar
// Those test should be ok
tests = []Scalar{"1022.4 h", "1420 s", "12.4 MiB", "0.5 h", "5 Hz"}
for _, test := range tests {
val, err := test.Evaluate()
if err != nil {
t.Errorf("error: %v", err)
}
t.Logf("Scalar value for %v is %v", test, val)
}
// Those tests should be ko
tests = []Scalar{"1022", "qdfsf s", "12.4 G", "1 0.5 h"}
for _, test := range tests {
val, err := test.Evaluate()
if err == nil {
t.Errorf("error: %v", err)
}
t.Logf("Scalar value for %v is %v", test, val)
}
}
func TestEvaluate(t *testing.T) {}