mirror of
https://github.com/danbulant/oxc
synced 2026-05-24 20:32:10 +00:00
feat(query): adapter invariant test (#644)
Checks for invariants in the adapter that would certainly error out real usage, doesn't actually use the data provided to the adapter
This commit is contained in:
parent
5b0449507e
commit
34f25b7067
1 changed files with 17 additions and 1 deletions
|
|
@ -4,7 +4,7 @@ use oxc_allocator::Allocator;
|
|||
use oxc_parser::Parser;
|
||||
use oxc_semantic::SemanticBuilder;
|
||||
use oxc_span::SourceType;
|
||||
use trustfall::{execute_query, FieldValue, TryIntoStruct};
|
||||
use trustfall::{execute_query, provider::check_adapter_invariants, FieldValue, TryIntoStruct};
|
||||
|
||||
use crate::{adapter::schema, Adapter};
|
||||
|
||||
|
|
@ -205,3 +205,19 @@ query {
|
|||
results
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_invariants() {
|
||||
let file_path = "/apple/orange.tsx";
|
||||
let source_text = "const apple = 1;";
|
||||
|
||||
let allocator = Allocator::default();
|
||||
let source_type = SourceType::from_path(file_path).unwrap();
|
||||
let ret = Parser::new(&allocator, source_text, source_type).parse();
|
||||
let program = allocator.alloc(ret.program);
|
||||
let semantic_ret =
|
||||
SemanticBuilder::new(source_text, source_type).with_trivias(&ret.trivias).build(program);
|
||||
|
||||
let adapter = Adapter { path_components: vec![], semantic: Rc::new(semantic_ret.semantic) };
|
||||
check_adapter_invariants(schema(), &adapter);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue