@@ -32,7 +32,7 @@ func TestDrivesBuilder(t *testing.T) {
3232
3333 drives := NewDrivesBuilder (expectedPath ).Build ()
3434 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 )
3636 }
3737}
3838
@@ -51,7 +51,28 @@ func TestDrivesBuilderWithRootDrive(t *testing.T) {
5151 drives := b .WithRootDrive (expectedPath , WithDriveID ("foo" )).Build ()
5252
5353 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 )
5576 }
5677}
5778
@@ -77,6 +98,13 @@ func TestDrivesBuilderAddDrive(t *testing.T) {
7798 drive .Partuuid = "uuid"
7899 },
79100 },
101+ {
102+ Path : "/5" ,
103+ ReadOnly : true ,
104+ Opt : func (drive * models.Drive ) {
105+ drive .CacheType = String (models .DriveCacheTypeWriteback )
106+ },
107+ },
80108 }
81109 expectedDrives := []models.Drive {
82110 {
@@ -98,6 +126,13 @@ func TestDrivesBuilderAddDrive(t *testing.T) {
98126 IsReadOnly : Bool (false ),
99127 Partuuid : "uuid" ,
100128 },
129+ {
130+ DriveID : String ("3" ),
131+ PathOnHost : String ("/5" ),
132+ IsRootDevice : Bool (false ),
133+ IsReadOnly : Bool (true ),
134+ CacheType : String (models .DriveCacheTypeWriteback ),
135+ },
101136 {
102137 DriveID : String (rootDriveName ),
103138 PathOnHost : & rootPath ,
@@ -117,6 +152,6 @@ func TestDrivesBuilderAddDrive(t *testing.T) {
117152
118153 drives := b .Build ()
119154 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 )
121156 }
122157}
0 commit comments