-
Notifications
You must be signed in to change notification settings - Fork 6
/
plan_test.go
40 lines (35 loc) · 1.03 KB
/
plan_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
package tweed_test
import (
"testing"
"github.com/tweedproject/tweed"
)
func TestPlanInputValidation(t *testing.T) {
p := tweed.Plan{}
p.Tweed.Params = map[string]tweed.Parameter{
"disk": tweed.Parameter{
Type: "bytes",
Minimum: "1Gi",
Maximum: "100Gi",
},
"cpu": tweed.Parameter{
Type: "number",
Minimum: "1",
Maximum: "4",
},
}
if err := p.ValidateInputs(map[string]string{"disk": "5Gi"}); err != nil {
t.Errorf("input validation fails: %s", err)
}
if err := p.ValidateInputs(map[string]string{"disk": "5Gi", "cpu": "2"}); err != nil {
t.Errorf("input validation fails: %s", err)
}
if err := p.ValidateInputs(map[string]string{"disk": "2Ti"}); err == nil {
t.Errorf("input validation DOES NOT fail: (no error)")
}
if err := p.ValidateInputs(map[string]string{"disk": "2Ti", "cpu": "8"}); err == nil {
t.Errorf("input validation DOES NOT fail: (no error)")
}
if err := p.ValidateInputs(map[string]string{"ram": "80Gi"}); err == nil {
t.Errorf("input validation DOES NOT fail: (no error)")
}
}