Skip to content

Commit 1ee97d4

Browse files
committed
HYPERFLEET-1017 - refactor: update tests and mocks for LastKnownReconciled rename
The HyperFleet API renamed the aggregated Available condition to LastKnownReconciled. Update all test fixtures, CEL expressions, and the mock API server to match.
1 parent 9517112 commit 1ee97d4

5 files changed

Lines changed: 14 additions & 14 deletions

File tree

internal/client/client_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ func createMockCluster(id string) map[string]interface{} {
4141
"observed_generation": 5,
4242
},
4343
{
44-
"type": "Available",
44+
"type": "LastKnownReconciled",
4545
"status": "True",
4646
"created_time": "2025-01-01T09:00:00Z",
4747
"last_transition_time": "2025-01-01T10:00:00Z",
@@ -587,7 +587,7 @@ func TestFetchResources_NodePools(t *testing.T) {
587587
"observed_generation": 3,
588588
},
589589
{
590-
"type": "Available",
590+
"type": "LastKnownReconciled",
591591
"status": "True",
592592
"created_time": "2025-01-01T09:00:00Z",
593593
"last_transition_time": "2025-01-01T10:00:00Z",

internal/config/config_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -590,7 +590,7 @@ func TestTopologicalSort_NoDependencies(t *testing.T) {
590590
md := &MessageDecisionConfig{
591591
Params: map[string]string{
592592
"a": `condition("Ready").status`,
593-
"b": `condition("Available").status`,
593+
"b": `condition("LastKnownReconciled").status`,
594594
},
595595
Result: "a == b",
596596
}

internal/engine/decision_test.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ func TestDecisionEngine_Evaluate_CustomExpressions(t *testing.T) {
338338
t.Run("condition function with custom condition name", func(t *testing.T) {
339339
cfg := &config.MessageDecisionConfig{
340340
Params: map[string]string{
341-
"is_available": `condition("Available").status == "True"`,
341+
"is_available": `condition("LastKnownReconciled").status == "True"`,
342342
},
343343
Result: "is_available",
344344
}
@@ -353,17 +353,17 @@ func TestDecisionEngine_Evaluate_CustomExpressions(t *testing.T) {
353353
Generation: 1,
354354
Status: client.ResourceStatus{
355355
Conditions: []client.Condition{
356-
{Type: "Available", Status: "True", LastUpdatedTime: now},
356+
{Type: "LastKnownReconciled", Status: "True", LastUpdatedTime: now},
357357
},
358358
},
359359
}
360360

361361
decision := engine.Evaluate(resource, now)
362362
if !decision.ShouldPublish {
363-
t.Error("expected ShouldPublish=true for Available=True condition")
363+
t.Error("expected ShouldPublish=true for LastKnownReconciled=True condition")
364364
}
365365

366-
// Missing Available condition → zero-value → status="" → false
366+
// Missing LastKnownReconciled condition → zero-value → status="" → false
367367
resource2 := &client.Resource{
368368
ID: testResourceID,
369369
Kind: testResourceKind,
@@ -377,7 +377,7 @@ func TestDecisionEngine_Evaluate_CustomExpressions(t *testing.T) {
377377

378378
decision2 := engine.Evaluate(resource2, now)
379379
if decision2.ShouldPublish {
380-
t.Error("expected ShouldPublish=false when Available condition is missing")
380+
t.Error("expected ShouldPublish=false when LastKnownReconciled condition is missing")
381381
}
382382
})
383383
}
@@ -466,7 +466,7 @@ func TestBuildConditionsLookup(t *testing.T) {
466466
ObservedGeneration: 3,
467467
},
468468
{
469-
Type: "Available",
469+
Type: "LastKnownReconciled",
470470
Status: "False",
471471
LastUpdatedTime: now.Add(-5 * time.Minute),
472472
LastTransitionTime: now.Add(-10 * time.Minute),
@@ -491,12 +491,12 @@ func TestBuildConditionsLookup(t *testing.T) {
491491
t.Errorf("Ready observed_generation = %v, want 3", ready["observed_generation"])
492492
}
493493

494-
avail, ok := lookup["Available"]
494+
avail, ok := lookup["LastKnownReconciled"]
495495
if !ok {
496-
t.Fatal("missing Available condition")
496+
t.Fatal("missing LastKnownReconciled condition")
497497
}
498498
if avail["status"] != "False" {
499-
t.Errorf("Available status = %v, want False", avail["status"])
499+
t.Errorf("LastKnownReconciled status = %v, want False", avail["status"])
500500
}
501501
}
502502

test/integration/integration_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ func createMockClusterWithLabels(id string, generation int, observedGeneration i
8686
"conditions": []map[string]interface{}{
8787
readyCondition,
8888
{
89-
"type": "Available",
89+
"type": "LastKnownReconciled",
9090
"status": readyStatus,
9191
"created_time": "2025-01-01T09:00:00Z",
9292
"last_transition_time": "2025-01-01T10:00:00Z",

test/mock-hyperfleet-api/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ func buildConditions(generation int32) []map[string]any {
269269
conditions := []map[string]any{
270270
makeCondition("Ready", "True", "AllAdaptersReady",
271271
"All adapters reported Ready True for the current generation"),
272-
makeCondition("Available", "True", "AllAdaptersAvailable",
272+
makeCondition("LastKnownReconciled", "True", "AllAdaptersAvailable",
273273
"All adapters reported Available True for the same generation"),
274274
}
275275

0 commit comments

Comments
 (0)