@@ -29,27 +29,29 @@ import (
29
29
"github.com/stretchr/testify/assert"
30
30
)
31
31
32
- func Test_StorageClassSpec_Creation (t * testing.T ) {
32
+ // test creation of storage class spec
33
+ func TestStorageClassSpecCreation (t * testing.T ) {
33
34
storageClassSpec := StorageClassSpec {}
34
- assert .True (t , nil != storageClassSpec .Validate ())
35
+ assert .Error (t , storageClassSpec .Validate (), "empty name name is not allowed" )
35
36
36
- storageClassSpec = StorageClassSpec {Name : "TheSpecName" , IsDefault : true } // no upper-case allowed
37
- assert .True (t , nil != storageClassSpec .Validate ())
37
+ storageClassSpec = StorageClassSpec {Name : "TheSpecName" , IsDefault : true }
38
+ assert .Error (t , storageClassSpec .Validate (), "upper case letters are not allowed in resources" )
38
39
39
40
storageClassSpec = StorageClassSpec {"the-spec-name" , true }
40
- assert .Equal ( t , nil , storageClassSpec .Validate ())
41
+ assert .NoError ( t , storageClassSpec .Validate ())
41
42
42
- storageClassSpec = StorageClassSpec {} // this is invalid because it was not created with a proper name
43
- storageClassSpec .SetDefaults ("foo" ) // here the Name is fixed
44
- assert .Equal ( t , nil , storageClassSpec .Validate ())
43
+ storageClassSpec = StorageClassSpec {} // no proper name -> invalid
44
+ storageClassSpec .SetDefaults ("foo" ) // name is fixed -> vaild
45
+ assert .NoError ( t , storageClassSpec .Validate ())
45
46
}
46
47
47
- func Test_StorageClassSpec_ResetImmutableFileds (t * testing.T ) {
48
+ // test reset of storage class spec
49
+ func TestStorageClassSpecResetImmutableFileds (t * testing.T ) {
48
50
specSource := StorageClassSpec {"source" , true }
49
51
specTarget := StorageClassSpec {"target" , true }
50
52
51
53
assert .Equal (t , "target" , specTarget .Name )
52
54
rv := specSource .ResetImmutableFields ("fieldPrefix-" , & specTarget )
53
- assert .Equal (t , "fieldPrefix-name" , strings .Join (rv [:] , ", " ))
55
+ assert .Equal (t , "fieldPrefix-name" , strings .Join (rv , ", " ))
54
56
assert .Equal (t , "source" , specTarget .Name )
55
57
}
0 commit comments