@@ -32,7 +32,7 @@ func TestDrivesBuilder(t *testing.T) {
32
32
33
33
drives := NewDrivesBuilder (expectedPath ).Build ()
34
34
if e , a := expectedDrives , drives ; ! reflect .DeepEqual (e , a ) {
35
- t .Errorf ("expected drives %v, but received %v" , e , a )
35
+ t .Errorf ("expected drives %+ v, but received %+ v" , e , a )
36
36
}
37
37
}
38
38
@@ -51,7 +51,28 @@ func TestDrivesBuilderWithRootDrive(t *testing.T) {
51
51
drives := b .WithRootDrive (expectedPath , WithDriveID ("foo" )).Build ()
52
52
53
53
if e , a := expectedDrives , drives ; ! reflect .DeepEqual (e , a ) {
54
- t .Errorf ("expected drives %v, but received %v" , e , a )
54
+ t .Errorf ("expected drives %+v, but received %+v" , e , a )
55
+ }
56
+ }
57
+
58
+ func TestDrivesBuilderWithCacheType (t * testing.T ) {
59
+ expectedPath := "/path/to/rootfs"
60
+ expectedCacheType := models .DriveCacheTypeWriteback
61
+ expectedDrives := []models.Drive {
62
+ {
63
+ DriveID : String ("root_drive" ),
64
+ PathOnHost : & expectedPath ,
65
+ IsRootDevice : Bool (true ),
66
+ IsReadOnly : Bool (false ),
67
+ CacheType : String (expectedCacheType ),
68
+ },
69
+ }
70
+
71
+ b := NewDrivesBuilder (expectedPath )
72
+ drives := b .WithRootDrive (expectedPath , WithDriveID ("root_drive" ), WithCacheType ("Writeback" )).Build ()
73
+
74
+ if e , a := expectedDrives , drives ; ! reflect .DeepEqual (e , a ) {
75
+ t .Errorf ("expected drives %+v, but received %+v" , e , a )
55
76
}
56
77
}
57
78
@@ -77,6 +98,13 @@ func TestDrivesBuilderAddDrive(t *testing.T) {
77
98
drive .Partuuid = "uuid"
78
99
},
79
100
},
101
+ {
102
+ Path : "/5" ,
103
+ ReadOnly : true ,
104
+ Opt : func (drive * models.Drive ) {
105
+ drive .CacheType = String (models .DriveCacheTypeWriteback )
106
+ },
107
+ },
80
108
}
81
109
expectedDrives := []models.Drive {
82
110
{
@@ -98,6 +126,13 @@ func TestDrivesBuilderAddDrive(t *testing.T) {
98
126
IsReadOnly : Bool (false ),
99
127
Partuuid : "uuid" ,
100
128
},
129
+ {
130
+ DriveID : String ("3" ),
131
+ PathOnHost : String ("/5" ),
132
+ IsRootDevice : Bool (false ),
133
+ IsReadOnly : Bool (true ),
134
+ CacheType : String (models .DriveCacheTypeWriteback ),
135
+ },
101
136
{
102
137
DriveID : String (rootDriveName ),
103
138
PathOnHost : & rootPath ,
@@ -117,6 +152,6 @@ func TestDrivesBuilderAddDrive(t *testing.T) {
117
152
118
153
drives := b .Build ()
119
154
if e , a := expectedDrives , drives ; ! reflect .DeepEqual (e , a ) {
120
- t .Errorf ("expected drives %v , but received %v" , e , a )
155
+ t .Errorf ("expected drives %+v \n , but received %+ v" , e , a )
121
156
}
122
157
}
0 commit comments