Skip to content

Commit

Permalink
Merge pull request #22 from Avinya-Foundation/rukmal-update
Browse files Browse the repository at this point in the history
Add internal graphQL tests and update avinya types
  • Loading branch information
rukmal authored Oct 6, 2022
2 parents b17628b + fa21df7 commit 86e51b3
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 20 deletions.
7 changes: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,16 @@ clean: ## Clean docker containers and volumes (causes act to break sometimes)
docker rm -f $(shell docker ps -a -q)
docker volume rm $(shell docker volume ls -q)

.PHONY: app
.PHONY: all
all: ## Cleans up docker containers, and runs GitHub workflows with act
$(MAKE) clean
$(MAKE) push

.PHONY: db-run
db-run: ## Build and run the database container with Docker. This logic is replicated from the `push.yml` workflow.
docker build -f db/Dockerfile -t ghcr.io/avinya-foundation/global-data-db:latest .
docker run -d -e MYSQL_ROOT_PASSWORD=test -p 3306:3306 ghcr.io/avinya-foundation/global-data-db:latest

# Util
#######

Expand Down
2 changes: 1 addition & 1 deletion api/avinya_data.bal
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public distinct service class AvinyaTypeData {
return self.avinya_type.active;
}

resource function get global_type() returns string? {
resource function get global_type() returns string {
return self.avinya_type.global_type;
}

Expand Down
2 changes: 1 addition & 1 deletion api/organization_data.bal
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public distinct service class OrganizationData {
}

resource function get people() returns PersonData[]|error? {
// Get list of child organizations
// Get list of people in the organization
stream<Person, error?> people = db_client->query(
`SELECT *
FROM avinya_db.person
Expand Down
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"}}
}
}
}
}
}
);
}
2 changes: 1 addition & 1 deletion api/types.bal
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public type AvinyaType record{|
readonly string record_type = "avinya_type";
int id?;
boolean active;
string? global_type;
string global_type;
string? name;
string? foundation_type;
string? focus;
Expand Down
41 changes: 25 additions & 16 deletions db/schema/2-avinya_types.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,35 @@ USE avinya_db;
CREATE TABLE IF NOT EXISTS avinya_type (
id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
active BOOLEAN NOT NULL,
global_type ENUM("Employee", "Customer", "Volunteer", "Applicant", "Organization", "Team") NOT NULL,
global_type ENUM(
"employee",
"consultant",
"customer",
"volunteer",
"applicant",
"team",
"advisor",
"director",
"donor"
) NOT NULL,
name VARCHAR(255),
foundation_type ENUM(
"Executive",
"Advisor",
"Educator",
"Technology",
"Operations",
"HR",
"Parent",
"Student"
"executive", -- Foundation Level
"academic", -- specifically academic instruction
"staff", -- l.t. (<) Foundation Level
"parent",
"student"
),
focus ENUM(
"Foundation",
"Vocational-IT",
"Vocational-Healthcare",
"Vocational-Hospitality",
"Operations",
"HR",
"Technology"
"bootcamp",
"information-technology",
"healthcare",
"hospitality",
"operations",
"human-resources",
"technology",
"marketing",
"finance"
),
level INT
);

0 comments on commit 86e51b3

Please sign in to comment.