Skip to content

Commit d981d02

Browse files
scotwellsclaude
andcommitted
test(controller): fix lint (gofmt + goconst) to green the CI Lint job
The Lint job had been red on the branch from pre-existing findings, unrelated to the rename/quota work: - gofmt: re-align a struct in the instance-sizing test. - goconst: extract the repeated "datumcloud/d1-standard-2", "app", and "test/image:latest" literals into test constants. Tests and lint both pass locally. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 472ab81 commit d981d02

1 file changed

Lines changed: 21 additions & 15 deletions

File tree

internal/controller/instance_controller_test.go

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,12 @@ const (
6060

6161
// testMsgQuotaExceeded is the quota-denied message used across quota tests.
6262
testMsgQuotaExceeded = "Quota exceeded for project"
63+
64+
// Catalog instance type, container name, and image used across the
65+
// instance-mapper / sizing tests (extracted to satisfy goconst).
66+
testCatalogInstanceType = "datumcloud/d1-standard-2"
67+
testContainerName = "app"
68+
testContainerImage = "test/image:latest"
6369
)
6470

6571
// newTestScheme builds a runtime.Scheme with the types needed for instance reconcile tests.
@@ -2221,11 +2227,11 @@ func TestResolveInstanceResources(t *testing.T) {
22212227
}
22222228

22232229
tests := []struct {
2224-
name string
2225-
instance *computev1alpha.Instance
2226-
wantCPU int64
2227-
wantMem int64
2228-
wantResolved bool
2230+
name string
2231+
instance *computev1alpha.Instance
2232+
wantCPU int64
2233+
wantMem int64
2234+
wantResolved bool
22292235
}{
22302236
{
22312237
// Common production case: instanceType only, no explicit limits.
@@ -2236,7 +2242,7 @@ func TestResolveInstanceResources(t *testing.T) {
22362242
Spec: computev1alpha.InstanceSpec{
22372243
Runtime: computev1alpha.InstanceRuntimeSpec{
22382244
Resources: computev1alpha.InstanceRuntimeResources{
2239-
InstanceType: "datumcloud/d1-standard-2",
2245+
InstanceType: testCatalogInstanceType,
22402246
},
22412247
},
22422248
},
@@ -2253,13 +2259,13 @@ func TestResolveInstanceResources(t *testing.T) {
22532259
Spec: computev1alpha.InstanceSpec{
22542260
Runtime: computev1alpha.InstanceRuntimeSpec{
22552261
Resources: computev1alpha.InstanceRuntimeResources{
2256-
InstanceType: "datumcloud/d1-standard-2",
2262+
InstanceType: testCatalogInstanceType,
22572263
},
22582264
Sandbox: &computev1alpha.SandboxRuntime{
22592265
Containers: []computev1alpha.SandboxContainer{
22602266
{
2261-
Name: "app",
2262-
Image: "test/image:latest",
2267+
Name: testContainerName,
2268+
Image: testContainerImage,
22632269
Resources: makeContainerResources(cpu500m, mem256Mi),
22642270
},
22652271
{
@@ -2286,8 +2292,8 @@ func TestResolveInstanceResources(t *testing.T) {
22862292
Sandbox: &computev1alpha.SandboxRuntime{
22872293
Containers: []computev1alpha.SandboxContainer{
22882294
{
2289-
Name: "app",
2290-
Image: "test/image:latest",
2295+
Name: testContainerName,
2296+
Image: testContainerImage,
22912297
Resources: makeContainerResources(cpu1, mem512Mi),
22922298
},
22932299
},
@@ -2358,13 +2364,13 @@ func TestResolveInstanceResources(t *testing.T) {
23582364
Spec: computev1alpha.InstanceSpec{
23592365
Runtime: computev1alpha.InstanceRuntimeSpec{
23602366
Resources: computev1alpha.InstanceRuntimeResources{
2361-
InstanceType: "datumcloud/d1-standard-2",
2367+
InstanceType: testCatalogInstanceType,
23622368
},
23632369
Sandbox: &computev1alpha.SandboxRuntime{
23642370
Containers: []computev1alpha.SandboxContainer{
23652371
{
2366-
Name: "app",
2367-
Image: "test/image:latest",
2372+
Name: testContainerName,
2373+
Image: testContainerImage,
23682374
// No Resources.Limits set — common for UKC workloads.
23692375
},
23702376
},
@@ -2429,7 +2435,7 @@ func TestReconcileQuotaClaim_RequestsIncludeVCPUsAndMemory(t *testing.T) {
24292435
Runtime: computev1alpha.InstanceRuntimeSpec{
24302436
Resources: computev1alpha.InstanceRuntimeResources{
24312437
// No Requests, no container Limits — catalog must supply the values.
2432-
InstanceType: "datumcloud/d1-standard-2",
2438+
InstanceType: testCatalogInstanceType,
24332439
},
24342440
},
24352441
NetworkInterfaces: []computev1alpha.InstanceNetworkInterface{},

0 commit comments

Comments
 (0)