-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtest.js
66 lines (53 loc) · 2.12 KB
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import test from 'ava'
const util = require('util');
const exec = util.promisify(require('child_process').exec);
import {
doesFileExist,
} from './dist/utils'
(async () => {
const hasConfig = await doesFileExist('swiff.config.js')
const hasEnv = await doesFileExist('.env')
if (!hasConfig) console.error('No swiff.config.js')
if (!hasEnv) console.error('No .env')
if (!hasConfig || !hasEnv) return
test('swiff --pull-folders', async t => {
const { stdout, stderr } = await exec('swiff --pull')
if (stderr) return t.fail(stderr)
if (!stdout) return t.fail('No output')
const result = String(stdout).includes('No pull required, localhost is already up-to-date!')
if (result) return t.pass(stdout)
t.fail(`Unknown output:\n\n${stdout}`)
})
test('swiff --pull-database', async t => {
const { stdout, stderr } = await exec('swiff --database')
if (stderr) return t.fail(stderr)
if (!stdout) return t.fail('No output')
const result = String(stdout).includes('First create a database named swf on localhost with these login details')
if (result) return t.pass(stdout)
t.fail(`Unknown output:\n\n${stdout}`)
})
test('swiff --pull-composer', async t => {
const { stdout, stderr } = await exec('swiff --composer')
if (stderr) return t.fail(stderr)
if (!stdout) return t.fail('No output')
const result = String(stdout).includes('Your local composer.json and composer.lock were refreshed')
if (result) return t.pass(stdout)
t.fail(`Unknown output:\n\n${stdout}`)
})
test('swiff --backups', async t => {
const { stdout, stderr } = await exec('swiff --backups')
if (stderr) return t.fail(stderr)
if (!stdout) return t.fail('No output')
const result = String(stdout).includes('The backups folder was opened')
if (result) return t.pass(stdout)
t.fail(`Unknown output:\n\n${stdout}`)
})
// test('swiff --ssh', async t => {
// const { stdout, stderr } = await exec('swiff --ssh')
// if (stderr) return t.fail(stderr)
// if (!stdout) return t.fail('No output')
// const result = String(stdout).includes('...')
// if (result) return t.pass(stdout)
// t.fail(`Unknown output:\n\n${stdout}`)
// })
})()