Skip to content

Commit ec80426

Browse files
committed
Change testTimestamp to handle DBs without nano precision
Signed-off-by: Greg Watts <gwatts@us.ibm.com>
1 parent bad574b commit ec80426

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

vertx-db2-client/src/test/java/io/vertx/db2client/DB2DataTypeTest.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
import java.sql.RowId;
2121
import java.time.LocalDateTime;
22+
import java.time.temporal.ChronoField;
2223
import java.util.Arrays;
2324

2425
import org.junit.Test;
@@ -124,8 +125,10 @@ public void testTimestamp(TestContext ctx) {
124125
.execute(Tuple.of(5), ctx.asyncAssertSuccess(rows -> {
125126
ctx.assertEquals(1, rows.size());
126127
Row row = rows.iterator().next();
128+
int nowNanos = now.getNano() - (1000 * now.get(ChronoField.MICRO_OF_SECOND));
129+
int dbNanos = row.getLocalDateTime(1).getNano() - (1000 * row.getLocalDateTime(1).get(ChronoField.MICRO_OF_SECOND));
127130
ctx.assertEquals(5, row.getInteger(0));
128-
ctx.assertEquals(now, row.getLocalDateTime(1));
131+
ctx.assertEquals(dbNanos > 0 ? now : now.minusNanos(nowNanos), row.getLocalDateTime(1));
129132
}));
130133
}));
131134
}));

0 commit comments

Comments
 (0)