Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Borys Tkachenko authored and Borys Tkachenko committed Jan 2, 2025
1 parent 64fc236 commit 9329d9c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,19 +94,6 @@ INSERT INTO experiment_items (
;
""";

// private static final String STREAM = """
// SELECT
// *
// FROM experiment_items
// WHERE workspace_id = :workspace_id
// AND experiment_id IN :experiment_ids
// <if(lastRetrievedId)> AND id \\< :lastRetrievedId <endif>
// ORDER BY experiment_id DESC, id DESC, last_updated_at DESC
// LIMIT 1 BY id
// LIMIT :limit
// ;
// """;

private static final String STREAM = """
WITH experiment_items_scope as (
SELECT
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2828,30 +2828,36 @@ private void getAndAssert(ExperimentItem expectedExperimentItem, String workspac
.ignoringFields(ITEM_IGNORED_FIELDS)
.isEqualTo(expectedExperimentItem);

assertIgnoredFields(actualExperimentItem, expectedExperimentItem);
assertIgnoredFields(actualExperimentItem, expectedExperimentItem, false);
}
}

private void assertIgnoredFields(
List<ExperimentItem> actualExperimentItems, List<ExperimentItem> expectedExperimentItems) {
assertThat(actualExperimentItems).hasSameSizeAs(expectedExperimentItems);
for (int i = 0; i < actualExperimentItems.size(); i++) {
assertIgnoredFields(actualExperimentItems.get(i), expectedExperimentItems.get(i));
assertIgnoredFields(actualExperimentItems.get(i), expectedExperimentItems.get(i), true);
}
}

private void assertIgnoredFields(ExperimentItem actualExperimentItem, ExperimentItem expectedExperimentItem) {
assertThat(actualExperimentItem.input()).isEqualTo(expectedExperimentItem.input());
assertThat(actualExperimentItem.output()).isEqualTo(expectedExperimentItem.output());
private void assertIgnoredFields(ExperimentItem actualExperimentItem, ExperimentItem expectedExperimentItem, boolean isFullContent) {
assertThat(actualExperimentItem.createdAt()).isAfter(expectedExperimentItem.createdAt());
assertThat(actualExperimentItem.lastUpdatedAt()).isAfter(expectedExperimentItem.lastUpdatedAt());
assertThat(actualExperimentItem.createdBy()).isEqualTo(USER);
assertThat(actualExperimentItem.lastUpdatedBy()).isEqualTo(USER);
assertThat(actualExperimentItem.feedbackScores())
.usingRecursiveComparison()
.withComparatorForType(BigDecimal::compareTo, BigDecimal.class)
.ignoringCollectionOrder()
.isEqualTo(expectedExperimentItem.feedbackScores());
if (isFullContent) {
assertThat(actualExperimentItem.feedbackScores())
.usingRecursiveComparison()
.withComparatorForType(BigDecimal::compareTo, BigDecimal.class)
.ignoringCollectionOrder()
.isEqualTo(expectedExperimentItem.feedbackScores());
assertThat(actualExperimentItem.input()).isEqualTo(expectedExperimentItem.input());
assertThat(actualExperimentItem.output()).isEqualTo(expectedExperimentItem.output());
} else {
assertThat(actualExperimentItem.input()).isNull();
assertThat(actualExperimentItem.output()).isNull();
assertThat(actualExperimentItem.feedbackScores()).isNull();
}
}

private void getAndAssertNotFound(UUID id, String apiKey, String workspaceName) {
Expand Down

0 comments on commit 9329d9c

Please sign in to comment.