Skip to content

Commit e36a1f1

Browse files
committed
Verify time and precision is working as expected. Closes influxdata#44
1 parent 84586ac commit e36a1f1

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

src/test/java/org/influxdb/TicketTests.java

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package org.influxdb;
22

3+
import static org.assertj.core.api.Assertions.assertThat;
4+
35
import java.io.IOException;
46
import java.util.concurrent.TimeUnit;
57
import java.util.logging.Level;
@@ -130,7 +132,6 @@ public void testTicket39() {
130132

131133
/**
132134
* Test for ticket #40
133-
*
134135
*/
135136
@Test(enabled = true)
136137
public void testTicket40() {
@@ -143,4 +144,28 @@ public void testTicket40() {
143144
}
144145
this.influxDB.deleteDatabase(dbName);
145146
}
147+
148+
/**
149+
* Test for ticket #40
150+
*/
151+
@Test(enabled = true)
152+
public void testTicket44() {
153+
Point point = Point.measurement("test").time(1, TimeUnit.MICROSECONDS).field("a", 1).build();
154+
assertThat(point.lineProtocol()).asString().isEqualTo("test a=1 1000");
155+
156+
point = Point.measurement("test").time(1, TimeUnit.MILLISECONDS).field("a", 1).build();
157+
assertThat(point.lineProtocol()).asString().isEqualTo("test a=1 1000000");
158+
159+
point = Point.measurement("test").time(1, TimeUnit.NANOSECONDS).field("a", 1).build();
160+
BatchPoints batchPoints = BatchPoints.database("db").point(point).build();
161+
assertThat(batchPoints.lineProtocol()).asString().isEqualTo("test a=1 1\n");
162+
163+
point = Point.measurement("test").time(1, TimeUnit.MICROSECONDS).field("a", 1).build();
164+
batchPoints = BatchPoints.database("db").point(point).build();
165+
assertThat(batchPoints.lineProtocol()).asString().isEqualTo("test a=1 1000\n");
166+
167+
point = Point.measurement("test").time(1, TimeUnit.MILLISECONDS).field("a", 1).build();
168+
batchPoints = BatchPoints.database("db").point(point).build();
169+
assertThat(batchPoints.lineProtocol()).asString().isEqualTo("test a=1 1000000\n");
170+
}
146171
}

0 commit comments

Comments
 (0)