Skip to content

Commit

Permalink
Add test for GeoData GraphQL endpoint
Browse files Browse the repository at this point in the history
Closes #13
  • Loading branch information
rukmal committed Oct 4, 2022
1 parent 168b52a commit 1e09406
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions api/tests/geo_data.bal
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import ballerina/test;
import ballerina/graphql;

graphql:Client test_client = check new ("http://localhost:4000/graphql");

@test:Config {}
public function testGetProvince() {
// Attempt to get geo information for Dehiwala
json|error? a = test_client->executeWithType(string `
query test($name:String!) {
geo {
city(name: $name) {
name {name_en}
district {
name {name_en}
province {
name {name_en}
}
}
}
}
}`,
{"name": "Dehiwala"});

// Verify output
test:assertEquals(a,
{
"data": {
"geo": {
"city": {
"name": {"name_en": "Dehiwala"},
"district": {
"name": {"name_en": "Colombo"},
"province": {"name": {"name_en": "Western"}}
}
}
}
}
}
);
}

0 comments on commit 1e09406

Please sign in to comment.