Skip to content
Merged
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
4 changes: 2 additions & 2 deletions packages/js-sdk/tests/sandbox/git/add.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { expect } from 'vitest'

import { sandboxTest } from '../../setup.js'
import { gitTest } from '../../setup.js'
import { cleanupBaseDir, createBaseDir, createRepo } from './helpers.js'

sandboxTest('git add stages files', async ({ sandbox }) => {
gitTest('git add stages files', async ({ sandbox }) => {
const baseDir = await createBaseDir(sandbox)

try {
Expand Down
10 changes: 5 additions & 5 deletions packages/js-sdk/tests/sandbox/git/branches.test.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { expect } from 'vitest'

import { sandboxTest } from '../../setup.js'
import { gitTest } from '../../setup.js'
import {
cleanupBaseDir,
createBaseDir,
createRepoWithCommit,
} from './helpers.js'

sandboxTest('git branches lists current and feature', async ({ sandbox }) => {
gitTest('git branches lists current and feature', async ({ sandbox }) => {
const baseDir = await createBaseDir(sandbox)

try {
Expand All @@ -23,7 +23,7 @@ sandboxTest('git branches lists current and feature', async ({ sandbox }) => {
}
})

sandboxTest('git checkoutBranch switches branch', async ({ sandbox }) => {
gitTest('git checkoutBranch switches branch', async ({ sandbox }) => {
const baseDir = await createBaseDir(sandbox)

try {
Expand All @@ -43,7 +43,7 @@ sandboxTest('git checkoutBranch switches branch', async ({ sandbox }) => {
}
})

sandboxTest(
gitTest(
'git createBranch creates and checks out branch',
async ({ sandbox }) => {
const baseDir = await createBaseDir(sandbox)
Expand All @@ -61,7 +61,7 @@ sandboxTest(
}
)

sandboxTest('git deleteBranch removes branch', async ({ sandbox }) => {
gitTest('git deleteBranch removes branch', async ({ sandbox }) => {
const baseDir = await createBaseDir(sandbox)

try {
Expand Down
4 changes: 2 additions & 2 deletions packages/js-sdk/tests/sandbox/git/clone.test.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { expect } from 'vitest'

import { sandboxTest } from '../../setup.js'
import { gitTest } from '../../setup.js'
import {
cleanupBaseDir,
createBaseDir,
createRepoWithCommit,
startGitDaemon,
} from './helpers.js'

sandboxTest('git clone fetches repo', async ({ sandbox }) => {
gitTest('git clone fetches repo', async ({ sandbox }) => {
const baseDir = await createBaseDir(sandbox)

try {
Expand Down
6 changes: 3 additions & 3 deletions packages/js-sdk/tests/sandbox/git/commit.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { expect } from 'vitest'

import { sandboxTest } from '../../setup.js'
import { gitTest } from '../../setup.js'
import {
AUTHOR_EMAIL,
AUTHOR_NAME,
Expand All @@ -9,7 +9,7 @@ import {
createRepo,
} from './helpers.js'

sandboxTest('git commit creates commit', async ({ sandbox }) => {
gitTest('git commit creates commit', async ({ sandbox }) => {
const baseDir = await createBaseDir(sandbox)

try {
Expand All @@ -31,7 +31,7 @@ sandboxTest('git commit creates commit', async ({ sandbox }) => {
}
})

sandboxTest(
gitTest(
'git commit uses config for missing author fields',
async ({ sandbox }) => {
const baseDir = await createBaseDir(sandbox)
Expand Down
47 changes: 22 additions & 25 deletions packages/js-sdk/tests/sandbox/git/config.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { expect } from 'vitest'

import { sandboxTest } from '../../setup.js'
import { gitTest } from '../../setup.js'
import {
AUTHOR_EMAIL,
AUTHOR_NAME,
Expand All @@ -9,7 +9,7 @@ import {
createRepo,
} from './helpers.js'

sandboxTest('git getConfig reads local config', async ({ sandbox }) => {
gitTest('git getConfig reads local config', async ({ sandbox }) => {
const baseDir = await createBaseDir(sandbox)

try {
Expand All @@ -34,7 +34,7 @@ sandboxTest('git getConfig reads local config', async ({ sandbox }) => {
}
})

sandboxTest('git setConfig updates local config', async ({ sandbox }) => {
gitTest('git setConfig updates local config', async ({ sandbox }) => {
const baseDir = await createBaseDir(sandbox)

try {
Expand All @@ -61,27 +61,24 @@ sandboxTest('git setConfig updates local config', async ({ sandbox }) => {
}
})

sandboxTest(
'git configureUser sets global user config',
async ({ sandbox }) => {
await sandbox.git.configureUser(AUTHOR_NAME, AUTHOR_EMAIL)
gitTest('git configureUser sets global user config', async ({ sandbox }) => {
await sandbox.git.configureUser(AUTHOR_NAME, AUTHOR_EMAIL)

const name = (
await sandbox.commands.run('git config --global --get user.name')
).stdout.trim()
const email = (
await sandbox.commands.run('git config --global --get user.email')
).stdout.trim()
const configuredName = await sandbox.git.getConfig('user.name', {
scope: 'global',
})
const configuredEmail = await sandbox.git.getConfig('user.email', {
scope: 'global',
})
const name = (
await sandbox.commands.run('git config --global --get user.name')
).stdout.trim()
const email = (
await sandbox.commands.run('git config --global --get user.email')
).stdout.trim()
const configuredName = await sandbox.git.getConfig('user.name', {
scope: 'global',
})
const configuredEmail = await sandbox.git.getConfig('user.email', {
scope: 'global',
})

expect(name).toBe(AUTHOR_NAME)
expect(email).toBe(AUTHOR_EMAIL)
expect(configuredName).toBe(AUTHOR_NAME)
expect(configuredEmail).toBe(AUTHOR_EMAIL)
}
)
expect(name).toBe(AUTHOR_NAME)
expect(email).toBe(AUTHOR_EMAIL)
expect(configuredName).toBe(AUTHOR_NAME)
expect(configuredEmail).toBe(AUTHOR_EMAIL)
})
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { expect } from 'vitest'

import { sandboxTest } from '../../setup.js'
import { gitTest } from '../../setup.js'
import { HOST, PASSWORD, PROTOCOL, USERNAME } from './helpers.js'

sandboxTest('git dangerouslyAuthenticate sets helper', async ({ sandbox }) => {
gitTest('git dangerouslyAuthenticate sets helper', async ({ sandbox }) => {
await sandbox.git.dangerouslyAuthenticate({
username: USERNAME,
password: PASSWORD,
Expand Down
3 changes: 2 additions & 1 deletion packages/js-sdk/tests/sandbox/git/helpers.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { describe, expect, test, vi } from 'vitest'

import { isGitTestsEnabled } from '../../setup.js'
import { cleanupBaseDir } from './helpers.js'

describe('cleanupBaseDir', () => {
describe.skipIf(!isGitTestsEnabled)('cleanupBaseDir', () => {
test('retries a Cloudflare dropped connection once', async () => {
const run = vi
.fn()
Expand Down
4 changes: 2 additions & 2 deletions packages/js-sdk/tests/sandbox/git/init.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { expect } from 'vitest'

import { sandboxTest } from '../../setup.js'
import { gitTest } from '../../setup.js'
import { cleanupBaseDir, createBaseDir } from './helpers.js'

sandboxTest('git init', async ({ sandbox }) => {
gitTest('git init', async ({ sandbox }) => {
const baseDir = await createBaseDir(sandbox)

try {
Expand Down
8 changes: 4 additions & 4 deletions packages/js-sdk/tests/sandbox/git/remote.test.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { expect } from 'vitest'

import { sandboxTest } from '../../setup.js'
import { gitTest } from '../../setup.js'
import {
cleanupBaseDir,
createBaseDir,
createRepo,
startGitDaemon,
} from './helpers.js'

sandboxTest(
gitTest(
'git remoteGet returns undefined for missing remote',
async ({ sandbox }) => {
const baseDir = await createBaseDir(sandbox)
Expand All @@ -23,7 +23,7 @@ sandboxTest(
}
)

sandboxTest('git remoteAdd adds remote', async ({ sandbox }) => {
gitTest('git remoteAdd adds remote', async ({ sandbox }) => {
const baseDir = await createBaseDir(sandbox)

try {
Expand All @@ -42,7 +42,7 @@ sandboxTest('git remoteAdd adds remote', async ({ sandbox }) => {
}
})

sandboxTest('git remoteAdd overwrites existing remote', async ({ sandbox }) => {
gitTest('git remoteAdd overwrites existing remote', async ({ sandbox }) => {
const baseDir = await createBaseDir(sandbox)

try {
Expand Down
4 changes: 2 additions & 2 deletions packages/js-sdk/tests/sandbox/git/reset.test.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { expect } from 'vitest'

import { sandboxTest } from '../../setup.js'
import { gitTest } from '../../setup.js'
import {
cleanupBaseDir,
createBaseDir,
createRepoWithCommit,
} from './helpers.js'

sandboxTest(
gitTest(
'git reset --hard discards changes',
async ({ sandbox }) => {
const baseDir = await createBaseDir(sandbox)
Expand Down
37 changes: 17 additions & 20 deletions packages/js-sdk/tests/sandbox/git/restore.test.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { expect } from 'vitest'

import { sandboxTest } from '../../setup.js'
import { gitTest } from '../../setup.js'
import {
cleanupBaseDir,
createBaseDir,
createRepoWithCommit,
} from './helpers.js'

sandboxTest('git restore --staged unstages changes', async ({ sandbox }) => {
gitTest('git restore --staged unstages changes', async ({ sandbox }) => {
const baseDir = await createBaseDir(sandbox)

try {
Expand All @@ -32,27 +32,24 @@ sandboxTest('git restore --staged unstages changes', async ({ sandbox }) => {
}
})

sandboxTest(
'git restore discards working tree changes',
async ({ sandbox }) => {
const baseDir = await createBaseDir(sandbox)
gitTest('git restore discards working tree changes', async ({ sandbox }) => {
const baseDir = await createBaseDir(sandbox)

try {
const repoPath = await createRepoWithCommit(sandbox, baseDir)
await sandbox.files.write(`${repoPath}/README.md`, 'changed\n')
try {
const repoPath = await createRepoWithCommit(sandbox, baseDir)
await sandbox.files.write(`${repoPath}/README.md`, 'changed\n')

const status = await sandbox.git.status(repoPath)
expect(status.isClean).toBe(false)
const status = await sandbox.git.status(repoPath)
expect(status.isClean).toBe(false)

await sandbox.git.restore(repoPath, { paths: ['README.md'] })
await sandbox.git.restore(repoPath, { paths: ['README.md'] })

const statusAfter = await sandbox.git.status(repoPath)
expect(statusAfter.isClean).toBe(true)
const statusAfter = await sandbox.git.status(repoPath)
expect(statusAfter.isClean).toBe(true)

const contents = await sandbox.files.read(`${repoPath}/README.md`)
expect(contents).toBe('hello\n')
} finally {
await cleanupBaseDir(sandbox, baseDir)
}
const contents = await sandbox.files.read(`${repoPath}/README.md`)
expect(contents).toBe('hello\n')
} finally {
await cleanupBaseDir(sandbox, baseDir)
}
)
})
6 changes: 3 additions & 3 deletions packages/js-sdk/tests/sandbox/git/status.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { expect } from 'vitest'

import { sandboxTest } from '../../setup.js'
import { gitTest } from '../../setup.js'
import {
AUTHOR_EMAIL,
AUTHOR_NAME,
Expand All @@ -9,7 +9,7 @@ import {
createRepo,
} from './helpers.js'

sandboxTest('git status reports untracked file', async ({ sandbox }) => {
gitTest('git status reports untracked file', async ({ sandbox }) => {
const baseDir = await createBaseDir(sandbox)

try {
Expand All @@ -36,7 +36,7 @@ sandboxTest('git status reports untracked file', async ({ sandbox }) => {
}
})

sandboxTest(
gitTest(
'git status reports added modified deleted renamed',
async ({ sandbox }) => {
const baseDir = await createBaseDir(sandbox)
Expand Down
10 changes: 5 additions & 5 deletions packages/js-sdk/tests/sandbox/git/sync.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { expect } from 'vitest'

import { sandboxTest } from '../../setup.js'
import { gitTest } from '../../setup.js'
import {
AUTHOR_EMAIL,
AUTHOR_NAME,
Expand All @@ -10,7 +10,7 @@ import {
startGitDaemon,
} from './helpers.js'

sandboxTest('git push updates remote', async ({ sandbox }) => {
gitTest('git push updates remote', async ({ sandbox }) => {
const baseDir = await createBaseDir(sandbox)

try {
Expand Down Expand Up @@ -38,7 +38,7 @@ sandboxTest('git push updates remote', async ({ sandbox }) => {
}
})

sandboxTest('git push warns when no upstream', async ({ sandbox }) => {
gitTest('git push warns when no upstream', async ({ sandbox }) => {
const baseDir = await createBaseDir(sandbox)

try {
Expand All @@ -59,7 +59,7 @@ sandboxTest('git push warns when no upstream', async ({ sandbox }) => {
}
})

sandboxTest('git pull updates clone', async ({ sandbox }) => {
gitTest('git pull updates clone', async ({ sandbox }) => {
const baseDir = await createBaseDir(sandbox)

try {
Expand Down Expand Up @@ -94,7 +94,7 @@ sandboxTest('git pull updates clone', async ({ sandbox }) => {
}
})

sandboxTest('git pull warns when no upstream', async ({ sandbox }) => {
gitTest('git pull warns when no upstream', async ({ sandbox }) => {
const baseDir = await createBaseDir(sandbox)

try {
Expand Down
Loading
Loading