File: query_errors.rs

package info (click to toggle)
rust-graphql-parser 0.4.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 588 kB
  • sloc: makefile: 2
file content (30 lines) | stat: -rw-r--r-- 783 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
extern crate graphql_parser;
#[cfg(test)]
#[macro_use]
extern crate pretty_assertions;

use std::fs::File;
use std::io::Read;

use graphql_parser::parse_query;

fn test_error(filename: &str) {
    let mut buf = String::with_capacity(1024);
    let path = format!("tests/query_errors/{}.txt", filename);
    let mut f = File::open(path).unwrap();
    f.read_to_string(&mut buf).unwrap();
    let mut iter = buf.splitn(2, "\n---\n");
    let graphql = iter.next().unwrap();
    let expected = iter.next().expect("file should contain error message");
    let err = parse_query::<String>(graphql).unwrap_err();
    assert_eq!(err.to_string(), expected);
}

#[test]
fn invalid_curly_brace() {
    test_error("invalid_curly_brace");
}
#[test]
fn bad_args() {
    test_error("bad_args");
}