Skip to content

Commit 1163823

Browse files
committed
fix: tests check prperty ordering
Signed-off-by: Alessio Pragliola <seth.pro@gmail.com>
1 parent 74f3770 commit 1163823

1 file changed

Lines changed: 14 additions & 14 deletions

File tree

catalog/internal/catalog/db_catalog_filterquery_test.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -721,7 +721,8 @@ func TestArtifactFilteringCapability(t *testing.T) {
721721
".name = $",
722722
".double_value <= $",
723723
},
724-
expectedArgs: []any{"ttft_mean", float64(90), "tpot_mean", float64(50)},
724+
// Args order: JOIN property names first, then WHERE value conditions
725+
expectedArgs: []any{"ttft_mean", "tpot_mean", float64(90), float64(50)},
725726
description: "Should handle multiple artifact property filters in a single EXISTS with multiple property JOINs on the SAME artifact",
726727
},
727728
{
@@ -835,20 +836,19 @@ func TestArtifactFilteringCapability(t *testing.T) {
835836
expectedFragment, generatedSQL)
836837
}
837838

838-
// Verify arguments if specified
839+
// Verify arguments if specified - ORDER MATTERS for SQL placeholder mapping
839840
if len(tt.expectedArgs) > 0 {
840-
// Check that all expected args are present (order may vary due to JOINs)
841-
// For numeric values, check value equality regardless of type (int vs float64)
842-
for _, expectedArg := range tt.expectedArgs {
843-
found := false
844-
for _, actualArg := range queryArgs {
845-
if actualArg == expectedArg {
846-
found = true
847-
break
848-
}
849-
}
850-
assert.True(t, found, "Expected argument %v not found in actual args: %v",
851-
expectedArg, queryArgs)
841+
// Args must be in exact order to match SQL placeholders ($1, $2, etc.)
842+
// This is critical for combined artifact filters where JOIN args come before WHERE args
843+
require.Equal(t, len(tt.expectedArgs), len(queryArgs)-1, // -1 for type_id
844+
"Argument count mismatch (excluding type_id)")
845+
846+
// Compare args starting from index 1 (skip type_id at index 0)
847+
for i, expectedArg := range tt.expectedArgs {
848+
actualArg := queryArgs[i+1] // +1 to skip type_id
849+
assert.Equal(t, expectedArg, actualArg,
850+
"Argument at position %d should be %v but was %v. Full args: %v",
851+
i+1, expectedArg, actualArg, queryArgs)
852852
}
853853
}
854854

0 commit comments

Comments
 (0)