-
Notifications
You must be signed in to change notification settings - Fork 265
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(xo-server-test): cleanup and rewrite user tests (#8048)
- Loading branch information
1 parent
a3cb9d5
commit a71e78f
Showing
36 changed files
with
471 additions
and
331 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
7 changes: 3 additions & 4 deletions
7
packages/xo-server-test/src/_config.js → packages/xo-server-test/_config.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,12 @@ | ||
import appConf from 'app-conf' | ||
import path from 'path' | ||
|
||
/* eslint-env jest */ | ||
import { before } from 'node:test' | ||
|
||
let config | ||
export { config as default } | ||
|
||
beforeAll(async () => { | ||
before(async () => { | ||
config = await appConf.load('xo-server-test', { | ||
appDir: path.join(__dirname, '..'), | ||
appDir: path.join(process.cwd(), '..'), | ||
}) | ||
}) |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import Xo from 'xo-lib' | ||
const XoConnection = Xo.default | ||
|
||
const SERVER_URL = process.env.SERVER_URL || 'http://127.0.0.1:80' | ||
|
||
/** | ||
* @param params Contains {url, email, password} as the optionnal server url, and the email/password of the user | ||
* @return Xo A Xo object connection | ||
**/ | ||
export async function connect({ url = SERVER_URL, email, password }) { | ||
const xo = new XoConnection({ url }) | ||
await xo.open() | ||
try { | ||
await xo.signIn({ email, password }) | ||
} catch (err) { | ||
xo.close() | ||
throw err | ||
} | ||
return xo | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
// @TODO | ||
// Index.js will be the main entry point as defined in package.json |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
...xo-server-test/src/old-tests/disk.spec.js → ...es/xo-server-test/old-tests/disk.spec.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
/* eslint-env jest */ | ||
|
||
import { difference, keyBy } from 'lodash' | ||
import config from '../../_config.mjs' | ||
import { describe, it, afterEach } from 'node:test' | ||
import { XoConnection as xo, testWithOtherConnection } from '../../_xoConnection.mjs' | ||
|
||
import config from '../_config' | ||
import xo, { testWithOtherConnection } from '../_xoConnection' | ||
const { difference, keyBy } = 'lodash' | ||
|
||
const ADMIN_USER = { | ||
email: '[email protected]', | ||
|
@@ -14,33 +15,33 @@ const ADMIN_USER = { | |
describe('job', () => { | ||
let defaultJob | ||
|
||
beforeAll(() => { | ||
defaultJob = { | ||
name: 'jobTest', | ||
timeout: 2000, | ||
type: 'call', | ||
key: 'snapshot', | ||
method: 'vm.snapshot', | ||
paramsVector: { | ||
type: 'crossProduct', | ||
items: [ | ||
{ | ||
type: 'set', | ||
values: [ | ||
{ | ||
id: config.vms.default, | ||
name: 'test-snapshot', | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
} | ||
}) | ||
// beforeAll(() => { | ||
// defaultJob = { | ||
// name: 'jobTest', | ||
// timeout: 2000, | ||
// type: 'call', | ||
// key: 'snapshot', | ||
// method: 'vm.snapshot', | ||
// paramsVector: { | ||
// type: 'crossProduct', | ||
// items: [ | ||
// { | ||
// type: 'set', | ||
// values: [ | ||
// { | ||
// id: config.vms.default, | ||
// name: 'test-snapshot', | ||
// }, | ||
// ], | ||
// }, | ||
// ], | ||
// }, | ||
// } | ||
// }) | ||
|
||
describe('.create() :', () => { | ||
it('creates a new job', async () => { | ||
jest.setTimeout(6e3) | ||
// jest.setTimeout(6e3) | ||
const userId = await xo.createTempUser(ADMIN_USER) | ||
const { email, password } = ADMIN_USER | ||
await testWithOtherConnection({ email, password }, async xo => { | ||
|
@@ -201,7 +202,7 @@ describe('job', () => { | |
}) | ||
|
||
it('runs a job', async () => { | ||
jest.setTimeout(7e4) | ||
// jest.setTimeout(7e4) | ||
await xo.createTempServer(config.servers.default) | ||
const jobId = await xo.createTempJob(defaultJob) | ||
const snapshots = xo.objects.all[config.vms.default].snapshots | ||
|
2 changes: 2 additions & 0 deletions
2
...xo-server-test/src/old-tests/pool.spec.js → ...es/xo-server-test/old-tests/pool.spec.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
...xo-server-test/src/old-tests/role.spec.js → ...es/xo-server-test/old-tests/role.spec.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
...erver-test/src/old-tests/schedule.spec.js → ...o-server-test/old-tests/schedule.spec.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
...rver-test/src/old-tests/scheduler.spec.js → ...-server-test/old-tests/scheduler.spec.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
.../xo-server-test/src/old-tests/vbd.spec.js → ...ges/xo-server-test/old-tests/vbd.spec.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.