Skip to content

Commit

Permalink
perf: made tests run quite a bit faster
Browse files Browse the repository at this point in the history
  • Loading branch information
edvald committed May 23, 2018
1 parent 242d0aa commit 1aa69fd
Show file tree
Hide file tree
Showing 10 changed files with 23 additions and 28 deletions.
7 changes: 4 additions & 3 deletions test/data/test-project-build-products/garden.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
project:
name: build-products
global:
providers:
- name: test-plugin
environments:
- name: local
providers:
- name: test-plugin
4 changes: 4 additions & 0 deletions test/data/test-project-empty/garden.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
project:
name: test-project-empty
environments:
- name: local
providers:
- name: test-plugin
14 changes: 13 additions & 1 deletion test/setup.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
import * as td from "testdouble"
import { LoggerType } from "../src/logger/types"
import { setLoggerType, getLogger } from "../src/logger"
import { setLoggerType } from "../src/logger"
import { Module } from "../src/types/module"

// Global before hooks
before(() => {
setLoggerType(LoggerType.quiet)
})

beforeEach(() => {
td.replace(Module.prototype, "getVersion", () => ({
versionString: "0000000000",
latestCommit: "0000000000",
dirtyTimestamp: null,
}))
})

afterEach(() => td.reset())
4 changes: 0 additions & 4 deletions test/src/commands/environment/destroy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,6 @@ const testProvider: PluginFactory = () => {
testProvider.pluginName = "test-plugin"

describe("EnvironmentDestroyCommand", () => {
afterEach(() => {
td.reset()
})

const projectRootB = join(__dirname, "..", "..", "..", "data", "test-project-b")
const command = new EnvironmentDestroyCommand()

Expand Down
4 changes: 0 additions & 4 deletions test/src/commands/login.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@ import * as td from "testdouble"
import { LoginCommand } from "../../../src/commands/login"

describe("LoginCommand", () => {
afterEach(() => {
td.reset()
})

const command = new LoginCommand()

it("should log in to provider", async () => {
Expand Down
4 changes: 0 additions & 4 deletions test/src/commands/logout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@ import * as td from "testdouble"
import { LogoutCommand } from "../../../src/commands/logout"

describe("LogoutCommand", () => {
afterEach(() => {
td.reset()
})

const command = new LogoutCommand()

it("should log out from a provider", async () => {
Expand Down
4 changes: 0 additions & 4 deletions test/src/commands/push.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,6 @@ describe("PushCommand", () => {
})
})

afterEach(() => {
td.reset()
})

it("should build and push modules in a project", async () => {
const ctx = await getTestContext()
const command = new PushCommand()
Expand Down
2 changes: 0 additions & 2 deletions test/src/plugins/container.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ describe("container", () => {
td.replace(garden.buildDir, "syncDependencyProducts", () => null)
})

afterEach(() => td.reset())

const provider = { name: "container", config: {} }

async function getTestModule(moduleConfig: ContainerModuleConfig) {
Expand Down
4 changes: 2 additions & 2 deletions test/src/task-graph.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { join } from "path"
import { expect } from "chai"
import { Garden } from "../../src/garden"
import { Task } from "../../src/types/task"
import {
TaskGraph,
TaskResult,
TaskResults,
} from "../../src/task-graph"
import { makeTestGarden } from "../helpers"

const projectRoot = join(__dirname, "..", "data", "test-project-empty")

Expand Down Expand Up @@ -82,7 +82,7 @@ describe("task-graph", () => {

describe("TaskGraph", () => {
async function getContext() {
const garden = await Garden.factory(projectRoot)
const garden = await makeTestGarden(projectRoot)
return garden.pluginContext
}

Expand Down
4 changes: 0 additions & 4 deletions test/src/tasks/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@ import {
import { DeployTask } from "../../../src/tasks/deploy"

describe("DeployTask", () => {
afterEach(() => {
td.reset()
})

it("should fully resolve templated strings on the service before deploying", async () => {
process.env.TEST_VARIABLE = "banana"

Expand Down

0 comments on commit 1aa69fd

Please sign in to comment.