Skip to content

Commit

Permalink
Make all GraphQL fixture tests async
Browse files Browse the repository at this point in the history
Reviewed By: josephsavona

Differential Revision: D49868464

fbshipit-source-id: c246dc8f19e89db3c85340f6d778e02b9b9b978d
  • Loading branch information
captbaritone authored and facebook-github-bot committed Oct 3, 2023
1 parent 1ae14fe commit 650dfe4
Show file tree
Hide file tree
Showing 206 changed files with 4,159 additions and 4,099 deletions.
15 changes: 15 additions & 0 deletions compiler/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 compiler/crates/dependency-analyzer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,4 @@ common = { path = "../common" }
fixture-tests = { path = "../fixture-tests" }
intern = { path = "../intern" }
relay-test-schema = { path = "../relay-test-schema" }
tokio = { version = "1.29.1", features = ["full", "test-util", "tracing"] }
2 changes: 1 addition & 1 deletion compiler/crates/dependency-analyzer/tests/ast/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use fixture_tests::Fixture;
use graphql_syntax::*;
use intern::Lookup;

pub fn transform_fixture(fixture: &Fixture<'_>) -> Result<String, String> {
pub async fn transform_fixture(fixture: &Fixture<'_>) -> Result<String, String> {
let parts: Vec<&str> = fixture.content.split("%definitions%").collect();

let source_location = SourceLocationKey::standalone(fixture.file_name);
Expand Down
26 changes: 13 additions & 13 deletions compiler/crates/dependency-analyzer/tests/ast_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,38 +4,38 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<3ecc95204640f547290f1ab25b144c25>>
* @generated SignedSource<<136a8e87899ea84cea0d34b4c2dd6080>>
*/

mod ast;

use ast::transform_fixture;
use fixture_tests::test_fixture;

#[test]
fn base_definitions() {
#[tokio::test]
async fn base_definitions() {
let input = include_str!("ast/fixtures/base-definitions.graphql");
let expected = include_str!("ast/fixtures/base-definitions.expected");
test_fixture(transform_fixture, "base-definitions.graphql", "ast/fixtures/base-definitions.expected", input, expected);
test_fixture(transform_fixture, "base-definitions.graphql", "ast/fixtures/base-definitions.expected", input, expected).await;
}

#[test]
fn definitions_only() {
#[tokio::test]
async fn definitions_only() {
let input = include_str!("ast/fixtures/definitions-only.graphql");
let expected = include_str!("ast/fixtures/definitions-only.expected");
test_fixture(transform_fixture, "definitions-only.graphql", "ast/fixtures/definitions-only.expected", input, expected);
test_fixture(transform_fixture, "definitions-only.graphql", "ast/fixtures/definitions-only.expected", input, expected).await;
}

#[test]
fn missing_fragments() {
#[tokio::test]
async fn missing_fragments() {
let input = include_str!("ast/fixtures/missing-fragments.graphql");
let expected = include_str!("ast/fixtures/missing-fragments.expected");
test_fixture(transform_fixture, "missing-fragments.graphql", "ast/fixtures/missing-fragments.expected", input, expected);
test_fixture(transform_fixture, "missing-fragments.graphql", "ast/fixtures/missing-fragments.expected", input, expected).await;
}

#[test]
fn multiple_base_definitions() {
#[tokio::test]
async fn multiple_base_definitions() {
let input = include_str!("ast/fixtures/multiple-base-definitions.graphql");
let expected = include_str!("ast/fixtures/multiple-base-definitions.expected");
test_fixture(transform_fixture, "multiple-base-definitions.graphql", "ast/fixtures/multiple-base-definitions.expected", input, expected);
test_fixture(transform_fixture, "multiple-base-definitions.graphql", "ast/fixtures/multiple-base-definitions.expected", input, expected).await;
}
2 changes: 1 addition & 1 deletion compiler/crates/dependency-analyzer/tests/ir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ fn format_definition(def: ExecutableDefinition) -> String {
}

// TODO: Test without using snapshot tests
pub fn transform_fixture(fixture: &Fixture<'_>) -> Result<String, String> {
pub async fn transform_fixture(fixture: &Fixture<'_>) -> Result<String, String> {
let parts = fixture.content.split("%extensions%").collect::<Vec<_>>();

let (content, schema): (&str, Arc<SDLSchema>) = match parts.as_slice() {
Expand Down
80 changes: 40 additions & 40 deletions compiler/crates/dependency-analyzer/tests/ir_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,101 +4,101 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<1370ea763208b340fd15717d45729c87>>
* @generated SignedSource<<4d5d37a14a41f5a7598f6291fddd1af5>>
*/

mod ir;

use ir::transform_fixture;
use fixture_tests::test_fixture;

#[test]
fn base_definitions_change_fragment() {
#[tokio::test]
async fn base_definitions_change_fragment() {
let input = include_str!("ir/fixtures/base-definitions-change-fragment.graphql");
let expected = include_str!("ir/fixtures/base-definitions-change-fragment.expected");
test_fixture(transform_fixture, "base-definitions-change-fragment.graphql", "ir/fixtures/base-definitions-change-fragment.expected", input, expected);
test_fixture(transform_fixture, "base-definitions-change-fragment.graphql", "ir/fixtures/base-definitions-change-fragment.expected", input, expected).await;
}

#[test]
fn base_definitions_change_fragment2() {
#[tokio::test]
async fn base_definitions_change_fragment2() {
let input = include_str!("ir/fixtures/base-definitions-change-fragment2.graphql");
let expected = include_str!("ir/fixtures/base-definitions-change-fragment2.expected");
test_fixture(transform_fixture, "base-definitions-change-fragment2.graphql", "ir/fixtures/base-definitions-change-fragment2.expected", input, expected);
test_fixture(transform_fixture, "base-definitions-change-fragment2.graphql", "ir/fixtures/base-definitions-change-fragment2.expected", input, expected).await;
}

#[test]
fn base_definitions_change_query() {
#[tokio::test]
async fn base_definitions_change_query() {
let input = include_str!("ir/fixtures/base-definitions-change-query.graphql");
let expected = include_str!("ir/fixtures/base-definitions-change-query.expected");
test_fixture(transform_fixture, "base-definitions-change-query.graphql", "ir/fixtures/base-definitions-change-query.expected", input, expected);
test_fixture(transform_fixture, "base-definitions-change-query.graphql", "ir/fixtures/base-definitions-change-query.expected", input, expected).await;
}

#[test]
fn definitions_only_change_fragment() {
#[tokio::test]
async fn definitions_only_change_fragment() {
let input = include_str!("ir/fixtures/definitions-only-change-fragment.graphql");
let expected = include_str!("ir/fixtures/definitions-only-change-fragment.expected");
test_fixture(transform_fixture, "definitions-only-change-fragment.graphql", "ir/fixtures/definitions-only-change-fragment.expected", input, expected);
test_fixture(transform_fixture, "definitions-only-change-fragment.graphql", "ir/fixtures/definitions-only-change-fragment.expected", input, expected).await;
}

#[test]
fn definitions_only_change_query() {
#[tokio::test]
async fn definitions_only_change_query() {
let input = include_str!("ir/fixtures/definitions-only-change-query.graphql");
let expected = include_str!("ir/fixtures/definitions-only-change-query.expected");
test_fixture(transform_fixture, "definitions-only-change-query.graphql", "ir/fixtures/definitions-only-change-query.expected", input, expected);
test_fixture(transform_fixture, "definitions-only-change-query.graphql", "ir/fixtures/definitions-only-change-query.expected", input, expected).await;
}

#[test]
fn definitions_only_no_change() {
#[tokio::test]
async fn definitions_only_no_change() {
let input = include_str!("ir/fixtures/definitions-only-no-change.graphql");
let expected = include_str!("ir/fixtures/definitions-only-no-change.expected");
test_fixture(transform_fixture, "definitions-only-no-change.graphql", "ir/fixtures/definitions-only-no-change.expected", input, expected);
test_fixture(transform_fixture, "definitions-only-no-change.graphql", "ir/fixtures/definitions-only-no-change.expected", input, expected).await;
}

#[test]
fn implicit_dependencies_parent_child() {
#[tokio::test]
async fn implicit_dependencies_parent_child() {
let input = include_str!("ir/fixtures/implicit-dependencies-parent-child.graphql");
let expected = include_str!("ir/fixtures/implicit-dependencies-parent-child.expected");
test_fixture(transform_fixture, "implicit-dependencies-parent-child.graphql", "ir/fixtures/implicit-dependencies-parent-child.expected", input, expected);
test_fixture(transform_fixture, "implicit-dependencies-parent-child.graphql", "ir/fixtures/implicit-dependencies-parent-child.expected", input, expected).await;
}

#[test]
fn new_resolver_field() {
#[tokio::test]
async fn new_resolver_field() {
let input = include_str!("ir/fixtures/new-resolver-field.graphql");
let expected = include_str!("ir/fixtures/new-resolver-field.expected");
test_fixture(transform_fixture, "new-resolver-field.graphql", "ir/fixtures/new-resolver-field.expected", input, expected);
test_fixture(transform_fixture, "new-resolver-field.graphql", "ir/fixtures/new-resolver-field.expected", input, expected).await;
}

#[test]
fn new_resolver_model_field() {
#[tokio::test]
async fn new_resolver_model_field() {
let input = include_str!("ir/fixtures/new-resolver-model-field.graphql");
let expected = include_str!("ir/fixtures/new-resolver-model-field.expected");
test_fixture(transform_fixture, "new-resolver-model-field.graphql", "ir/fixtures/new-resolver-model-field.expected", input, expected);
test_fixture(transform_fixture, "new-resolver-model-field.graphql", "ir/fixtures/new-resolver-model-field.expected", input, expected).await;
}

#[test]
fn new_resolver_model_field_with_custom_fragment() {
#[tokio::test]
async fn new_resolver_model_field_with_custom_fragment() {
let input = include_str!("ir/fixtures/new-resolver-model-field-with-custom-fragment.graphql");
let expected = include_str!("ir/fixtures/new-resolver-model-field-with-custom-fragment.expected");
test_fixture(transform_fixture, "new-resolver-model-field-with-custom-fragment.graphql", "ir/fixtures/new-resolver-model-field-with-custom-fragment.expected", input, expected);
test_fixture(transform_fixture, "new-resolver-model-field-with-custom-fragment.graphql", "ir/fixtures/new-resolver-model-field-with-custom-fragment.expected", input, expected).await;
}

#[test]
fn query_then_fragment() {
#[tokio::test]
async fn query_then_fragment() {
let input = include_str!("ir/fixtures/query-then-fragment.graphql");
let expected = include_str!("ir/fixtures/query-then-fragment.expected");
test_fixture(transform_fixture, "query-then-fragment.graphql", "ir/fixtures/query-then-fragment.expected", input, expected);
test_fixture(transform_fixture, "query-then-fragment.graphql", "ir/fixtures/query-then-fragment.expected", input, expected).await;
}

#[test]
fn recursive_fragments() {
#[tokio::test]
async fn recursive_fragments() {
let input = include_str!("ir/fixtures/recursive-fragments.graphql");
let expected = include_str!("ir/fixtures/recursive-fragments.expected");
test_fixture(transform_fixture, "recursive-fragments.graphql", "ir/fixtures/recursive-fragments.expected", input, expected);
test_fixture(transform_fixture, "recursive-fragments.graphql", "ir/fixtures/recursive-fragments.expected", input, expected).await;
}

#[test]
fn transitive_implicit_dependency() {
#[tokio::test]
async fn transitive_implicit_dependency() {
let input = include_str!("ir/fixtures/transitive-implicit-dependency.graphql");
let expected = include_str!("ir/fixtures/transitive-implicit-dependency.expected");
test_fixture(transform_fixture, "transitive-implicit-dependency.graphql", "ir/fixtures/transitive-implicit-dependency.expected", input, expected);
test_fixture(transform_fixture, "transitive-implicit-dependency.graphql", "ir/fixtures/transitive-implicit-dependency.expected", input, expected).await;
}
1 change: 1 addition & 0 deletions compiler/crates/docblock-syntax/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ thiserror = "1.0.43"
[dev-dependencies]
fixture-tests = { path = "../fixture-tests" }
graphql-test-helpers = { path = "../graphql-test-helpers" }
tokio = { version = "1.29.1", features = ["full", "test-util", "tracing"] }
2 changes: 1 addition & 1 deletion compiler/crates/docblock-syntax/tests/parse/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use docblock_syntax::parse_docblock;
use fixture_tests::Fixture;
use graphql_test_helpers::diagnostics_to_sorted_string;

pub fn transform_fixture(fixture: &Fixture<'_>) -> Result<String, String> {
pub async fn transform_fixture(fixture: &Fixture<'_>) -> Result<String, String> {
let mut content = fixture.content;
if !content.starts_with("/*") {
panic!("Expected fixture to start with \"/*\".")
Expand Down
Loading

0 comments on commit 650dfe4

Please sign in to comment.