Skip to content

Commit f99e5ee

Browse files
committed
test: add failed query in integration test
Signed-off-by: Gustavo Inacio <[email protected]>
1 parent 59eed9f commit f99e5ee

File tree

2 files changed

+26
-3
lines changed

2 files changed

+26
-3
lines changed

crates/service/tests/router_test.rs

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use test_assets::{
1818
create_signed_receipt, SignedReceiptRequest, INDEXER_ALLOCATIONS, TAP_EIP712_DOMAIN,
1919
};
2020
use tokio::sync::watch;
21-
use tower::ServiceExt;
21+
use tower::Service;
2222
use wiremock::{
2323
matchers::{method, path},
2424
Mock, MockServer, ResponseTemplate,
@@ -95,7 +95,7 @@ async fn full_integration_test(database: PgPool) {
9595
.allocations(allocations)
9696
.build();
9797

98-
let app = router.create_router().await.unwrap();
98+
let mut app = router.create_router().await.unwrap();
9999

100100
let receipt = create_signed_receipt(
101101
SignedReceiptRequest::builder()
@@ -118,12 +118,29 @@ async fn full_integration_test(database: PgPool) {
118118
.unwrap();
119119

120120
// with deployment
121-
let res = app.oneshot(request).await.unwrap();
121+
let res = app.call(request).await.unwrap();
122122
assert_eq!(res.status(), StatusCode::OK);
123123

124124
let graphql_response = res.into_body();
125125
let bytes = to_bytes(graphql_response, usize::MAX).await.unwrap();
126126
let res = String::from_utf8(bytes.into()).unwrap();
127127

128128
insta::assert_snapshot!(res);
129+
130+
let request = Request::builder()
131+
.method(Method::POST)
132+
.uri(format!("/subgraphs/id/{deployment}"))
133+
.body(serde_json::to_string(&query).unwrap())
134+
.unwrap();
135+
136+
// without tap receipt
137+
let res = app.call(request).await.unwrap();
138+
139+
assert_eq!(res.status(), StatusCode::PAYMENT_REQUIRED);
140+
141+
let graphql_response = res.into_body();
142+
let bytes = to_bytes(graphql_response, usize::MAX).await.unwrap();
143+
let res = String::from_utf8(bytes.into()).unwrap();
144+
145+
insta::assert_snapshot!(res);
129146
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
source: crates/service/tests/router_test.rs
3+
expression: res
4+
snapshot_kind: text
5+
---
6+
{"message":"No Tap receipt was found in the request"}

0 commit comments

Comments
 (0)