Skip to content

Commit 70d4163

Browse files
Add E2E test for new command
1 parent 43f864c commit 70d4163

File tree

4 files changed

+175
-2
lines changed

4 files changed

+175
-2
lines changed

Cargo.lock

+145-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,7 @@ git2 = { workspace = true, features = ["https"] }
235235
graphql-schema-diff = "=0.2.0"
236236
httpmock = { workspace = true }
237237
indoc = { workspace = true }
238+
jsonschema = "0.29.0"
238239
mime = "=0.3.17"
239240
mockall = "=0.13.1"
240241
portpicker = "=0.1.1"

tests/e2e/supergraph/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
mod compose;
22
mod fetch;
3+
mod print_json_schema;
+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
use std::process::Command;
2+
3+
use assert_cmd::cargo::CommandCargoExt;
4+
use rstest::rstest;
5+
use tracing::error;
6+
use tracing_test::traced_test;
7+
8+
#[rstest]
9+
#[ignore]
10+
#[tokio::test(flavor = "multi_thread")]
11+
#[traced_test]
12+
async fn e2e_test_rover_supergraph_print_json_schema() {
13+
let mut cmd = Command::cargo_bin("rover").expect("Could not find necessary binary");
14+
cmd.args(["supergraph", "print-json-schema"]);
15+
16+
let output = cmd.output().expect("Could not run command");
17+
if !output.status.success() {
18+
error!("{}", String::from_utf8(output.stderr).unwrap());
19+
panic!("Command did not complete successfully");
20+
}
21+
22+
let output = String::from_utf8(output.stdout).unwrap();
23+
let json_schema = serde_json::from_str(&output).unwrap();
24+
if !jsonschema::meta::is_valid(&json_schema) {
25+
error!("{}", output);
26+
panic!("Could not validate JSON Schema, incorrect schema printed above");
27+
}
28+
}

0 commit comments

Comments
 (0)