|
| 1 | +import "reflect-metadata"; |
| 2 | +import {closeTestingConnections, createTestingConnections, reloadTestingDatabases} from "../../utils/test-utils"; |
| 3 | +import {Connection} from "../../../src/connection/Connection"; |
| 4 | +import {expect} from "chai"; |
| 5 | +import { VersionUtils } from "../../../src/util/VersionUtils"; |
| 6 | + |
| 7 | +describe("github issues > 4782 mariadb driver wants to recreate create/update date columns CURRENT_TIMESTAMP(6) === current_timestamp(6)", () => { |
| 8 | + |
| 9 | + let connections: Connection[]; |
| 10 | + before(async () => connections = await createTestingConnections({ |
| 11 | + // logging: true, |
| 12 | + entities: [__dirname + "/entity/*{.js,.ts}"], |
| 13 | + enabledDrivers: ["mysql", "mariadb"] |
| 14 | + })); |
| 15 | + beforeEach(() => reloadTestingDatabases(connections)); |
| 16 | + after(() => closeTestingConnections(connections)); |
| 17 | + |
| 18 | + it("should not want to execute migrations twice", () => Promise.all(connections.map(async connection => { |
| 19 | + const sql1 = await connection.driver.createSchemaBuilder().log(); |
| 20 | + expect(sql1.upQueries).to.eql([]); |
| 21 | + }))); |
| 22 | + |
| 23 | + describe("VersionUtils", () => { |
| 24 | + describe("isGreaterOrEqual", () => { |
| 25 | + it("should return false when comparing invalid versions", () => { |
| 26 | + expect(VersionUtils.isGreaterOrEqual("", "")).to.equal(false); |
| 27 | + }); |
| 28 | + |
| 29 | + it("should return false when targetVersion is larger", () => { |
| 30 | + expect(VersionUtils.isGreaterOrEqual("1.2.3", "1.2.4")).to.equal(false); |
| 31 | + expect(VersionUtils.isGreaterOrEqual("1.2.3", "1.4.3")).to.equal(false); |
| 32 | + expect(VersionUtils.isGreaterOrEqual("1.2.3", "2.2.3")).to.equal(false); |
| 33 | + expect(VersionUtils.isGreaterOrEqual("1.2", "1.3")).to.equal(false); |
| 34 | + expect(VersionUtils.isGreaterOrEqual("1", "2")).to.equal(false); |
| 35 | + expect(VersionUtils.isGreaterOrEqual(undefined as unknown as string, "0.0.1")).to.equal(false); |
| 36 | + }); |
| 37 | + |
| 38 | + it("should return true when targetVersion is smaller", () => { |
| 39 | + |
| 40 | + expect(VersionUtils.isGreaterOrEqual("1.2.3", "1.2.2")).to.equal(true); |
| 41 | + expect(VersionUtils.isGreaterOrEqual("1.2.3", "1.1.3")).to.equal(true); |
| 42 | + expect(VersionUtils.isGreaterOrEqual("1.2.3", "0.2.3")).to.equal(true); |
| 43 | + expect(VersionUtils.isGreaterOrEqual("1.2", "1.2")).to.equal(true); |
| 44 | + expect(VersionUtils.isGreaterOrEqual("1", "1")).to.equal(true); |
| 45 | + }); |
| 46 | + |
| 47 | + it("should work with mariadb-style versions", () => { |
| 48 | + const dbVersion = "10.4.8-MariaDB-1:10.4.8+maria~bionic"; |
| 49 | + expect(VersionUtils.isGreaterOrEqual("10.4.9", dbVersion)).to.equal(true); |
| 50 | + expect(VersionUtils.isGreaterOrEqual("10.4.8", dbVersion)).to.equal(true); |
| 51 | + expect(VersionUtils.isGreaterOrEqual("10.4.7", dbVersion)).to.equal(false); |
| 52 | + }); |
| 53 | + }); |
| 54 | + }); |
| 55 | + |
| 56 | +}); |
0 commit comments