── buildModifyRequestFromFlags ─────────────────────────────────────────────
(t *testing.T)
| 47 | // ── buildModifyRequestFromFlags ───────────────────────────────────────────── |
| 48 | |
| 49 | func TestBuildModifyRequestFromFlags(t *testing.T) { |
| 50 | specs := modifySpecStore() |
| 51 | |
| 52 | tests := []struct { |
| 53 | name string |
| 54 | instance *api.Instance |
| 55 | flags map[string]string |
| 56 | expectError bool |
| 57 | errorContains string |
| 58 | validate func(t *testing.T, req api.InstanceModifyRequest) |
| 59 | }{ |
| 60 | { |
| 61 | name: "change GPU type within prototyping", |
| 62 | instance: modifyInstance("prototyping", "a6000", "1", "8", 100), |
| 63 | flags: map[string]string{"gpu": "h100"}, |
| 64 | validate: func(t *testing.T, req api.InstanceModifyRequest) { |
| 65 | require.NotNil(t, req.GPUType) |
| 66 | assert.Equal(t, "h100", *req.GPUType) |
| 67 | }, |
| 68 | }, |
| 69 | { |
| 70 | name: "change disk size", |
| 71 | instance: modifyInstance("prototyping", "a6000", "1", "4", 100), |
| 72 | flags: map[string]string{"disk": "200"}, |
| 73 | validate: func(t *testing.T, req api.InstanceModifyRequest) { |
| 74 | require.NotNil(t, req.DiskSizeGB) |
| 75 | assert.Equal(t, 200, *req.DiskSizeGB) |
| 76 | }, |
| 77 | }, |
| 78 | { |
| 79 | name: "disk shrink rejected", |
| 80 | instance: modifyInstance("prototyping", "a6000", "1", "4", 200), |
| 81 | flags: map[string]string{"disk": "150"}, |
| 82 | expectError: true, |
| 83 | errorContains: "cannot be smaller than current size (200 GB)", |
| 84 | }, |
| 85 | { |
| 86 | name: "disk exceeds max", |
| 87 | instance: modifyInstance("prototyping", "a6000", "1", "4", 100), |
| 88 | flags: map[string]string{"disk": "501"}, |
| 89 | expectError: true, |
| 90 | errorContains: "disk size must be between", |
| 91 | }, |
| 92 | { |
| 93 | name: "vcpus for fixed-size spec rejected", |
| 94 | instance: modifyInstance("production", "a100xl", "1", "18", 100), |
| 95 | flags: map[string]string{"vcpus": "18"}, |
| 96 | expectError: true, |
| 97 | errorContains: "vcpus must be one of", |
| 98 | }, |
| 99 | { |
| 100 | name: "invalid vcpus for GPU", |
| 101 | instance: modifyInstance("prototyping", "a6000", "1", "4", 100), |
| 102 | flags: map[string]string{"vcpus": "16"}, |
| 103 | expectError: true, |
| 104 | errorContains: "vcpus must be one of", |
| 105 | }, |
| 106 | { |
nothing calls this directly
no test coverage detected