Skip to content
This repository was archived by the owner on Apr 13, 2020. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions src/commands/deployment/dashboard.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/camelcase */
jest.mock("open");
import open from "open";
jest.mock("../../config");
Expand Down Expand Up @@ -30,18 +31,18 @@ afterAll(() => {

const mockConfig = (): void => {
(Config as jest.Mock).mockReturnValueOnce({
"azure_devops": {
"access_token": uuid(),
azure_devops: {
access_token: uuid(),
org: uuid(),
project: uuid()
},
introspection: {
azure: {
"account_name": uuid(),
account_name: uuid(),
key: uuid(),
"partition_key": uuid(),
"source_repo_access_token": "test_token",
"table_name": uuid()
partition_key: uuid(),
source_repo_access_token: "test_token",
table_name: uuid()
}
}
});
Expand Down Expand Up @@ -208,8 +209,8 @@ describe("Fallback to azure devops access token", () => {
describe("Extract manifest repository information", () => {
test("Manifest repository information is successfully extracted", () => {
(Config as jest.Mock).mockReturnValue({
"azure_devops": {
"manifest_repository":
azure_devops: {
manifest_repository:
"https://dev.azure.com/bhnook/fabrikam/_git/materialized"
}
});
Expand Down
25 changes: 13 additions & 12 deletions src/commands/deployment/validate.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/camelcase */
// imports
import uuid from "uuid/v4";
import * as deploymenttable from "../../lib/azure/deploymenttable";
Expand Down Expand Up @@ -134,16 +135,16 @@ afterAll(() => {
describe("Validate deployment configuration", () => {
test("valid deployment configuration", async () => {
const config: ConfigYaml = {
"azure_devops": {
azure_devops: {
org: uuid(),
project: uuid()
},
introspection: {
azure: {
"account_name": uuid(),
account_name: uuid(),
key: Promise.resolve(uuid()),
"partition_key": uuid(),
"table_name": uuid()
partition_key: uuid(),
table_name: uuid()
}
}
};
Expand Down Expand Up @@ -210,7 +211,7 @@ describe("test runSelfTest function", () => {
introspection: {
azure: {
key: Promise.resolve(uuid()),
"table_name": undefined
table_name: undefined
}
}
};
Expand All @@ -229,7 +230,7 @@ describe("test runSelfTest function", () => {
introspection: {
azure: {
key: Promise.resolve(uuid()),
"table_name": undefined
table_name: undefined
}
}
};
Expand All @@ -244,7 +245,7 @@ describe("test runSelfTest function", () => {
introspection: {
azure: {
key: Promise.resolve(uuid()),
"table_name": undefined
table_name: undefined
}
}
};
Expand Down Expand Up @@ -277,7 +278,7 @@ describe("Validate missing deployment.storage configuration", () => {
const config: ConfigYaml = {
introspection: {
azure: {
"account_name": undefined,
account_name: undefined,
key: Promise.resolve(uuid())
}
}
Expand All @@ -292,7 +293,7 @@ describe("Validate missing deployment.storage configuration", () => {
introspection: {
azure: {
key: Promise.resolve(uuid()),
"table_name": undefined
table_name: undefined
}
}
};
Expand All @@ -306,7 +307,7 @@ describe("Validate missing deployment.storage configuration", () => {
introspection: {
azure: {
key: Promise.resolve(uuid()),
"partition_key": undefined
partition_key: undefined
}
}
};
Expand Down Expand Up @@ -343,7 +344,7 @@ describe("Validate missing deployment.pipeline configuration", () => {
describe("Validate missing deployment.pipeline configuration", () => {
test("missing deployment.pipeline.org configuration", async () => {
const config: ConfigYaml = {
"azure_devops": {
azure_devops: {
org: undefined
},
introspection: {
Expand All @@ -359,7 +360,7 @@ describe("Validate missing deployment.pipeline configuration", () => {
describe("Validate missing deployment.pipeline configuration", () => {
test("missing deployment.pipeline.project configuration", async () => {
const config: ConfigYaml = {
"azure_devops": {
azure_devops: {
org: "org",
project: undefined
},
Expand Down
29 changes: 15 additions & 14 deletions src/commands/init.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/camelcase */
import axios from "axios";
import fs from "fs";
import inquirer from "inquirer";
Expand Down Expand Up @@ -106,8 +107,8 @@ describe("Test execute function", () => {
describe("test getConfig function", () => {
it("with configuration file", () => {
const mockedValues = {
"azure_devops": {
"access_token": "access_token",
azure_devops: {
access_token: "access_token",
org: "org",
project: "project"
}
Expand All @@ -124,8 +125,8 @@ describe("test getConfig function", () => {
});
const cfg = getConfig();
expect(cfg).toStrictEqual({
"azure_devops": {
"access_token": "",
azure_devops: {
access_token: "",
org: "",
project: ""
}
Expand All @@ -141,7 +142,7 @@ describe("test validatePersonalAccessToken function", () => {
})
);
const result = await validatePersonalAccessToken({
"access_token": "token",
access_token: "token",
org: "org",
project: "project"
});
Expand All @@ -153,7 +154,7 @@ describe("test validatePersonalAccessToken function", () => {
.spyOn(axios, "get")
.mockReturnValueOnce(Promise.reject(new Error("fake")));
const result = await validatePersonalAccessToken({
"access_token": "token",
access_token: "token",
org: "org",
project: "project"
});
Expand All @@ -166,16 +167,16 @@ const testHandleInteractiveModeFunc = async (
verified: boolean
): Promise<void> => {
jest.spyOn(init, "getConfig").mockReturnValueOnce({
"azure_devops": {
"access_token": "",
azure_devops: {
access_token: "",
org: "",
project: ""
}
});
jest.spyOn(init, "prompt").mockResolvedValueOnce({
"azdo_org_name": "org_name",
"azdo_pat": "pat",
"azdo_project_name": "project"
azdo_org_name: "org_name",
azdo_pat: "pat",
azdo_project_name: "project"
});
jest
.spyOn(init, "validatePersonalAccessToken")
Expand Down Expand Up @@ -206,9 +207,9 @@ describe("test handleInteractiveMode function", () => {
describe("test prompt function", () => {
it("positive test", async done => {
const answers = {
"azdo_org_name": "org",
"azdo_pat": "pat",
"azdo_project_name": "project"
azdo_org_name: "org",
azdo_pat: "pat",
azdo_project_name: "project"
};
jest.spyOn(inquirer, "prompt").mockResolvedValueOnce(answers);
const ans = await prompt({});
Expand Down
11 changes: 6 additions & 5 deletions src/commands/init.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/camelcase */
import axios from "axios";
import commander from "commander";
import fs from "fs";
Expand Down Expand Up @@ -76,9 +77,9 @@ export const prompt = async (curConfig: ConfigYaml): Promise<Answer> => {
];
const answers = await inquirer.prompt(questions);
return {
"azdo_org_name": answers.azdo_org_name as string,
"azdo_pat": answers.azdo_pat as string,
"azdo_project_name": answers.azdo_project_name as string
azdo_org_name: answers.azdo_org_name as string,
azdo_pat: answers.azdo_pat as string,
azdo_project_name: answers.azdo_project_name as string
};
};

Expand All @@ -93,8 +94,8 @@ export const getConfig = (): ConfigYaml => {
} catch (_) {
// current config is not found.
return {
"azure_devops": {
"access_token": "",
azure_devops: {
access_token: "",
org: "",
project: ""
}
Expand Down
13 changes: 7 additions & 6 deletions src/commands/setup.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/camelcase */
import path from "path";
import { readYaml } from "../config";
import * as config from "../config";
Expand Down Expand Up @@ -37,7 +38,7 @@ describe("test createSPKConfig function", () => {
createSPKConfig(mockRequestContext);
const data = readYaml<ConfigYaml>(tmpFile);
expect(data.azure_devops).toStrictEqual({
"access_token": "pat",
access_token: "pat",
org: "orgname",
project: "project"
});
Expand All @@ -56,16 +57,16 @@ describe("test createSPKConfig function", () => {

const data = readYaml<ConfigYaml>(tmpFile);
expect(data.azure_devops).toStrictEqual({
"access_token": "pat",
access_token: "pat",
org: "orgname",
project: "project"
});
expect(data.introspection).toStrictEqual({
azure: {
"service_principal_id": rc.servicePrincipalId,
"service_principal_secret": rc.servicePrincipalPassword,
"subscription_id": rc.subscriptionId,
"tenant_id": rc.servicePrincipalTenantId
service_principal_id: rc.servicePrincipalId,
service_principal_secret: rc.servicePrincipalPassword,
subscription_id: rc.subscriptionId,
tenant_id: rc.servicePrincipalTenantId
}
});
});
Expand Down
17 changes: 9 additions & 8 deletions src/commands/setup.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/camelcase */
import commander from "commander";
import fs from "fs";
import yaml from "js-yaml";
Expand Down Expand Up @@ -45,23 +46,23 @@ interface APIError {
export const createSPKConfig = (rc: RequestContext): void => {
const data = rc.toCreateAppRepo
? {
"azure_devops": {
"access_token": rc.accessToken,
azure_devops: {
access_token: rc.accessToken,
org: rc.orgName,
project: rc.projectName
},
introspection: {
azure: {
"service_principal_id": rc.servicePrincipalId,
"service_principal_secret": rc.servicePrincipalPassword,
"subscription_id": rc.subscriptionId,
"tenant_id": rc.servicePrincipalTenantId
service_principal_id: rc.servicePrincipalId,
service_principal_secret: rc.servicePrincipalPassword,
subscription_id: rc.subscriptionId,
tenant_id: rc.servicePrincipalTenantId
}
}
}
: {
"azure_devops": {
"access_token": rc.accessToken,
azure_devops: {
access_token: rc.accessToken,
org: rc.orgName,
project: rc.projectName
}
Expand Down
Loading