Skip to content

Commit

Permalink
Test fixtures
Browse files Browse the repository at this point in the history
  • Loading branch information
JadenSimon committed Jun 28, 2024
1 parent e5e479b commit 801e4af
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 2 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/build-synapse.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,7 @@ jobs:
- uses: actions/checkout@v3
- run: curl -fsSL https://synap.sh/install | bash
- run: synapse --version
- run: synapse compile && synapse build
- run: synapse compile
- run: synapse run testFixtures
- run: synapse build
- run: ./dist/bin/synapse
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
"node": "22.1.0"
},
"scripts": {
"compileSelf": "synapse compile --no-synth && synapse publish --local"
"compileSelf": "synapse compile --no-synth && synapse publish --local",
"testFixtures": "synapse run src/testing/internal.ts --skipValidation -- \"$@\""
},
"synapse": {
"config": {
Expand Down
18 changes: 18 additions & 0 deletions test/fixtures/synth/deployed-module/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import * as pkg from 'pkg'
import { Function } from 'synapse:srl/compute'
import { test, expectEqual } from 'synapse:test'

const client = pkg.createClient()

const fn = new Function(async (key: string) => {
return client.get(key)
})

test('client puts and gets', async () => {
await client.put('foo', 'bar')
expectEqual(await fn('foo'), 'bar')
})

// !commands
// (cd pkg && synapse deploy)
// synapse test
5 changes: 5 additions & 0 deletions test/fixtures/synth/deployed-module/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"dependencies": {
"pkg": "file:pkg"
}
}
15 changes: 15 additions & 0 deletions test/fixtures/synth/deployed-module/pkg/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { Bucket } from 'synapse:srl/storage'

const b = new Bucket()

export function createClient() {
function get(key: string) {
return b.get(key, 'utf-8')
}

function put(key: string, data: string) {
return b.put(key, data)
}

return { get, put }
}
3 changes: 3 additions & 0 deletions test/fixtures/synth/deployed-module/pkg/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"exports": "./main.ts"
}

0 comments on commit 801e4af

Please sign in to comment.