Skip to content
This repository was archived by the owner on Feb 23, 2023. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/deploy-to-staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:

- uses: supabase/setup-cli@v1
with:
version: 1.0.3
version: 1.24.0

- run: |
supabase link --project-ref $STAGING_PROJECT_ID
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
run: npm ci
- uses: supabase/setup-cli@v1
with:
version: 1.0.3
version: 1.24.0
- run: |
supabase start
npm run test:run
Expand Down
8 changes: 4 additions & 4 deletions rest-client/api.http
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ Authorization: Bearer {{access_token}}

### invoke function get specific tree

POST http://localhost:54321/functions/v1/trees?gml_id=eq.s_wfs_baumbestand_an.00008100:00283c82
POST http://localhost:54321/functions/v1/trees?id=eq.s_wfs_baumbestand_an.00008100:00283c82
Content-Type: application/json
apikey: {{anon_key}}
Authorization: Bearer {{access_token}}

### invoke function get join forcast
POST http://localhost:54321/functions/v1/trees?limit=100&select=forecast(baum_id)
POST http://localhost:54321/functions/v1/trees?limit=100&select=forecast(tree_id)
Content-Type: application/json
apikey: {{anon_key}}
Authorization: Bearer {{access_token}}
Expand All @@ -61,7 +61,7 @@ Authorization: Bearer {{access_token}}

### login

GET {{ml_pgrest_host}}:{{ml_pgrest_port}}/rpc/login
POST {{ml_pgrest_host}}:{{ml_pgrest_port}}/rpc/login
Content-Type: application/json

{"email": "{{ml_pgrest_user}}", "password": "{{ml_pgrest_password}}"}
Expand All @@ -70,7 +70,7 @@ Content-Type: application/json

### get all trees

GET {{ml_pgrest_host}}:{{ml_pgrest_port}}/nowcast?limit=100
POST {{ml_pgrest_host}}:{{ml_pgrest_port}}/nowcast?limit=100
Content-Type: application/json
Authorization: Bearer {{ml_pgrest_token}}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
alter table "public"."issues" drop column "gml_id";

alter table "public"."issues" add column "tree_id" text not null;


2 changes: 1 addition & 1 deletion test/__shared/supabase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ import { createClient } from "@supabase/supabase-js";

export const supabase = createClient(
"http://localhost:54321",
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6ImFub24ifQ.625_WdcF3KHqz5amU0x2X5WWHP-OEs_4qj0ssLNHzTs",
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6ImFub24iLCJleHAiOjE5ODM4MTI5OTZ9.CRXP1A7WOeoJeXxjNni43kdQwgnWNReilDMblYTn_I0",
);
4 changes: 2 additions & 2 deletions test/basic.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ describe("basic suite", () => {
headers: {
"Content-Type": "application/json",
apikey:
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6ImFub24ifQ.625_WdcF3KHqz5amU0x2X5WWHP-OEs_4qj0ssLNHzTs",
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6ImFub24iLCJleHAiOjE5ODM4MTI5OTZ9.CRXP1A7WOeoJeXxjNni43kdQwgnWNReilDMblYTn_I0",
authorization:
"Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6ImFub24ifQ.625_WdcF3KHqz5amU0x2X5WWHP-OEs_4qj0ssLNHzTs",
"Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6ImFub24iLCJleHAiOjE5ODM4MTI5OTZ9.CRXP1A7WOeoJeXxjNni43kdQwgnWNReilDMblYTn_I0",
},
});

Expand Down
15 changes: 11 additions & 4 deletions test/issues.test.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,33 @@
import { assert, describe, expect, it } from "vitest";
import { describe, expect, it } from "vitest";
import { supabase } from "./__shared/supabase";
import { Database } from "./types";
type Issues = Database["public"]["Tables"]["issues"];
type Issues_Type = Database["public"]["Tables"]["issue_types"];
type IssueInsert = Issues["Insert"];
type IssuesRow = Issues["Row"];
describe("suite name", () => {
it("should fetch issues", async () => {
const { data: issues, error } = await supabase
.from<Issues>("issues")
.from<IssuesRow>("issues")
.select("*");
if (error) {
console.error(error);
throw error;
}
expect(issues).to.toBeDefined();
expect(error).to.toBeNull();
});

it("should not create an issue", async () => {
const { data: issue_types, error: _ } = await supabase
.from("issue_types")
.from<Issues_Type["Row"]>("issue_types")
.select("*");

expect(issue_types).to.toBeDefined();
expect(issue_types).to.toHaveLength(1);
const { data: issues, error } = await supabase
.from<IssueInsert>("issues")
.insert([{ issue_type_id: issue_types![0].id, gml_id: "gml_id" }]);
.insert([{ issue_type_id: issue_types![0].id, tree_id: "tree_id" }]);
expect(error).not.toBeNull();
expect(issues).toBeNull();
expect(error).toMatchInlineSnapshot(`
Expand Down
Loading