Skip to content

Commit

Permalink
Showing 12 changed files with 168 additions and 73 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -2,3 +2,6 @@
node_modules/*
bin
.out-bin
.nyc_output
.vscode
.idea
8 changes: 8 additions & 0 deletions .mocharc.json.ignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extensions": ["ts"],
"spec": ["z_tests/**/*.test.ts"],
"node-option": [
"experimental-specifier-resolution=node",
"loader=ts-node/esm"
]
}
4 changes: 4 additions & 0 deletions .ncurc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"upgrade": true,
"reject": ["mocha"]
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
126 changes: 94 additions & 32 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -20,7 +20,7 @@
"import": "pulumi stack import --file state.json",
"test-leak": "cross-env PULUMI_DEBUG_PROMISE_LEAKS=true TS_NODE_PROJECT='./tsconfig.test.json' mocha --timeout 10000 -r ts-node/register 'z_tests/**/*.ts'",
"test": "cross-env TS_NODE_PROJECT='./tsconfig.test.json' mocha --timeout 10000 -r ts-node/register 'z_tests/**/*.test.ts'",
"testcert": "cross-env TS_NODE_PROJECT='./tsconfig.test.json' mocha --timeout 10000 -r ts-node/register 'z_tests/**/cert.test.ts'",
"testcert": "cross-env TS_NODE_PROJECT='./tsconfig.test.json' mocha --timeout 10000 -r ts-node/register '**/*.ts'",
"test-cover": "cross-env TS_NODE_PROJECT='./tsconfig.test.json' nyc mocha --timeout 10000 -r ts-node/register 'z_tests/**/*.ts'",
"lint": "eslint **/*.ts",
"lint:fix": "eslint **/*.ts --fix"
@@ -39,7 +39,7 @@
"eslint": "^8.57.0",
"husky": "^9.0.11",
"lint-staged": "^15.2.2",
"mocha": "^10.3.0",
"mocha": "^9.2.2",
"nyc": "^15.1.0",
"ts-node": "^10.9.2",
"typescript": "^5.4.2"
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
@@ -10,6 +10,7 @@
"experimentalDecorators": true,
"noFallthroughCasesInSwitch": true,
"forceConsistentCasingInFileNames": true,
"noImplicitAny": true,
"strict": true
},
"files": [
@@ -226,7 +227,7 @@
"**/*.ts"
],
"exclude": [
"**/node_modules",
"node_modules",
"z_tests",
".out-bin",
".tools",
21 changes: 16 additions & 5 deletions tsconfig.test.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,23 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"module": "CommonJS",
"target": "esnext",
"module": "commonjs",
"moduleResolution": "NodeNext",
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"noImplicitAny": false
},
"files": ["index.ts"],
"include": ["**/*.ts"],
"exclude": ["**/node_modules",".out-bin"]
"ts-node": {
"esm": true
},
"include": [
"**/*.ts",
"**/*.d.ts",
"z_tests/**/*.ts"
],
"exclude": [
"node_modules",
".out-bin",
".tools",
]
}
72 changes: 39 additions & 33 deletions z_tests/_tools/Mocks.ts
Original file line number Diff line number Diff line change
@@ -16,40 +16,46 @@ const tryFindName = (props: any) => {
return name;
};

export default pulumi.runtime.setMocks({
newResource: (
args: pulumi.runtime.MockResourceArgs
): {
id: string;
name: string;
state: any;
} => {
const name = tryFindName(args.inputs);
//console.log(`Mocks resource ${name}`);
export default pulumi.runtime.setMocks(
{
newResource: (
args: pulumi.runtime.MockResourceArgs
): {
id: string;
name: string;
state: any;
} => {
const name = tryFindName(args.inputs);
//console.log(`Mocks resource ${name}`);

return {
id: `/subscriptions/12345/resourceGroups/resr-group/providers/${name}`,
name,
state: {
name,
...args.inputs,
result: args.type.includes('Random')
? '5c1c5657-085b-41c8-8d11-de897e70eae7'
: name.endsWith('ssh')
? {
publicKey: '1234567890',
privateKey: '1234567890',
}
: '',
},
};
},
call: (args: pulumi.runtime.MockCallArgs) => {
if (args.token === 'azure:core/getSubscription:getSubscription')
return {
id: '00000000-0000-0000-0000-000000000000',
display_name: 'subscription',
id: `/subscriptions/12345/resourceGroups/resr-group/providers/${name}`,
name,
state: {
name,
...args.inputs,
result: args.type.includes('Random')
? '5c1c5657-085b-41c8-8d11-de897e70eae7'
: name.endsWith('ssh')
? {
publicKey: '1234567890',
privateKey: '1234567890',
}
: '',
},
};
return args.inputs;
},
call: (args: pulumi.runtime.MockCallArgs) => {
if (args.token === 'azure:core/getSubscription:getSubscription')
return {
id: '00000000-0000-0000-0000-000000000000',
display_name: 'subscription',
};
return args.inputs;
},
},
});
'testProject',
'testStack',
false,
'testOrganization'
);

0 comments on commit 129ad9b

Please sign in to comment.