TestCreateConfigDiskSizeBoundaries verifies that disk size validation correctly enforces the storage range from the GPU spec. The a6000 prototyping spec has StorageGB: {Min: 100, Max: 500}.
(t *testing.T)
| 449 | // correctly enforces the storage range from the GPU spec. |
| 450 | // The a6000 prototyping spec has StorageGB: {Min: 100, Max: 500}. |
| 451 | func TestCreateConfigDiskSizeBoundaries(t *testing.T) { |
| 452 | tests := []struct { |
| 453 | name string |
| 454 | diskSizeGB int |
| 455 | expectError bool |
| 456 | }{ |
| 457 | { |
| 458 | name: "minimum valid disk size", |
| 459 | diskSizeGB: 100, |
| 460 | expectError: false, |
| 461 | }, |
| 462 | { |
| 463 | name: "maximum valid disk size", |
| 464 | diskSizeGB: 500, |
| 465 | expectError: false, |
| 466 | }, |
| 467 | { |
| 468 | name: "disk size too small", |
| 469 | diskSizeGB: 99, |
| 470 | expectError: true, |
| 471 | }, |
| 472 | { |
| 473 | name: "disk size too large", |
| 474 | diskSizeGB: 501, |
| 475 | expectError: true, |
| 476 | }, |
| 477 | } |
| 478 | |
| 479 | for _, tt := range tests { |
| 480 | t.Run(tt.name, func(t *testing.T) { |
| 481 | config := &tui.CreateConfig{ |
| 482 | GPUType: "a6000", |
| 483 | VCPUs: 6, |
| 484 | Template: "ubuntu-22.04", |
| 485 | DiskSizeGB: tt.diskSizeGB, |
| 486 | } |
| 487 | |
| 488 | templates := []api.TemplateEntry{ |
| 489 | tmplEntry("ubuntu-22.04", "Ubuntu 22.04"), |
| 490 | } |
| 491 | |
| 492 | err := validateCreateConfig(config, templates, []api.Snapshot{}, true, testSpecStore()) |
| 493 | |
| 494 | if tt.expectError { |
| 495 | assert.Error(t, err) |
| 496 | assert.Contains(t, err.Error(), "disk size must be between 100 and 500 GB") |
| 497 | } else { |
| 498 | assert.NoError(t, err) |
| 499 | } |
| 500 | }) |
| 501 | } |
| 502 | } |
nothing calls this directly
no test coverage detected