-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest.js
92 lines (78 loc) · 2.68 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
var UmzugPostgresStorage = require("./dist/umzug-postgres-storage.js");
var tape = require('tape');
var storage = new UmzugPostgresStorage({
database: {
database: "umzug_postgres_storage",
user: "app",
password: "catbakescookies",
host: "localhost",
port: 5432
},
relation: 'umzug_meta',
column: 'name'
});
storage.safeQuery(`TRUNCATE umzug_meta CASCADE;`).then(function () {
tape("logMigration should log the migration", function (t) {
storage.logMigration('001_firstMigration').then(function () {
storage.safeQuery(`
SELECT name FROM umzug_meta;
`).then(function (result) {
t.deepEqual(result.rows, [
{name: '001_firstMigration'}
]);
t.end();
});
});
});
tape("logMigration should log a second migration", function (t) {
storage.logMigration('002_secondMigration').then(function () {
storage.safeQuery(`
SELECT name FROM umzug_meta;
`).then(function (result) {
t.deepEqual(result.rows, [
{name: '001_firstMigration'},
{name: '002_secondMigration'}
]);
t.end();
});
});
});
tape("logMigration should not log a duplicate migration", function (t) {
storage.logMigration('002_secondMigration').then(function(){
return storage.logMigration('003_thirdMigration');
}).then(function () {
storage.safeQuery(`
SELECT name FROM umzug_meta;
`).then(function (result) {
t.deepEqual(result.rows, [
{name: '001_firstMigration'},
{name: '002_secondMigration'},
{name: '003_thirdMigration'}
]);
t.end();
});
});
});
tape("unlogMigration should remove a migration row", function (t) {
storage.unlogMigration('003_thirdMigration').then(function () {
storage.safeQuery(`
SELECT name FROM umzug_meta;
`).then(function (result) {
t.deepEqual(result.rows, [
{name: '001_firstMigration'},
{name: '002_secondMigration'}
]);
t.end();
});
});
});
tape("executed should return a list of executed migrations", function (t) {
storage.executed().then(function (executed_ar) {
t.deepEqual(executed_ar, [
'001_firstMigration',
'002_secondMigration'
]);
t.end();
});
});
});