Skip to content

Commit 5dff61f

Browse files
committed
graphman: add tests for graphman create graphql api
1 parent 88093ae commit 5dff61f

File tree

1 file changed

+62
-0
lines changed

1 file changed

+62
-0
lines changed

server/graphman/tests/deployment_mutation.rs

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,3 +266,65 @@ fn graphql_allows_tracking_restart_deployment_executions() {
266266
assert_eq!(resp, expected_resp);
267267
});
268268
}
269+
270+
#[test]
271+
fn graphql_can_create_new_subgraph() {
272+
run_test(|| async {
273+
let resp = send_graphql_request(
274+
json!({
275+
"query": r#"mutation CreateSubgraph {
276+
deployment {
277+
create(name: "subgraph_1") {
278+
success
279+
}
280+
}
281+
}"#
282+
}),
283+
VALID_TOKEN,
284+
)
285+
.await;
286+
287+
let expected_resp = json!({
288+
"data": {
289+
"deployment": {
290+
"create": {
291+
"success": true,
292+
}
293+
}
294+
}
295+
});
296+
297+
assert_eq!(resp, expected_resp);
298+
});
299+
}
300+
301+
#[test]
302+
fn graphql_cannot_create_new_subgraph_with_invalid_name() {
303+
run_test(|| async {
304+
let resp = send_graphql_request(
305+
json!({
306+
"query": r#"mutation CreateInvalidSubgraph {
307+
deployment {
308+
create(name: "*@$%^subgraph") {
309+
success
310+
}
311+
}
312+
}"#
313+
}),
314+
VALID_TOKEN,
315+
)
316+
.await;
317+
318+
let success_resp = json!({
319+
"data": {
320+
"deployment": {
321+
"create": {
322+
"success": true,
323+
}
324+
}
325+
}
326+
});
327+
328+
assert_ne!(resp, success_resp);
329+
});
330+
}

0 commit comments

Comments
 (0)