-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtypes_test.go
31 lines (25 loc) · 936 Bytes
/
types_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
package main
import "testing"
func TestMetadata(t *testing.T) {
labels := make(map[string]string)
nameValue := "name"
namespaceValue := "namespace"
metadata := Metadata{labels, nameValue, namespaceValue}
if len(metadata.Labels) > 0 || metadata.Name != nameValue || metadata.Namespace != namespaceValue {
t.Errorf("faulty struct metadata: %v", metadata)
}
}
func TestResourceConstraint(t *testing.T) {
validConstraint := &ResourceConstraint{"200m", "1000Mi"}
invalidConstraint := &ResourceConstraint{"1000Mi", "200m"}
incompleteConstraint := &ResourceConstraint{"200m", ""}
if validConstraint.Valid() == false {
t.Errorf("must accept valid constraint: %v", validConstraint)
}
if invalidConstraint.Valid() == true {
t.Errorf("must reject invalid constraint: %v", invalidConstraint)
}
if incompleteConstraint.Complete() == true {
t.Errorf("must not accept incomplete constraint: %v", incompleteConstraint)
}
}