Skip to content

Commit 0adbbb2

Browse files
committed
fix: add better testing
1 parent 1b730fa commit 0adbbb2

File tree

2 files changed

+104
-1
lines changed

2 files changed

+104
-1
lines changed

src/core/config/config.rs

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -566,7 +566,7 @@ impl Config {
566566
interfaces_types_map.insert(interface_name.clone(), types_set);
567567
}
568568

569-
interfaces_types
569+
interfaces_types_map
570570
}
571571

572572
/// Returns a list of all the arguments in the configuration
@@ -821,4 +821,54 @@ mod tests {
821821
.collect();
822822
assert_eq!(union_types, expected_union_types);
823823
}
824+
825+
#[test]
826+
fn test_interfaces_types_map() {
827+
let sdl = std::fs::read_to_string(tailcall_fixtures::configs::INTERFACE_CONFIG).unwrap();
828+
let config = Config::from_sdl(&sdl).to_result().unwrap();
829+
let interfaces_types_map = config.interfaces_types_map();
830+
831+
let mut expected_union_types = BTreeMap::new();
832+
833+
{
834+
let mut set = BTreeSet::new();
835+
set.insert("E".to_string());
836+
set.insert("F".to_string());
837+
expected_union_types.insert("T0".to_string(), set);
838+
}
839+
840+
{
841+
let mut set = BTreeSet::new();
842+
set.insert("A".to_string());
843+
set.insert("E".to_string());
844+
set.insert("B".to_string());
845+
set.insert("C".to_string());
846+
set.insert("D".to_string());
847+
expected_union_types.insert("T1".to_string(), set);
848+
}
849+
850+
{
851+
let mut set = BTreeSet::new();
852+
set.insert("B".to_string());
853+
set.insert("E".to_string());
854+
set.insert("D".to_string());
855+
expected_union_types.insert("T2".to_string(), set);
856+
}
857+
858+
{
859+
let mut set = BTreeSet::new();
860+
set.insert("C".to_string());
861+
set.insert("E".to_string());
862+
set.insert("D".to_string());
863+
expected_union_types.insert("T3".to_string(), set);
864+
}
865+
866+
{
867+
let mut set = BTreeSet::new();
868+
set.insert("D".to_string());
869+
expected_union_types.insert("T4".to_string(), set);
870+
}
871+
872+
assert_eq!(interfaces_types_map, expected_union_types);
873+
}
824874
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
schema @server {
2+
query: Query
3+
}
4+
5+
interface T0 {
6+
id: Int!
7+
}
8+
9+
interface T1 {
10+
id: Int!
11+
}
12+
13+
interface T2 implements T1 {
14+
id: Int!
15+
}
16+
17+
interface T3 implements T1 {
18+
id: Int!
19+
}
20+
21+
interface T4 implements T2 & T3 & T1 {
22+
id: Int!
23+
}
24+
25+
26+
27+
type A implements T1 {
28+
id: Int!
29+
}
30+
type B implements T2 {
31+
id: Int!
32+
}
33+
type C implements T3 {
34+
id: Int!
35+
}
36+
type D implements T4 {
37+
id: Int!
38+
}
39+
type E implements T1 & T2 & T3 & T0 {
40+
id: Int!
41+
}
42+
type F implements T0 {
43+
id: Int!
44+
}
45+
46+
type Query {
47+
a: A @expr(body: "A")
48+
b: B @expr(body: "B")
49+
c: C @expr(body: "C")
50+
d: D @expr(body: "D")
51+
e: E @expr(body: "E")
52+
f: F @expr(body: "F")
53+
}

0 commit comments

Comments
 (0)