Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ptpaterson committed Oct 14, 2024
1 parent c485371 commit 26d33b8
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,10 @@ public enum Metrics {
QUERY_BYTES_IN("x-query-bytes-in"),
QUERY_BYTES_OUT("x-query-bytes-out"),
QUERY_TIME("x-query-time"),
READ_OPS("x-read-ops"),
STORAGE_BYTES_READ("x-storage-bytes-read"),
STORAGE_BYTES_WRITE("x-storage-bytes-write"),
TXN_RETRIES("x-txn-retries"),
TXN_TIME("x-txn-time"),
WRITE_OPS("x-write-ops");
TXN_TIME("x-txn-time");

private final String metric;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -325,12 +325,10 @@ public void shouldReturnMetricsData() throws Exception {
Optional<String> queryBytesIn = metricsResponse.getMetric(MetricsResponse.Metrics.QUERY_BYTES_IN);
Optional<String> queryBytesOut = metricsResponse.getMetric(MetricsResponse.Metrics.QUERY_BYTES_OUT);
Optional<String> queryTime = metricsResponse.getMetric(MetricsResponse.Metrics.QUERY_TIME);
Optional<String> readOps = metricsResponse.getMetric(MetricsResponse.Metrics.READ_OPS);
Optional<String> storageBytesRead = metricsResponse.getMetric(MetricsResponse.Metrics.STORAGE_BYTES_READ);
Optional<String> storageBytesWrite = metricsResponse.getMetric(MetricsResponse.Metrics.STORAGE_BYTES_WRITE);
Optional<String> txnRetries = metricsResponse.getMetric(MetricsResponse.Metrics.TXN_RETRIES);
Optional<String> txnTime = metricsResponse.getMetric(MetricsResponse.Metrics.TXN_TIME);
Optional<String> writeOps = metricsResponse.getMetric(MetricsResponse.Metrics.WRITE_OPS);

assertThat(byteReadOps.isPresent(), is(true));
assertThat(byteWriteOps.isPresent(), is(true));
Expand All @@ -339,12 +337,10 @@ public void shouldReturnMetricsData() throws Exception {
assertThat(queryBytesIn.isPresent(), is(true));
assertThat(queryBytesOut.isPresent(), is(true));
assertThat(queryTime.isPresent(), is(true));
assertThat(readOps.isPresent(), is(true));
assertThat(storageBytesRead.isPresent(), is(true));
assertThat(storageBytesWrite.isPresent(), is(true));
assertThat(txnRetries.isPresent(), is(true));
assertThat(txnTime.isPresent(), is(true));
assertThat(writeOps.isPresent(), is(true));
}

@Test
Expand Down Expand Up @@ -3171,7 +3167,7 @@ public void streamFailsIfTargetDoesNotExist() throws Exception {
@Test
public void streamFailsIfQueryIsNotReadOnly() throws Exception {
thrown.expectCause(isA(BadRequestException.class));
thrown.expectMessage(containsString("invalid expression: Write effect in read-only query expression."));
thrown.expectMessage(containsString("invalid expression: Call performs a write, which is not allowed in stream requests."));

adminClient.stream(CreateCollection(Collection("spells"))).get();
}
Expand Down
2 changes: 0 additions & 2 deletions faunadb-scala/src/main/scala/faunadb/values/Metrics.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,10 @@ object Metrics extends Enumeration {
val QueryBytesIn = Value("x-query-bytes-in")
val QueryBytesOut = Value("x-query-bytes-out")
val QueryTime = Value("x-query-time")
val ReadOps = Value("x-read-ops")
val StorageBytesRead = Value("x-storage-bytes-read")
val StorageBytesWrite = Value("x-storage-bytes-write")
val TxnRetries = Value("x-txn-retries")
val TxnTime = Value("x-txn-time")
val WriteOps = Value("x-write-ops")

val All = values.toList
}
6 changes: 1 addition & 5 deletions faunadb-scala/src/test/scala/faunadb/ClientSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -524,12 +524,10 @@ class ClientSpec
val queryBytesIn = metricsResponse.getMetric(Metrics.QueryBytesIn)
val queryBytesOut = metricsResponse.getMetric(Metrics.QueryBytesOut)
val queryTime = metricsResponse.getMetric(Metrics.QueryTime)
val readOps = metricsResponse.getMetric(Metrics.ReadOps)
val storageBytesRead = metricsResponse.getMetric(Metrics.StorageBytesRead)
val storageBytesWrite = metricsResponse.getMetric(Metrics.StorageBytesWrite)
val txnRetries = metricsResponse.getMetric(Metrics.TxnRetries)
val txnTime = metricsResponse.getMetric(Metrics.TxnTime)
val writeOps = metricsResponse.getMetric(Metrics.WriteOps)

byteReadOps.isDefined should equal (true)
byteWriteOps.isDefined should equal (true)
Expand All @@ -538,12 +536,10 @@ class ClientSpec
queryBytesIn.isDefined should equal (true)
queryBytesOut.isDefined should equal (true)
queryTime.isDefined should equal (true)
readOps.isDefined should equal (true)
storageBytesRead.isDefined should equal (true)
storageBytesWrite.isDefined should equal (true)
txnRetries.isDefined should equal (true)
txnTime.isDefined should equal (true)
writeOps.isDefined should equal (true)
}

it should "paginate with cursor object" in {
Expand Down Expand Up @@ -2163,7 +2159,7 @@ class ClientSpec
it should "stream return error if the query is not readonly" in {
val err = client.stream(Create(Collection("spells"), Obj("data" -> Obj("testField" -> "testValue0")))).failed.futureValue
err shouldBe a[BadRequestException]
err.getMessage should include("Write effect in read-only query expression.")
err.getMessage should include("Call performs a write, which is not allowed in stream requests.")
}

it should "stream on document reference contains `document` field by default" in {
Expand Down

0 comments on commit 26d33b8

Please sign in to comment.