mirror of
https://github.com/getcompanion-ai/computer-host.git
synced 2026-04-18 10:03:28 +00:00
feat: nvme disk on m6
This commit is contained in:
parent
54a4c423a6
commit
eb9d2a76df
9 changed files with 240 additions and 22 deletions
|
|
@ -1,6 +1,10 @@
|
|||
package config
|
||||
|
||||
import "testing"
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/getcompanion-ai/computer-host/internal/firecracker"
|
||||
)
|
||||
|
||||
func TestLoadDiskCloneModeDefaultsToReflink(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
|
@ -38,3 +42,73 @@ func TestDiskCloneModeValidate(t *testing.T) {
|
|||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestLoadDriveIOEngineDefaultsToSync(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
if got := loadDriveIOEngine(""); got != firecracker.DriveIOEngineSync {
|
||||
t.Fatalf("drive io engine = %q, want %q", got, firecracker.DriveIOEngineSync)
|
||||
}
|
||||
}
|
||||
|
||||
func TestValidateDriveIOEngine(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
engine firecracker.DriveIOEngine
|
||||
wantErr bool
|
||||
}{
|
||||
{name: "sync", engine: firecracker.DriveIOEngineSync},
|
||||
{name: "async", engine: firecracker.DriveIOEngineAsync},
|
||||
{name: "empty", engine: "", wantErr: true},
|
||||
{name: "unknown", engine: "Aio", wantErr: true},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
err := validateDriveIOEngine(tt.engine)
|
||||
if tt.wantErr && err == nil {
|
||||
t.Fatal("validateDriveIOEngine() error = nil, want error")
|
||||
}
|
||||
if !tt.wantErr && err != nil {
|
||||
t.Fatalf("validateDriveIOEngine() error = %v, want nil", err)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestLoadBool(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
value string
|
||||
want bool
|
||||
wantErr bool
|
||||
}{
|
||||
{name: "default"},
|
||||
{name: "true", value: "true", want: true},
|
||||
{name: "false", value: "false"},
|
||||
{name: "one", value: "1", want: true},
|
||||
{name: "invalid", value: "enabled", wantErr: true},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
envName := "TEST_FIRECRACKER_BOOL"
|
||||
t.Setenv(envName, tt.value)
|
||||
|
||||
got, err := loadBool(envName)
|
||||
if tt.wantErr && err == nil {
|
||||
t.Fatal("loadBool() error = nil, want error")
|
||||
}
|
||||
if !tt.wantErr && err != nil {
|
||||
t.Fatalf("loadBool() error = %v, want nil", err)
|
||||
}
|
||||
if got != tt.want {
|
||||
t.Fatalf("loadBool() = %v, want %v", got, tt.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue