Skip to content

Commit f9e40c5

Browse files
committed
Fix failing test cases
1 parent 5094189 commit f9e40c5

2 files changed

Lines changed: 3 additions & 4 deletions

File tree

document-store/src/main/java/org/hypertrace/core/documentstore/postgres/FlatPostgresCollection.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1091,7 +1091,7 @@ private boolean createOrReplaceWithRetry(Key key, Document document, boolean isR
10911091
return executeUpsertReturningIsInsert(sql, parsed);
10921092

10931093
} catch (PSQLException e) {
1094-
return handlePSQLExceptionForUpsert(e, key, document, tableName, isRetry);
1094+
return handlePSQLExceptionForCreateOrReplace(e, key, document, tableName, isRetry);
10951095
} catch (SQLException e) {
10961096
LOGGER.error("SQLException in createOrReplace. key: {} content: {}", key, document, e);
10971097
throw new IOException(e);

document-store/src/test/java/org/hypertrace/core/documentstore/postgres/FlatPostgresCollectionTest.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,6 @@ void testUpsertRetriesOnUndefinedColumn() throws Exception {
265265
PSQLException psqlException = createPSQLException(PSQLState.UNDEFINED_COLUMN);
266266
when(mockPreparedStatement.executeQuery()).thenThrow(psqlException).thenReturn(mockResultSet);
267267
when(mockResultSet.next()).thenReturn(true);
268-
when(mockResultSet.getBoolean("is_insert")).thenReturn(true);
269268

270269
doNothing().when(mockSchemaRegistry).invalidate(COLLECTION_NAME);
271270

@@ -289,13 +288,13 @@ void testUpsertRetriesOnDatatypeMismatch() throws Exception {
289288
PSQLException psqlException = createPSQLException(PSQLState.DATATYPE_MISMATCH);
290289
when(mockPreparedStatement.executeQuery()).thenThrow(psqlException).thenReturn(mockResultSet);
291290
when(mockResultSet.next()).thenReturn(true);
292-
when(mockResultSet.getBoolean("is_insert")).thenReturn(false);
293291

294292
doNothing().when(mockSchemaRegistry).invalidate(COLLECTION_NAME);
295293

296294
boolean result = flatPostgresCollection.upsert(key, document);
297295

298-
assertFalse(result);
296+
// upsert always returns true if it succeeds
297+
assertTrue(result);
299298
verify(mockSchemaRegistry, times(1)).invalidate(COLLECTION_NAME);
300299
verify(mockPreparedStatement, times(2)).executeQuery();
301300
}

0 commit comments

Comments
 (0)