feat: add integration test infra and bootstrapper updates
This commit is contained in:
@@ -38,9 +38,6 @@ func TestInvalidOptionCombinations(t *testing.T) {
|
||||
if _, err := ParseOptions([]string{"--only", "wsl", "--no-wsl"}, &bytes.Buffer{}); err == nil {
|
||||
t.Fatal("expected --only wsl --no-wsl to fail")
|
||||
}
|
||||
if _, err := ParseOptions([]string{"--headless"}, &bytes.Buffer{}); err == nil {
|
||||
t.Fatal("expected --headless without --yes or --dry-run to fail")
|
||||
}
|
||||
if _, err := ParseOptions([]string{"--only", "bogus"}, &bytes.Buffer{}); err == nil {
|
||||
t.Fatal("expected invalid --only value to fail")
|
||||
}
|
||||
@@ -52,29 +49,86 @@ func TestInvalidOptionCombinations(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestParseOptionsAcceptsHeadlessWithDryRunAndCustomRepo(t *testing.T) {
|
||||
opts, err := ParseOptions([]string{"--headless", "--dry-run", "--linux-release-repo", "owner/repo"}, &bytes.Buffer{})
|
||||
func TestNvidiaOptions(t *testing.T) {
|
||||
// Valid combinations
|
||||
opts, err := ParseOptions([]string{"--nvidia", "--model", "RTX 4090", "--type", "Studio"}, &bytes.Buffer{})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !opts.Headless || !opts.DryRun || opts.LinuxReleaseRepo != "owner/repo" {
|
||||
t.Fatalf("opts = %#v", opts)
|
||||
if !opts.Nvidia || opts.NvidiaModel != "RTX 4090" || opts.NvidiaType != "Studio" {
|
||||
t.Fatal("Nvidia options not parsed correctly")
|
||||
}
|
||||
}
|
||||
|
||||
func TestParseOptionsAcceptsNoRestorePoints(t *testing.T) {
|
||||
opts, err := ParseOptions([]string{"--yes", "--no-restore-points"}, &bytes.Buffer{})
|
||||
opts, err = ParseOptions([]string{"--nvidia", "--model", "RTX 4090", "--type", "Game Ready"}, &bytes.Buffer{})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !opts.NoRestorePoints {
|
||||
t.Fatalf("expected NoRestorePoints to be set: %#v", opts)
|
||||
if !opts.Nvidia || opts.NvidiaModel != "RTX 4090" || opts.NvidiaType != "Game Ready" {
|
||||
t.Fatal("Nvidia options not parsed correctly")
|
||||
}
|
||||
defaults, err := ParseOptions(nil, &bytes.Buffer{})
|
||||
|
||||
// Missing model
|
||||
if _, err := ParseOptions([]string{"--nvidia", "--type", "Studio"}, &bytes.Buffer{}); err == nil {
|
||||
t.Fatal("expected error when model is missing")
|
||||
}
|
||||
|
||||
// Missing type
|
||||
if _, err := ParseOptions([]string{"--nvidia", "--model", "RTX 4090"}, &bytes.Buffer{}); err == nil {
|
||||
t.Fatal("expected error when type is missing")
|
||||
}
|
||||
|
||||
// Invalid type
|
||||
if _, err := ParseOptions([]string{"--nvidia", "--model", "RTX 4090", "--type", "Other"}, &bytes.Buffer{}); err == nil {
|
||||
t.Fatal("expected error with invalid type")
|
||||
}
|
||||
|
||||
// Subflags passed without --nvidia
|
||||
if _, err := ParseOptions([]string{"--model", "RTX 4090"}, &bytes.Buffer{}); err == nil {
|
||||
t.Fatal("expected error when --model passed without --nvidia")
|
||||
}
|
||||
if _, err := ParseOptions([]string{"--type", "Studio"}, &bytes.Buffer{}); err == nil {
|
||||
t.Fatal("expected error when --type passed without --nvidia")
|
||||
}
|
||||
|
||||
// AMD options
|
||||
opts, err = ParseOptions([]string{"--amd"}, &bytes.Buffer{})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if defaults.NoRestorePoints {
|
||||
t.Fatal("NoRestorePoints should default to false")
|
||||
if !opts.Amd {
|
||||
t.Fatal("AMD option not parsed correctly")
|
||||
}
|
||||
|
||||
// AMD and Nvidia together (should succeed)
|
||||
opts, err = ParseOptions([]string{"--nvidia", "--model", "RTX 4090", "--type", "Studio", "--amd"}, &bytes.Buffer{})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !opts.Nvidia || opts.NvidiaModel != "RTX 4090" || opts.NvidiaType != "Studio" || !opts.Amd {
|
||||
t.Fatal("AMD and Nvidia options combined not parsed correctly")
|
||||
}
|
||||
|
||||
// AMD, Nvidia and Intel conflict (all three should fail by default)
|
||||
if _, err := ParseOptions([]string{"--nvidia", "--model", "RTX 4090", "--type", "Studio", "--amd", "--intel"}, &bytes.Buffer{}); err == nil {
|
||||
t.Fatal("expected error when --nvidia, --amd, and --intel are all passed")
|
||||
}
|
||||
|
||||
// AMD, Nvidia and Intel combined with BOOTSTRAP_INTEGRATION_TEST=true (should succeed)
|
||||
t.Setenv("BOOTSTRAP_INTEGRATION_TEST", "true")
|
||||
opts, err = ParseOptions([]string{"--nvidia", "--model", "RTX 4090", "--type", "Studio", "--amd", "--intel"}, &bytes.Buffer{})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !opts.Nvidia || !opts.Amd || !opts.Intel {
|
||||
t.Fatal("All three options combined not parsed correctly under integration test context")
|
||||
}
|
||||
|
||||
// Intel options
|
||||
opts, err = ParseOptions([]string{"--intel"}, &bytes.Buffer{})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !opts.Intel {
|
||||
t.Fatal("Intel option not parsed correctly")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user