Skip to content

Commit bf7e862

Browse files
authored
Added skip if debug for some tests (#737)
1 parent 6842e9a commit bf7e862

12 files changed

Lines changed: 247 additions & 159 deletions

File tree

packages/js-sdk/tests/sandbox/commands/envVars.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { assert } from 'vitest'
1+
import { assert, test } from 'vitest'
22

33
import { sandboxTest, isDebug, template } from '../../setup.js'
44
import { Sandbox } from '../../../src'
@@ -10,7 +10,7 @@ sandboxTest.skipIf(isDebug)('env vars', async ({ sandbox }) => {
1010
assert.equal(cmd.stdout.trim(), 'bar')
1111
})
1212

13-
sandboxTest.skipIf(isDebug)('env vars on sandbox', async () => {
13+
test.skipIf(isDebug)('env vars on sandbox', async () => {
1414
const sandbox = await Sandbox.create(template, { envs: { FOO: 'bar' } })
1515

1616
try {

packages/js-sdk/tests/sandbox/connect.test.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { assert, test, expect } from 'vitest'
33
import { Sandbox } from '../../src'
44
import { isDebug, sandboxTest, template } from '../setup.js'
55

6-
test('connect', async () => {
6+
test.skipIf(isDebug)('connect', async () => {
77
const sbx = await Sandbox.create(template, { timeoutMs: 10_000 })
88

99
try {
@@ -29,7 +29,9 @@ sandboxTest.skipIf(isDebug)(
2929

3030
const connectPromise = Sandbox.connect(sandbox.sandboxId)
3131
await expect(connectPromise).rejects.toThrowError(
32-
expect.objectContaining({ message: `404: sandbox "${sandbox.sandboxId}" doesn't exist or you don't have access to it` })
32+
expect.objectContaining({
33+
message: `404: sandbox "${sandbox.sandboxId}" doesn't exist or you don't have access to it`,
34+
})
3335
)
3436
}
3537
)

packages/js-sdk/tests/sandbox/create.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { test, assert } from 'vitest'
1+
import { assert, test } from 'vitest'
22

33
import { Sandbox } from '../../src'
44
import { template, isDebug } from '../setup.js'

packages/js-sdk/tests/sandbox/files/rename.test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,7 @@ sandboxTest('rename non-existing file', async ({ sandbox }) => {
2626
const oldFilename = 'non_existing_file.txt'
2727
const newFilename = 'new_non_existing_file.txt'
2828

29-
await expect(sandbox.files.rename(oldFilename, newFilename)).rejects.toThrowError(NotFoundError)
29+
await expect(
30+
sandbox.files.rename(oldFilename, newFilename)
31+
).rejects.toThrowError(NotFoundError)
3032
})

packages/js-sdk/tests/sandbox/files/signing.test.ts

Lines changed: 114 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -1,97 +1,137 @@
1-
import {assert, test} from 'vitest'
2-
import {Sandbox} from '../../../src'
3-
import {template} from '../../setup'
1+
import { assert, test } from 'vitest'
42

5-
const timeout = 20 * 1000
6-
7-
test('test access file with expired signing', async () => {
8-
const sbx = await Sandbox.create(template, { timeoutMs: timeout, secure: true })
9-
await sbx.files.write('hello.txt', 'hello world')
10-
11-
const fileUrlWithSigning = sbx.downloadUrl('hello.txt', { useSignature: true, useSignatureExpiration: -10_000 })
12-
13-
const res = await fetch(fileUrlWithSigning)
14-
const resBody = await res.text()
15-
const resStatus = res.status
3+
import { Sandbox } from '../../../src'
4+
import { template, isDebug } from '../../setup'
165

17-
assert.equal(resStatus, 401)
18-
assert.deepEqual(JSON.parse(resBody), {code: 401, message: 'signature is already expired'})
6+
const timeout = 20 * 1000
197

20-
await sbx.kill()
8+
test.skipIf(isDebug)('test access file with expired signing', async () => {
9+
const sbx = await Sandbox.create(template, {
10+
timeoutMs: timeout,
11+
secure: true,
12+
})
13+
await sbx.files.write('hello.txt', 'hello world')
14+
15+
const fileUrlWithSigning = sbx.downloadUrl('hello.txt', {
16+
useSignature: true,
17+
useSignatureExpiration: -10_000,
18+
})
19+
20+
const res = await fetch(fileUrlWithSigning)
21+
const resBody = await res.text()
22+
const resStatus = res.status
23+
24+
assert.equal(resStatus, 401)
25+
assert.deepEqual(JSON.parse(resBody), {
26+
code: 401,
27+
message: 'signature is already expired',
28+
})
29+
30+
await sbx.kill()
2131
})
2232

23-
test('test access file with valid signing', async () => {
24-
const sbx = await Sandbox.create(template, { timeoutMs: timeout, secure: true })
25-
await sbx.files.write('hello.txt', 'hello world')
33+
test.skipIf(isDebug)('test access file with valid signing', async () => {
34+
const sbx = await Sandbox.create(template, {
35+
timeoutMs: timeout,
36+
secure: true,
37+
})
38+
await sbx.files.write('hello.txt', 'hello world')
2639

27-
const fileUrlWithSigning = sbx.downloadUrl('hello.txt', { useSignature: true, useSignatureExpiration: 10_000 })
40+
const fileUrlWithSigning = sbx.downloadUrl('hello.txt', {
41+
useSignature: true,
42+
useSignatureExpiration: 10_000,
43+
})
2844

29-
const res = await fetch(fileUrlWithSigning)
30-
const resBody = await res.text()
31-
const resStatus = res.status
45+
const res = await fetch(fileUrlWithSigning)
46+
const resBody = await res.text()
47+
const resStatus = res.status
3248

33-
assert.equal(resStatus, 200)
34-
assert.equal(resBody, 'hello world')
49+
assert.equal(resStatus, 200)
50+
assert.equal(resBody, 'hello world')
3551

36-
await sbx.kill()
52+
await sbx.kill()
3753
})
3854

39-
test('test upload file with valid signing', async () => {
40-
const sbx = await Sandbox.create(template, { timeoutMs: timeout, secure: true })
41-
const fileUrlWithSigning = sbx.uploadUrl('hello.txt', { useSignature: true, useSignatureExpiration: 10_000 })
42-
43-
const form = new FormData()
44-
form.append('file', 'file content')
45-
46-
const res = await fetch(fileUrlWithSigning, { method: 'POST', body: form })
47-
const resBody = await res.text()
48-
const resStatus = res.status
49-
50-
assert.equal(resStatus, 200)
51-
assert.deepEqual(JSON.parse(resBody), [{name: 'hello.txt', path: '/home/user/hello.txt', type: 'file'}])
52-
53-
await sbx.kill()
55+
test.skipIf(isDebug)('test upload file with valid signing', async () => {
56+
const sbx = await Sandbox.create(template, {
57+
timeoutMs: timeout,
58+
secure: true,
59+
})
60+
const fileUrlWithSigning = sbx.uploadUrl('hello.txt', {
61+
useSignature: true,
62+
useSignatureExpiration: 10_000,
63+
})
64+
65+
const form = new FormData()
66+
form.append('file', 'file content')
67+
68+
const res = await fetch(fileUrlWithSigning, { method: 'POST', body: form })
69+
const resBody = await res.text()
70+
const resStatus = res.status
71+
72+
assert.equal(resStatus, 200)
73+
assert.deepEqual(JSON.parse(resBody), [
74+
{ name: 'hello.txt', path: '/home/user/hello.txt', type: 'file' },
75+
])
76+
77+
await sbx.kill()
5478
})
5579

56-
test('test upload file with invalid signing', async () => {
57-
const sbx = await Sandbox.create(template, { timeoutMs: timeout, secure: true })
58-
const fileUrlWithSigning = sbx.uploadUrl('hello.txt', { useSignature: true, useSignatureExpiration: -10_000 })
59-
60-
const form = new FormData()
61-
form.append('file', 'file content')
62-
63-
const res = await fetch(fileUrlWithSigning, { method: 'POST', body: form })
64-
const resBody = await res.text()
65-
const resStatus = res.status
66-
67-
assert.equal(resStatus, 401)
68-
assert.deepEqual(JSON.parse(resBody), {code: 401, message: 'signature is already expired'})
69-
70-
await sbx.kill()
80+
test.skipIf(isDebug)('test upload file with invalid signing', async () => {
81+
const sbx = await Sandbox.create(template, {
82+
timeoutMs: timeout,
83+
secure: true,
84+
})
85+
const fileUrlWithSigning = sbx.uploadUrl('hello.txt', {
86+
useSignature: true,
87+
useSignatureExpiration: -10_000,
88+
})
89+
90+
const form = new FormData()
91+
form.append('file', 'file content')
92+
93+
const res = await fetch(fileUrlWithSigning, { method: 'POST', body: form })
94+
const resBody = await res.text()
95+
const resStatus = res.status
96+
97+
assert.equal(resStatus, 401)
98+
assert.deepEqual(JSON.parse(resBody), {
99+
code: 401,
100+
message: 'signature is already expired',
101+
})
102+
103+
await sbx.kill()
71104
})
72105

73-
test('test upload file with missing signing', async () => {
74-
const sbx = await Sandbox.create(template, { timeoutMs: timeout, secure: true })
75-
const fileUrlWithSigning = sbx.uploadUrl('hello.txt')
106+
test.skipIf(isDebug)('test upload file with missing signing', async () => {
107+
const sbx = await Sandbox.create(template, {
108+
timeoutMs: timeout,
109+
secure: true,
110+
})
111+
const fileUrlWithSigning = sbx.uploadUrl('hello.txt')
76112

77-
const form = new FormData()
78-
form.append('file', 'file content')
113+
const form = new FormData()
114+
form.append('file', 'file content')
79115

80-
const res = await fetch(fileUrlWithSigning, { method: 'POST', body: form })
81-
const resBody = await res.text()
82-
const resStatus = res.status
116+
const res = await fetch(fileUrlWithSigning, { method: 'POST', body: form })
117+
const resBody = await res.text()
118+
const resStatus = res.status
83119

84-
assert.equal(resStatus, 401)
85-
assert.deepEqual(JSON.parse(resBody), {code: 401, message: 'missing signature query parameter'})
120+
assert.equal(resStatus, 401)
121+
assert.deepEqual(JSON.parse(resBody), {
122+
code: 401,
123+
message: 'missing signature query parameter',
124+
})
86125

87-
await sbx.kill()
126+
await sbx.kill()
88127
})
89128

90-
test('test command run with secured sbx', async () => {
91-
const sbx = await Sandbox.create(template, { timeoutMs: timeout, secure: true })
92-
const response = await sbx.commands.run('echo Hello World!')
129+
test.skipIf(isDebug)('test command run with secured sbx', async () => {
130+
const sbx = await Sandbox.create(template, {
131+
timeoutMs: timeout,
132+
secure: true,
133+
})
134+
const response = await sbx.commands.run('echo Hello World!')
93135

94-
assert.equal(response.stdout, 'Hello World!\n')
136+
assert.equal(response.stdout, 'Hello World!\n')
95137
})
96-
97-

0 commit comments

Comments
 (0)