Skip to content

Commit b350621

Browse files
committed
Added API functionality + testing to change engine IO type
Signed-off-by: David Son <[email protected]>
1 parent f0a967e commit b350621

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

drives.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,3 +110,10 @@ func WithCacheType(cacheType string) DriveOpt {
110110
d.CacheType = String(cacheType)
111111
}
112112
}
113+
114+
// WithIoEngine sets the io engine of the drive
115+
func WithIoEngine(ioEngine string) DriveOpt {
116+
return func(d *models.Drive) {
117+
d.IoEngine = String(ioEngine)
118+
}
119+
}

drives_test.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,3 +155,23 @@ func TestDrivesBuilderAddDrive(t *testing.T) {
155155
t.Errorf("expected drives %+v\n, but received %+v", e, a)
156156
}
157157
}
158+
159+
func TestDrivesBuilderWithIoEngine(t *testing.T) {
160+
expectedPath := "/path/to/rootfs"
161+
expectedVal := "Async"
162+
expectedDrives := []models.Drive{
163+
{
164+
DriveID: String(rootDriveName),
165+
PathOnHost: &expectedPath,
166+
IsRootDevice: Bool(true),
167+
IsReadOnly: Bool(false),
168+
IoEngine: &expectedVal,
169+
},
170+
}
171+
172+
drives := NewDrivesBuilder(expectedPath).WithRootDrive(expectedPath,
173+
WithDriveID(string(rootDriveName)), WithIoEngine(expectedVal)).Build()
174+
if e, a := expectedDrives, drives; !reflect.DeepEqual(e, a) {
175+
t.Errorf("expected drives %+v, but received %+v", e, a)
176+
}
177+
}

0 commit comments

Comments
 (0)