Skip to content

test: setup ephemeral PDS server for testing #56

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 17 commits into from
Feb 14, 2025

Conversation

shuuji3
Copy link
Collaborator

@shuuji3 shuuji3 commented Feb 9, 2025

resolve #53

Note that the existing tests still uses the public PDS server via https://bsky.social. I'll update other test in a separate PR later.

In the global setup, a new ephemeral PDS (and PLC) server is created on localhost and two users are created: @alice.test and @bob.test. We can use them with the test helper method getTestAgent() like this:

import { describe, it } from 'vitest'

import { getTestAgent } from '~~/test-utils';

describe('createAgent', () => {
  it('getAgent for Alice', async () => {
    const agent = await getTestAgent('alice.test');
    expect(agent.session).not.toBe(undefined);
    expect(agent.session?.handle).toBe('alice.test');
    expect(agent.session?.email).toBe('[email protected]');
  });

  it('test with Bob', async () => {
    const bobAgent = await getTestAgent('bob.test')
    // do something
  });
})

Example test run:

> CI=1 pnpm -r test tsky
Scope: 5 of 6 workspace projects
docs test$ echo "Error: no test specified" "tsky"
docs test: Error: no test specified tsky
docs test: Done
packages/client test$ vitest "tsky"
packages/client test:  RUN  v3.0.5 /home/shuuji3/dev/tsky/packages/client
packages/client test: 🌐 Created test network:
packages/client test: - pds: http://localhost:33007
packages/client test: - plc: http://localhost:46063
packages/client test: 🙋 Created new account: @alice.test
packages/client test: 🙋 Created new account: @bob.test
packages/client test:  ✓ src/tsky/tsky.test.ts (2 tests) 736ms
packages/client test:    ✓ createAgent > can create agent for Alice 380ms
packages/client test:    ✓ createAgent > can resume from stored session 356ms
packages/client test:  Test Files  1 passed (1)
packages/client test:       Tests  2 passed (2)
packages/client test:    Start at  03:11:01
packages/client test:    Duration  2.05s (transform 80ms, setup 0ms, collect 68ms, tests 736ms, environment 0ms, prepare 64ms)
packages/client test: Done

Copy link

netlify bot commented Feb 9, 2025

Deploy Preview for tsky canceled.

Name Link
🔨 Latest commit 3e36347
🔍 Latest deploy log https://app.netlify.com/sites/tsky/deploys/67acc5b2d6da3a000816fea0

@shuuji3 shuuji3 force-pushed the shuuji3/test/atcute-internal-dev-env branch from e4d0098 to ea56994 Compare February 9, 2025 16:30
Copy link
Contributor

github-actions bot commented Feb 9, 2025

Coverage Report for ./packages/client/

Status Category Percentage Covered / Total
🔵 Lines 21.73% 40 / 184
🔵 Statements 21.62% 40 / 185
🔵 Functions 19.6% 20 / 102
🔵 Branches 27.65% 13 / 47
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
packages/client/globalSetup.ts 0% 100% 0% 0% 9-38
packages/client/src/tsky/tsky.ts 100% 100% 100% 100%
Generated in workflow #173 for commit 3e36347 by the Vitest Coverage Report Action

@shuuji3 shuuji3 force-pushed the shuuji3/test/atcute-internal-dev-env branch from 233bf2d to 9777f96 Compare February 9, 2025 17:49
@shuuji3 shuuji3 force-pushed the shuuji3/test/atcute-internal-dev-env branch from fe91dd4 to 9650b00 Compare February 11, 2025 09:21
@shuuji3 shuuji3 changed the title WIP: setup internal-dev-env for testing test: setup internal-dev-env for testing Feb 11, 2025
@shuuji3 shuuji3 force-pushed the shuuji3/test/atcute-internal-dev-env branch 2 times, most recently from 83b6ec8 to 55d3f9b Compare February 11, 2025 13:54
@shuuji3 shuuji3 force-pushed the shuuji3/test/atcute-internal-dev-env branch from 55d3f9b to 2364613 Compare February 11, 2025 16:52
@shuuji3 shuuji3 changed the title test: setup internal-dev-env for testing test: setup ephemeral PDS server for testing Feb 11, 2025
@shuuji3 shuuji3 force-pushed the shuuji3/test/atcute-internal-dev-env branch from 07dcffd to 1d698fb Compare February 11, 2025 18:15
@shuuji3 shuuji3 marked this pull request as ready for review February 11, 2025 18:17
@shuuji3 shuuji3 force-pushed the shuuji3/test/atcute-internal-dev-env branch from 1d698fb to 83d1f8e Compare February 11, 2025 18:23
@shuuji3 shuuji3 merged commit 5cb690f into main Feb 14, 2025
6 checks passed
@shuuji3 shuuji3 deleted the shuuji3/test/atcute-internal-dev-env branch February 14, 2025 08:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Setup ephemeral PDS server for testing
1 participant