Skip to content

Commit

Permalink
Merge pull request #165 from rainlanguage/2024-01-31-refactor-testinsta
Browse files Browse the repository at this point in the history
2024 01 31 refactor test insta
  • Loading branch information
thedavidmeister authored Feb 1, 2024
2 parents b6ef639 + 28dcc80 commit 28ec407
Show file tree
Hide file tree
Showing 12 changed files with 256 additions and 184 deletions.
47 changes: 47 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ rain_interpreter_parser = { path = "lib/rain.interpreter/crates/parser" }
csv = "1.3.0"
forker = { git = "https://github.com/rainlanguage/forker", rev = "0649c401d8ec489b13bf7bc4a8a05f0950b4b5e0" }
revm-inspectors = "=0.1.0"
insta = { version = "1.34.0" }

[workspace.dependencies.rain_orderbook_bindings]
path = "crates/bindings"
Expand Down
3 changes: 3 additions & 0 deletions crates/subgraph/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,8 @@ alloy-primitives = { workspace = true }
rain_orderbook_bindings = { workspace = true }
csv = { workspace = true }

[dev-dependencies]
insta = { workspace = true }

[build-dependencies]
cynic-codegen = { workspace = true }
65 changes: 2 additions & 63 deletions crates/subgraph/tests/order_test.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use cynic::Id;
use insta::assert_snapshot;
use rain_orderbook_subgraph_client::types::order_detail::{
OrderDetailQuery, OrderDetailQueryVariables,
};
Expand All @@ -10,67 +11,5 @@ fn orders_query_gql_output() {
let id = Id::new("1234");
let request_body = OrderDetailQuery::build(OrderDetailQueryVariables { id: &id });

let expected_query = "query OrderDetailQuery($id: ID!) {
order(id: $id) {
id
owner {
id
}
orderActive
interpreter
interpreterStore
expressionDeployer
expression
timestamp
handleIO
validInputs {
tokenVault {
id
vaultId
vault {
owner {
id
}
}
token {
id
name
symbol
decimals
}
}
}
validOutputs {
tokenVault {
id
vaultId
vault {
owner {
id
}
}
token {
id
name
symbol
decimals
}
}
}
meta {
metaBytes
content {
id
payload
magicNumber
contentType
contentEncoding
contentLanguage
}
}
}
}
";
assert_eq!(request_body.query, expected_query);
assert_snapshot!(request_body.query);
}
51 changes: 2 additions & 49 deletions crates/subgraph/tests/orders_test.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use insta::assert_snapshot;
use rain_orderbook_subgraph_client::types::orders_list::{
OrdersListQuery, OrdersListQueryVariables,
};
Expand All @@ -11,53 +12,5 @@ fn orders_query_gql_output() {
first: Some(10),
});

let expected_query = "query OrdersListQuery($first: Int, $skip: Int) {
orders(orderBy: timestamp, orderDirection: desc, skip: $skip, first: $first) {
id
timestamp
handleIO
orderJSONString
owner {
id
}
orderActive
expression
interpreter
interpreterStore
transaction {
id
}
validInputs {
token {
id
symbol
decimals
}
tokenVault {
id
balance
}
vault {
id
}
}
validOutputs {
token {
id
symbol
decimals
}
tokenVault {
id
balance
}
vault {
id
}
}
}
}
";
assert_eq!(request_body.query, expected_query);
assert_snapshot!(request_body.query);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
---
source: crates/subgraph/tests/order_test.rs
expression: request_body.query
---
query OrderDetailQuery($id: ID!) {
order(id: $id) {
id
owner {
id
}
orderActive
interpreter
interpreterStore
expressionDeployer
expression
timestamp
handleIO
validInputs {
tokenVault {
id
vaultId
vault {
owner {
id
}
}
token {
id
name
symbol
decimals
}
}
}
validOutputs {
tokenVault {
id
vaultId
vault {
owner {
id
}
}
token {
id
name
symbol
decimals
}
}
}
meta {
metaBytes
content {
id
payload
magicNumber
contentType
contentEncoding
contentLanguage
}
}
}
}


Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
---
source: crates/subgraph/tests/orders_test.rs
expression: request_body.query
---
query OrdersListQuery($first: Int, $skip: Int) {
orders(orderBy: timestamp, orderDirection: desc, skip: $skip, first: $first) {
id
timestamp
handleIO
orderJSONString
owner {
id
}
orderActive
expression
interpreter
interpreterStore
transaction {
id
}
validInputs {
token {
id
symbol
decimals
}
tokenVault {
id
balance
}
vault {
id
}
}
validOutputs {
token {
id
symbol
decimals
}
tokenVault {
id
balance
}
vault {
id
}
}
}
}


Loading

0 comments on commit 28ec407

Please sign in to comment.