Add juniper_tests crate with integration tests
This commit is contained in:
parent
d33db983de
commit
3b42c97a4a
3 changed files with 62 additions and 0 deletions
12
juniper_tests/Cargo.toml
Normal file
12
juniper_tests/Cargo.toml
Normal file
|
@ -0,0 +1,12 @@
|
|||
[package]
|
||||
name = "juniper_tests"
|
||||
version = "0.1.0"
|
||||
|
||||
[dependencies]
|
||||
juniper = { path = "../juniper" }
|
||||
juniper_codegen = { path = "../juniper_codegen" }
|
||||
|
||||
[[test]]
|
||||
name = "integration_tests"
|
||||
path = "src/lib.rs"
|
||||
harness = true
|
46
juniper_tests/src/codegen/mod.rs
Normal file
46
juniper_tests/src/codegen/mod.rs
Normal file
|
@ -0,0 +1,46 @@
|
|||
use std::collections::HashMap;
|
||||
|
||||
use juniper::{self, InputValue, ToInputValue, GraphQLType, FromInputValue};
|
||||
|
||||
#[derive(GraphQLEnum, Debug, PartialEq)]
|
||||
#[graphql(name="Some", description="enum descr")]
|
||||
enum SomeEnum {
|
||||
Regular,
|
||||
|
||||
#[graphql(
|
||||
name="FULL",
|
||||
description="field descr",
|
||||
deprecated="depr"
|
||||
)]
|
||||
Full,
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_derived_enum() {
|
||||
// Ensure that rename works.
|
||||
assert_eq!(SomeEnum::name(), Some("Some"));
|
||||
|
||||
// Ensure validity of meta info.
|
||||
let mut registry = juniper::Registry::new(HashMap::new());
|
||||
let meta = SomeEnum::meta(&mut registry);
|
||||
|
||||
// Test Regular variant.
|
||||
assert_eq!(
|
||||
SomeEnum::Regular.to(),
|
||||
InputValue::String("Regular".into())
|
||||
);
|
||||
assert_eq!(
|
||||
FromInputValue::from(&InputValue::String("Regular".into())),
|
||||
Some(SomeEnum::Regular)
|
||||
);
|
||||
|
||||
// Test FULL variant.
|
||||
assert_eq!(
|
||||
SomeEnum::Full.to(),
|
||||
InputValue::String("FULL".into())
|
||||
);
|
||||
assert_eq!(
|
||||
FromInputValue::from(&InputValue::String("FULL".into())),
|
||||
Some(SomeEnum::Full)
|
||||
);
|
||||
}
|
4
juniper_tests/src/lib.rs
Normal file
4
juniper_tests/src/lib.rs
Normal file
|
@ -0,0 +1,4 @@
|
|||
#[macro_use] extern crate juniper;
|
||||
#[macro_use] extern crate juniper_codegen;
|
||||
|
||||
mod codegen;
|
Loading…
Reference in a new issue