Skip to content

Commit 96d3325

Browse files
authored
Merge pull request #29 from EOSIO/develop
Release 2.0.1
2 parents b1e6cc2 + 0ce6bba commit 96d3325

File tree

7 files changed

+912
-18
lines changed

7 files changed

+912
-18
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "demux-postgres",
3-
"version": "2.0.0",
3+
"version": "2.0.1",
44
"description": "Demux-js Action Handler implementation for Postgres databases",
55
"main": "dist/index.js",
66
"types": "dist/index.d.ts",
@@ -38,6 +38,7 @@
3838
},
3939
"scripts": {
4040
"release": "release-it",
41+
"build": "tsc && cp -R src/cyanaudit dist",
4142
"compile": "tsc",
4243
"watch": "tsc -w",
4344
"lint": "tslint -c tslint.json src/**/*.ts",

src/MassiveActionHandler.test.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import Docker from "dockerode"
22
import massive from "massive"
3+
import * as path from "path"
34
import { Migration } from "./Migration"
45
import { MigrationRunner } from "./MigrationRunner"
56
import blockchains from "./testHelpers/blockchains"
@@ -17,6 +18,8 @@ const dbPass = "docker"
1718

1819
jest.setTimeout(30000)
1920

21+
const baseDir = path.join(path.resolve("./"), "src")
22+
2023
describe("TestMassiveActionHandler", () => {
2124
let runner: MigrationRunner
2225
let migrations: Migration[]
@@ -50,8 +53,8 @@ describe("TestMassiveActionHandler", () => {
5053
beforeEach(async () => {
5154
schemaName = "s" + Math.random().toString(36).substring(7)
5255
migrations = [
53-
new Migration("createTodoTable", schemaName, "testHelpers/migration1.sql"),
54-
new Migration("createTaskTable", schemaName, "testHelpers/migration2.sql"),
56+
new Migration("createTodoTable", schemaName, path.join(baseDir, "testHelpers/migration1.sql")),
57+
new Migration("createTaskTable", schemaName, path.join(baseDir, "testHelpers/migration2.sql")),
5558
]
5659
runner = new MigrationRunner(
5760
massiveInstance.instance,

src/Migration.test.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
1-
import { Migration } from "./Migration"
1+
import * as path from "path"
22
import { QueryFile } from "pg-promise"
3+
import { Migration } from "./Migration"
34

45
class TestMigration extends Migration {
56
get _downQueryFile(): QueryFile | null { return this.downQueryFile }
67
}
78

9+
const baseDir = path.join(path.resolve("./"), "src")
10+
811
describe("Migration", () => {
912
it("instantiates a Migration instance", () => {
1013
const migration = new TestMigration(
1114
"test",
1215
"public",
13-
"testHelpers/migration1.sql",
14-
"testHelpers/migration2.sql",
16+
path.join(baseDir, "testHelpers/migration1.sql"),
17+
path.join(baseDir, "testHelpers/migration2.sql"),
1518
)
1619
expect(migration).toBeTruthy()
1720
expect(migration._downQueryFile).not.toBe(null)

src/Migration.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import * as path from "path"
21
import { IDatabase, QueryFile } from "pg-promise"
32

43
export class Migration {
@@ -27,17 +26,15 @@ export class Migration {
2726
await pgp.none(this.downQueryFile)
2827
}
2928

30-
private loadQueryFile(file: string) {
31-
let fullPath: string
32-
fullPath = path.join(__dirname, file)
29+
private loadQueryFile(filepath: string) {
3330
const options = {
3431
minify: true,
3532
noWarnings: true,
3633
params: {
3734
schema: this.schema,
3835
},
3936
}
40-
const qf = new QueryFile(fullPath, options)
37+
const qf = new QueryFile(filepath, options)
4138
if (qf.error) {
4239
throw qf.error
4340
}

src/MigrationRunner.test.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
11
import Docker from "dockerode"
2+
import massive from "massive"
3+
import * as path from "path"
4+
import { IDatabase } from "pg-promise"
25
import { Migration } from "./Migration"
36
import { MigrationRunner } from "./MigrationRunner"
47
import * as dockerUtils from "./testHelpers/docker"
5-
import massive from "massive"
6-
import {IDatabase} from "pg-promise"
78

89
const docker = new Docker()
910
const postgresImageName = "postgres:10.4"
1011
const dbName = "migrationrunnertest"
1112
const dbUser = "docker"
1213
const dbPass = "docker"
1314

15+
const baseDir = path.join(path.resolve("./"), "src")
16+
1417
class TestMigrationRunner extends MigrationRunner {
1518
public async _checkOrCreateSchema() { await this.checkOrCreateSchema() }
1619
public async _checkOrCreateTables() { await this.checkOrCreateTables() }
@@ -137,9 +140,9 @@ describe("MigrationRunner", () => {
137140
beforeEach(async (done) => {
138141
schemaName = randomSchemaName()
139142
migrations = [
140-
new Migration("createTodoTable", schemaName, "testHelpers/migration1.sql"),
141-
new Migration("createTaskTable", schemaName, "testHelpers/migration2.sql"),
142-
new Migration("createAssigneeTable", schemaName, "testHelpers/migration3.sql"),
143+
new Migration("createTodoTable", schemaName, path.join(baseDir, "testHelpers/migration1.sql")),
144+
new Migration("createTaskTable", schemaName, path.join(baseDir, "testHelpers/migration2.sql")),
145+
new Migration("createAssigneeTable", schemaName, path.join(baseDir, "testHelpers/migration3.sql")),
143146
]
144147
runner = new TestMigrationRunner(
145148
massiveInstance.instance,
@@ -214,7 +217,7 @@ describe("MigrationRunner", () => {
214217
new Migration(
215218
"mymigration",
216219
schemaName,
217-
"testHelpers/migration1.sql",
220+
path.join(baseDir, "testHelpers/migration1.sql"),
218221
),
219222
)
220223
const error = new Error(

src/MigrationRunner.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { IDatabase } from "pg-promise"
22
import { Migration } from "./Migration"
3+
import * as path from "path"
34

45
export class MigrationRunner {
56
private isSetUp: boolean = false
@@ -70,7 +71,7 @@ export class MigrationRunner {
7071
}
7172

7273
protected async installCyanAudit() {
73-
const cyanaudit = new Migration("", "", "cyanaudit/cyanaudit--2.2.0.sql")
74+
const cyanaudit = new Migration("", "", path.join(__dirname, "cyanaudit/cyanaudit--2.2.0.sql"))
7475
await cyanaudit.up(this.pgp)
7576
await this.refreshCyanAudit()
7677
}

0 commit comments

Comments
 (0)