From 77abbe341c20d3fccb159947214291195e565417 Mon Sep 17 00:00:00 2001 From: Thorarinn Sigurdsson Date: Fri, 15 Mar 2019 14:16:53 +0100 Subject: [PATCH] fix(integ-tests): helper to remove .garden dirs Removing the .garden dirs of the projects used before running the integration tests makes for a more neutral/standardised initial state. --- garden-service/test/integ-helpers.ts | 10 ++++++++++ garden-service/test/integ/src/pre-release.ts | 5 +++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/garden-service/test/integ-helpers.ts b/garden-service/test/integ-helpers.ts index 727149f9cf..eabcb42ceb 100644 --- a/garden-service/test/integ-helpers.ts +++ b/garden-service/test/integ-helpers.ts @@ -1,5 +1,9 @@ import * as execa from "execa" +import * as Bluebird from "bluebird" +import { remove } from "fs-extra" import { get, intersection } from "lodash" +import { resolve } from "path" +import { GARDEN_DIR_NAME } from "../src/constants" import { KubeApi } from "../src/plugins/kubernetes/api" import { deleteNamespaces } from "../src/plugins/kubernetes/init" import { TaskLogStatus } from "../src/logger/log-entry" @@ -8,6 +12,12 @@ import { getAllNamespaces } from "../src/plugins/kubernetes/namespace" import { getExampleProjects } from "./helpers" import { WatchTestConditionState } from "./run-garden" +export async function removeExampleDotGardenDirs() { + await Bluebird.map(Object.values(getExampleProjects()), (projectRoot) => { + return remove(resolve(projectRoot, GARDEN_DIR_NAME)) + }) +} + export async function deleteExampleNamespaces(includeSystemNamespaces = false) { const namespacesToDelete: string[] = [] diff --git a/garden-service/test/integ/src/pre-release.ts b/garden-service/test/integ/src/pre-release.ts index d80844c3db..250fcbf017 100644 --- a/garden-service/test/integ/src/pre-release.ts +++ b/garden-service/test/integ/src/pre-release.ts @@ -12,7 +12,7 @@ import { runGarden, taskCompletedStep, } from "../../run-garden" -import { deleteExampleNamespaces, searchLog } from "../../integ-helpers" +import { deleteExampleNamespaces, searchLog, removeExampleDotGardenDirs } from "../../integ-helpers" // TODO: Add test for verifying that CLI returns with an error when called with an unknown command @@ -21,8 +21,9 @@ describe("PreReleaseTests", () => { const simpleProjectPath = resolve(examplesDir, "simple-project") before(async () => { - mlog.log("deleting example project namespaces") + mlog.log("deleting example project namespaces and .garden folders") await deleteExampleNamespaces(false) + await removeExampleDotGardenDirs() }) after(async () => {