Skip to content

Commit 5bf9159

Browse files
isumlutter
authored andcommitted
graphman: do not use hardcoded node id in tests
1 parent c4390a5 commit 5bf9159

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed

server/graphman/src/entities/warning_response.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,15 @@ use async_graphql::SimpleObject;
22

33
#[derive(Clone, Debug, SimpleObject)]
44
pub struct CompletedWithWarnings {
5+
pub success: bool,
56
pub warnings: Vec<String>,
67
}
78

89
impl CompletedWithWarnings {
910
pub fn new(warnings: Vec<String>) -> Self {
10-
Self { warnings }
11+
Self {
12+
success: true,
13+
warnings,
14+
}
1115
}
1216
}

server/graphman/tests/deployment_mutation.rs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@ pub mod util;
22

33
use std::time::Duration;
44

5+
use graph::components::store::SubgraphStore;
56
use graph::prelude::DeploymentHash;
67
use serde::Deserialize;
78
use serde_json::json;
89
use test_store::create_test_subgraph;
10+
use test_store::SUBGRAPH_STORE;
911
use tokio::time::sleep;
1012

1113
use self::util::client::send_graphql_request;
@@ -497,7 +499,7 @@ fn graphql_can_reassign_deployment() {
497499
create_test_subgraph(&deployment_hash, TEST_SUBGRAPH_SCHEMA).await;
498500

499501
let deployment_hash = DeploymentHash::new("subgraph_2").unwrap();
500-
create_test_subgraph(&deployment_hash, TEST_SUBGRAPH_SCHEMA).await;
502+
let locator = create_test_subgraph(&deployment_hash, TEST_SUBGRAPH_SCHEMA).await;
501503

502504
send_graphql_request(
503505
json!({
@@ -513,20 +515,26 @@ fn graphql_can_reassign_deployment() {
513515
)
514516
.await;
515517

518+
let node = SUBGRAPH_STORE.assigned_node(&locator).unwrap().unwrap();
519+
516520
let reassign = send_graphql_request(
517521
json!({
518-
"query": r#"mutation {
522+
"query": r#"mutation ReassignDeployment($node: String!) {
519523
deployment {
520-
reassign(deployment: { hash: "subgraph_1" }, node: "test") {
524+
reassign(deployment: { hash: "subgraph_1" }, node: $node) {
521525
... on EmptyResponse {
522526
success
523527
}
524528
... on CompletedWithWarnings {
529+
success
525530
warnings
526531
}
527532
}
528533
}
529-
}"#
534+
}"#,
535+
"variables": {
536+
"node": node.to_string(),
537+
}
530538
}),
531539
VALID_TOKEN,
532540
)
@@ -561,6 +569,7 @@ fn graphql_warns_reassign_on_wrong_node_id() {
561569
success
562570
}
563571
... on CompletedWithWarnings {
572+
success
564573
warnings
565574
}
566575
}
@@ -575,6 +584,7 @@ fn graphql_warns_reassign_on_wrong_node_id() {
575584
"data": {
576585
"deployment": {
577586
"reassign": {
587+
"success": true,
578588
"warnings": ["This is the only deployment assigned to 'invalid_node'. Please make sure that the node ID is spelled correctly."],
579589
}
580590
}

0 commit comments

Comments
 (0)