-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
52 changed files
with
2,024 additions
and
1,140 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,3 +43,5 @@ testem.log | |
# System Files | ||
.DS_Store | ||
Thumbs.db | ||
|
||
.nx/cache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,5 @@ | |
|
||
/dist | ||
/coverage | ||
|
||
/.nx/cache |
29 changes: 13 additions & 16 deletions
29
e2e/gcp-deployment-manager-e2e/tests/gcp-deployment-manager.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,24 @@ | ||
import { | ||
checkFilesExist, | ||
ensureNxProject, | ||
runNxCommandAsync, | ||
uniq | ||
runNxCommandAsync | ||
} from '@nx/plugin/testing' | ||
import { ensureNxProject } from '../../utils/workspace' | ||
|
||
describe('gcp-deployment-manager e2e', () => { | ||
beforeEach(() => { | ||
ensureNxProject( | ||
'@nx-extend/gcp-deployment-manager', | ||
'dist/packages/gcp-deployment-manager' | ||
) | ||
beforeAll(() => { | ||
ensureNxProject([ | ||
'@nx-extend/core:dist/packages/core', | ||
'@nx-extend/gcp-deployment-manager:dist/packages/gcp-deployment-manager' | ||
]) | ||
}) | ||
|
||
it('should be able to generate an deployment manager app', async () => { | ||
const plugin = uniq('gcp-deployment-manager') | ||
const appName = 'deployment-manager' | ||
|
||
await runNxCommandAsync( | ||
`generate @nx-extend/gcp-deployment-manager:init ${plugin}` | ||
) | ||
it('should be able to generate an deployment manager app', async () => { | ||
await runNxCommandAsync(`generate @nx-extend/gcp-deployment-manager:init ${appName}`) | ||
|
||
expect(() => | ||
checkFilesExist(`apps/${plugin}/src/deployment.yml`) | ||
).not.toThrow() | ||
expect(() => checkFilesExist( | ||
`${appName}/src/deployment.yml` | ||
)).not.toThrow() | ||
}, 300000) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,66 +1,55 @@ | ||
import { | ||
checkFilesExist, | ||
ensureNxProject, | ||
runNxCommandAsync, | ||
uniq | ||
rmDist, | ||
runNxCommandAsync | ||
} from '@nx/plugin/testing' | ||
import { ensureNxProject } from '../../utils/workspace' | ||
|
||
describe('(e2e) gcp-functions', () => { | ||
beforeEach(() => { | ||
ensureNxProject('@nx-extend/gcp-functions', 'dist/packages/gcp-functions') | ||
beforeAll(() => { | ||
ensureNxProject([ | ||
'@nx-extend/core:dist/packages/core', | ||
'@nx-extend/gcp-functions:dist/packages/gcp-functions' | ||
]) | ||
}) | ||
|
||
const appName = 'test-function' | ||
|
||
it('should be able to generate an empty function', async () => { | ||
const plugin = uniq('gcp-functions') | ||
await runNxCommandAsync(`generate @nx-extend/gcp-functions:init ${plugin}`) | ||
await runNxCommandAsync(`generate @nx-extend/gcp-functions:init ${appName}`) | ||
|
||
expect(() => | ||
checkFilesExist( | ||
`apps/${plugin}/src/main.ts`, | ||
`apps/${plugin}/src/environments/production.yaml` | ||
) | ||
).not.toThrow() | ||
expect(() => checkFilesExist( | ||
`${appName}/src/main.ts`, | ||
`${appName}/src/environments/production.yaml` | ||
)).not.toThrow() | ||
}, 300000) | ||
|
||
it('should be able to build a function', async () => { | ||
const plugin = uniq('gcp-functions') | ||
await runNxCommandAsync(`generate @nx-extend/gcp-functions:init ${plugin}`) | ||
await runNxCommandAsync(`build ${plugin}`) | ||
await runNxCommandAsync(`build ${appName}`) | ||
|
||
expect(() => | ||
checkFilesExist( | ||
`dist/apps/${plugin}/main.js`, | ||
`dist/apps/${plugin}/package.json` | ||
) | ||
).not.toThrow() | ||
expect(() => checkFilesExist( | ||
`dist/${appName}/main.js`, | ||
`dist/${appName}/package.json` | ||
)).not.toThrow() | ||
}, 300000) | ||
|
||
it('should be able to build a function and generate lock file', async () => { | ||
const plugin = uniq('gcp-functions-lock-file') | ||
await runNxCommandAsync(`generate @nx-extend/gcp-functions:init ${plugin}`) | ||
await runNxCommandAsync(`build ${plugin} --generateLockFile`) | ||
|
||
expect(() => | ||
checkFilesExist( | ||
`dist/apps/${plugin}/main.js`, | ||
`dist/apps/${plugin}/package.json`, | ||
`dist/apps/${plugin}/package-lock.json` | ||
) | ||
).not.toThrow() | ||
rmDist() | ||
await runNxCommandAsync(`build ${appName} --generateLockFile`) | ||
|
||
expect(() => checkFilesExist( | ||
`dist/${appName}/main.js`, | ||
`dist/${appName}/package.json`, | ||
`dist/${appName}/yarn.lock` | ||
)).not.toThrow() | ||
}, 300000) | ||
|
||
it('should be able the runner', async () => { | ||
const plugin = uniq('gcp-functions-runner') | ||
await runNxCommandAsync( | ||
`generate @nx-extend/gcp-functions:init-runner ${plugin}` | ||
) | ||
const runnerName = 'functions-runner' | ||
await runNxCommandAsync(`generate @nx-extend/gcp-functions:init-runner ${runnerName}`) | ||
|
||
expect(() => | ||
checkFilesExist( | ||
`apps/${plugin}/src/main.ts`, | ||
`apps/${plugin}/src/__runner.controller.ts`, | ||
`apps/${plugin}/src/__runner.module.ts` | ||
) | ||
).not.toThrow() | ||
expect(() => checkFilesExist( | ||
`${runnerName}/src/main.ts` | ||
)).not.toThrow() | ||
}, 300000) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,27 @@ | ||
import { | ||
checkFilesExist, | ||
ensureNxProject, | ||
runNxCommandAsync, | ||
uniq | ||
} from '@nx/plugin/testing' | ||
|
||
import { ensureNxProject } from '../../utils/workspace' | ||
|
||
describe('gcp-secrets e2e', () => { | ||
beforeEach(() => { | ||
ensureNxProject('@nx-extend/gcp-secrets', 'dist/packages/gcp-secrets') | ||
beforeAll(() => { | ||
ensureNxProject([ | ||
'@nx-extend/core:dist/packages/core', | ||
'@nx-extend/gcp-secrets:dist/packages/gcp-secrets' | ||
]) | ||
}) | ||
|
||
it('should be able to generate an secrets app', async () => { | ||
const plugin = uniq('gcp-functions') | ||
const appName = uniq('gcp-secrets') | ||
|
||
await runNxCommandAsync(`generate @nx-extend/gcp-secrets:init ${plugin}`) | ||
it('should be able to generate an secrets app', async () => { | ||
await runNxCommandAsync(`generate @nx-extend/gcp-secrets:init ${appName}`) | ||
|
||
expect(() => | ||
checkFilesExist( | ||
`apps/${plugin}/src/secret-one.json`, | ||
`apps/${plugin}/src/secret-two.json` | ||
) | ||
).not.toThrow() | ||
expect(() => checkFilesExist( | ||
`${appName}/src/secret-one.json`, | ||
`${appName}/src/secret-two.json` | ||
)).not.toThrow() | ||
}, 300000) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { execSync } from 'child_process' | ||
import { dirname } from 'path' | ||
import { cleanup, patchPackageJsonForPlugin, tmpProjPath } from '@nx/plugin/testing' | ||
import { mkdirSync } from 'fs' | ||
|
||
function runNxNewCommand(localTmpDir: string) { | ||
return execSync( | ||
`node ${require.resolve( | ||
'nx' | ||
)} new proj --nx-workspace-root=${localTmpDir} --no-interactive --skip-install --collection=@nx/workspace --npmScope=proj --preset=apps`, | ||
{ | ||
cwd: localTmpDir | ||
} | ||
) | ||
} | ||
|
||
/** | ||
* Ensures that a project has been setup in the e2e directory | ||
* It will also copy `@nx` packages to the e2e directory | ||
*/ | ||
export function ensureNxProject(patchPlugins: string[] = []): void { | ||
cleanup() | ||
|
||
const tmpProjectPath = tmpProjPath() | ||
const tmpProjectDir = dirname(tmpProjectPath) | ||
mkdirSync(tmpProjectDir, { | ||
recursive: true | ||
}) | ||
runNxNewCommand(tmpProjectDir) | ||
|
||
for (const plugin of patchPlugins) { | ||
const [npmPackageName, pluginDistPath] = plugin.split(':') | ||
patchPackageJsonForPlugin(npmPackageName, pluginDistPath) | ||
} | ||
|
||
execSync('touch yarn.lock', { | ||
cwd: tmpProjectPath, | ||
stdio: 'inherit', | ||
env: process.env | ||
}) | ||
execSync('yarn', { | ||
cwd: tmpProjectPath, | ||
stdio: 'inherit', | ||
env: process.env | ||
}) | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.