Skip to content

Commit

Permalink
Break apart tests
Browse files Browse the repository at this point in the history
  • Loading branch information
robertherber committed Nov 4, 2023
1 parent 81f0539 commit 511702b
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 17 deletions.
36 changes: 30 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
# This workflow contains a single job called "build"
test:
# The type of runner that the job will run on
runs-on: ubuntu-latest
runs-on: macos-latest
timeout-minutes: 10
env:
SUPABASE_ACCESS_TOKEN: ${{ secrets.SUPABASE_ACCESS_TOKEN }}
Expand All @@ -34,17 +34,41 @@ jobs:

- run: bun install

- uses: supabase/setup-cli@v1

- run: supabase start --debug
working-directory: ./packages/supabase/supabase-app

- name: Test
run: bun run test-recursive
env:
PRIVATE_KEY: ${{ secrets.TEST_PRIVATE_KEY }}
PUBLIC_KEY: ${{ secrets.TEST_PUBLIC_KEY }}

test-supabase:
# The type of runner that the job will run on
runs-on: ubuntu-latest
timeout-minutes: 10
env:
SUPABASE_ACCESS_TOKEN: ${{ secrets.SUPABASE_ACCESS_TOKEN }}
PROJECT_ID: ${{ secrets.SUPABASE_PROJECT_ID }}

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3

- uses: oven-sh/setup-bun@v1

- run: bun install

- uses: supabase/setup-cli@v1

- run: supabase start --debug
working-directory: ./packages/supabase/supabase-app

- name: Test
run: bun run codegen && bun test
working-directory: ./packages/supabase/supabase-app
env:
PRIVATE_KEY: ${{ secrets.TEST_PRIVATE_KEY }}
PUBLIC_KEY: ${{ secrets.TEST_PUBLIC_KEY }}

typecheck:
# The type of runner that the job will run on
runs-on: ubuntu-latest
Expand Down
1 change: 0 additions & 1 deletion packages/supabase/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
"@supabase/supabase-js": "^2.38.4"
},
"scripts": {
"test": "bun run codegen && bun test",
"dev": "zemble-dev plugin.ts",
"lint": "eslint .",
"typecheck": "bun run codegen && tsc --noEmit",
Expand Down
20 changes: 10 additions & 10 deletions packages/supabase/test-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@ import { createClient } from '@supabase/supabase-js'

import plugin from './plugin'

const testSupabaseUrl = 'http://127.0.0.1:54321'
const testSupabaseAnonKey = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Im5wdHFtbWF4bXluYWhzZ2Z1dmhuIiwicm9sZSI6ImFub24iLCJpYXQiOjE2OTkwMzc3MzEsImV4cCI6MjAxNDYxMzczMX0.TEyzdP13ogqp6NGhSQYwtzOkwmuJDMkXUjU3gUVmN1c'
const testConfig = {
supabaseUrl: testSupabaseUrl,
supabaseAnonKey: testSupabaseAnonKey,
}

const storage: Record<string, string> = {}

export const createSupabaseClient = () => {
const { supabaseUrl, supabaseAnonKey } = process.env.NODE_ENV === 'test' ? testConfig : plugin.config

Expand All @@ -14,7 +23,7 @@ export const createSupabaseClient = () => {
auth: {
storage: {
getItem(name: string) {
return storage[name]
return storage[name] ?? null
},
setItem(name: string, value: string) {
storage[name] = value
Expand Down Expand Up @@ -44,15 +53,6 @@ export async function signUpNewUser(
return res
}

const storage: Record<string, string> = {}

const testSupabaseUrl = 'http://127.0.0.1:54321'
const testSupabaseAnonKey = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Im5wdHFtbWF4bXluYWhzZ2Z1dmhuIiwicm9sZSI6ImFub24iLCJpYXQiOjE2OTkwMzc3MzEsImV4cCI6MjAxNDYxMzczMX0.TEyzdP13ogqp6NGhSQYwtzOkwmuJDMkXUjU3gUVmN1c'
const testConfig = {
supabaseUrl: testSupabaseUrl,
supabaseAnonKey: testSupabaseAnonKey,
}

export async function deleteAllUsers() {
const { data } = await createSupabaseClient().auth.admin.listUsers()

Expand Down

0 comments on commit 511702b

Please sign in to comment.