This repository was archived by the owner on Jan 15, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 86
chore: @microsoft/generator-bot-adaptive happy path unit tests #1091
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
d52327d
Adding Mocha unit test support to generator-bot-adaptive; implemented…
peterinnesmsft 909d94c
Further progress on .NET Web App generator unit tests for generator-b…
peterinnesmsft 1547882
Implementing basic happy path unit tests for generator-bot-adaptive f…
peterinnesmsft 52827f7
Addressing majority of eslint errors except for escape char errors in…
peterinnesmsft c72d877
Fixing remaining eslint issues around regular expressions in dotnet-w…
peterinnesmsft a21ca1c
Merge branch 'main' into peterinnesmsft/generator_unit_tests
peterinnesmsft d1e6286
Merge branch 'main' into peterinnesmsft/generator_unit_tests
peterinnesmsft c258275
Renaming tests dir to test.
peterinnesmsft 28b1e92
Addressing PR feedback from Josh.
peterinnesmsft 1ad87a0
Fixing references to platform in child generators to correctly use na…
peterinnesmsft File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,6 +1,7 @@ | ||
| { | ||
| "env": { | ||
| "es6": true, | ||
| "es2017": true, | ||
| "mocha": true, | ||
| "node": true | ||
| }, | ||
| "extends": ["eslint:recommended"], | ||
|
|
||
This file contains hidden or 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,7 @@ | ||
| { | ||
| "checkLeaks": true, | ||
| "exit": true, | ||
| "forbidOnly": true, | ||
| "forbidPending": true, | ||
| "recursive": true | ||
| } |
This file contains hidden or 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
308 changes: 308 additions & 0 deletions
308
generators/generator-bot-adaptive/test/dotnet-functions.test.js
This file contains hidden or 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,308 @@ | ||
| // Copyright (c) Microsoft Corporation. | ||
| // Licensed under the MIT License. | ||
|
|
||
| const fs = require('fs'); | ||
| const helpers = require('yeoman-test'); | ||
| const path = require('path'); | ||
| const TemplateFileReader = require('./templateFileReader'); | ||
|
|
||
| const botName = 'DotNetFunctions'; | ||
| const generatorPath = path.join(__dirname, '..', 'generators', 'app'); | ||
| const integration = 'functions'; | ||
| const platform = 'dotnet'; | ||
| const reader = new TemplateFileReader(path.join(generatorPath, 'templates')); | ||
|
|
||
| describe(`generator-bot-adaptive --platform ${platform} --integration ${integration}`, function () { | ||
| let runResult; | ||
|
|
||
| before(async function () { | ||
| runResult = await helpers | ||
| .create(generatorPath) | ||
| .withArguments([botName]) | ||
| .withOptions({ platform, integration }) | ||
| .run(); | ||
| }); | ||
|
|
||
| after(function () { | ||
| if (runResult) { | ||
| runResult.restore(); | ||
| } | ||
| }); | ||
|
|
||
| it(`should create file ${botName}.sln`, function () { | ||
| const filePath = path.join(`${botName}.sln`); | ||
|
|
||
| const actualContent = fs.readFileSync(filePath).toString('utf8'); | ||
| const projectType = 'FAE04EC0-301F-11D3-BF4B-00C04F79EFBC'; | ||
|
|
||
| const botProjectGuidExpression = new RegExp( | ||
| `Project\\(\\"\\{${projectType}\\}\\"\\) = \\"${botName}\\", ` + | ||
| `\\"${botName}\\\\${botName}.csproj\\", ` + | ||
| `\\"\\{(.+)\\}\\"`, | ||
| 'gi' | ||
| ); | ||
|
|
||
| const botProjectGuid = botProjectGuidExpression.exec(actualContent)[1]; | ||
|
|
||
| const solutionGuidExpression = /SolutionGuid = \{(.+)\}/gi; | ||
| const solutionGuid = solutionGuidExpression.exec(actualContent)[1]; | ||
|
|
||
| const content = reader.getTemplateFileContent( | ||
| path.join('dotnet', 'botName.sln'), | ||
| { | ||
| botName, | ||
| botProjectGuid, | ||
| projectType, | ||
| solutionGuid, | ||
| } | ||
| ); | ||
|
|
||
| runResult.assertFileContent(filePath, content); | ||
| }); | ||
|
|
||
| it(`should create file ${path.join( | ||
| botName, | ||
| 'ActivitySerializationSettings.cs' | ||
| )}`, function () { | ||
| const filePath = path.join(botName, 'ActivitySerializationSettings.cs'); | ||
| const content = reader.getTemplateFileContent( | ||
| path.join('dotnet', 'functions', 'ActivitySerializationSettings.cs'), | ||
| { | ||
| botName, | ||
| } | ||
| ); | ||
|
|
||
| runResult.assertFileContent(filePath, content); | ||
| }); | ||
|
|
||
| it(`should create file ${path.join( | ||
| botName, | ||
| 'appsettings.json' | ||
| )}`, function () { | ||
| const filePath = path.join(botName, 'appsettings.json'); | ||
| const content = reader.getJsonFileContent( | ||
| path.join('assets', 'appsettings.json'), | ||
| { | ||
| luis: { | ||
| name: botName, | ||
| }, | ||
| runtime: { | ||
| command: `func start --script-root ${path.join( | ||
| 'bin', | ||
| 'Debug', | ||
| 'netcoreapp3.1' | ||
| )}`, | ||
| key: `adaptive-runtime-${platform}-${integration}`, | ||
| }, | ||
| } | ||
| ); | ||
|
|
||
| runResult.assertJsonFileContent(filePath, content); | ||
| }); | ||
|
|
||
| it(`should create file ${path.join( | ||
| botName, | ||
| `${botName}.botproj` | ||
| )}`, function () { | ||
| const filePath = path.join(botName, `${botName}.botproj`); | ||
| const content = reader.getJsonFileContent( | ||
| path.join('assets', 'botName.botproj'), | ||
| { | ||
| name: botName, | ||
| } | ||
| ); | ||
|
|
||
| runResult.assertJsonFileContent(filePath, content); | ||
| }); | ||
|
|
||
| it(`should create file ${path.join( | ||
| botName, | ||
| `${botName}.csproj` | ||
| )}`, function () { | ||
| const filePath = path.join(botName, `${botName}.csproj`); | ||
| const content = reader.getTemplateFileContent( | ||
| path.join('dotnet', 'functions', 'botName.csproj'), | ||
| { | ||
| botName, | ||
| packageReferences: '', | ||
| sdkVersion: '4.13.2', | ||
| } | ||
| ); | ||
|
|
||
| runResult.assertFileContent(filePath, content); | ||
| }); | ||
|
|
||
| it(`should create file ${path.join(botName, 'host.json')}`, function () { | ||
| const filePath = path.join(botName, 'host.json'); | ||
| const content = reader.getFileContent( | ||
| path.join('dotnet', 'functions', 'host.json') | ||
| ); | ||
|
|
||
| runResult.assertFileContent(filePath, content); | ||
| }); | ||
|
|
||
| it(`should create file ${path.join( | ||
| botName, | ||
| 'local.settings.json' | ||
| )}`, function () { | ||
| const filePath = path.join(botName, 'local.settings.json'); | ||
| const content = reader.getFileContent( | ||
| path.join('dotnet', 'functions', 'local.settings.json') | ||
| ); | ||
|
|
||
| runResult.assertFileContent(filePath, content); | ||
| }); | ||
|
|
||
| it(`should create file ${path.join(botName, 'Startup.cs')}`, function () { | ||
| const filePath = path.join(botName, 'Startup.cs'); | ||
| const content = reader.getTemplateFileContent( | ||
| path.join('dotnet', 'functions', 'Startup.cs'), | ||
| { | ||
| botName, | ||
| settingsDirectory: 'string.Empty', | ||
| } | ||
| ); | ||
|
|
||
| runResult.assertFileContent(filePath, content); | ||
| }); | ||
|
|
||
| it(`should create file ${path.join( | ||
| botName, | ||
| 'Properties', | ||
| 'serviceDependencies.json' | ||
| )}`, function () { | ||
| const filePath = path.join( | ||
| botName, | ||
| 'Properties', | ||
| 'serviceDependencies.json' | ||
| ); | ||
| const content = reader.getFileContent( | ||
| path.join('dotnet', 'functions', 'Properties', 'serviceDependencies.json') | ||
| ); | ||
|
|
||
| runResult.assertFileContent(filePath, content); | ||
| }); | ||
|
|
||
| it(`should create file ${path.join( | ||
| botName, | ||
| 'Properties', | ||
| 'serviceDependencies.local.json' | ||
| )}`, function () { | ||
| const filePath = path.join( | ||
| botName, | ||
| 'Properties', | ||
| 'serviceDependencies.local.json' | ||
| ); | ||
|
|
||
| const content = reader.getFileContent( | ||
| path.join( | ||
| 'dotnet', | ||
| 'functions', | ||
| 'Properties', | ||
| 'serviceDependencies.local.json' | ||
| ) | ||
| ); | ||
|
|
||
| runResult.assertFileContent(filePath, content); | ||
| }); | ||
|
|
||
| it(`should create file ${path.join( | ||
| botName, | ||
| 'Triggers', | ||
| 'MessagesTrigger.cs' | ||
| )}`, function () { | ||
| const filePath = path.join(botName, 'Triggers', 'MessagesTrigger.cs'); | ||
| const content = reader.getTemplateFileContent( | ||
| path.join('dotnet', 'functions', 'Triggers', 'MessagesTrigger.cs'), | ||
| { | ||
| botName, | ||
| } | ||
| ); | ||
|
|
||
| runResult.assertFileContent(filePath, content); | ||
| }); | ||
|
|
||
| it(`should create file ${path.join( | ||
| botName, | ||
| 'Triggers', | ||
| 'SkillsTrigger.cs' | ||
| )}`, function () { | ||
| const filePath = path.join(botName, 'Triggers', 'SkillsTrigger.cs'); | ||
| const content = reader.getTemplateFileContent( | ||
| path.join('dotnet', 'functions', 'Triggers', 'SkillsTrigger.cs'), | ||
| { | ||
| botName, | ||
| } | ||
| ); | ||
|
|
||
| runResult.assertFileContent(filePath, content); | ||
| }); | ||
|
|
||
| it(`should create file ${path.join( | ||
| botName, | ||
| 'Triggers', | ||
| 'StaticFilesTrigger.cs' | ||
| )}`, function () { | ||
| const filePath = path.join(botName, 'Triggers', 'StaticFilesTrigger.cs'); | ||
| const content = reader.getTemplateFileContent( | ||
| path.join('dotnet', 'functions', 'Triggers', 'StaticFilesTrigger.cs'), | ||
| { | ||
| botName, | ||
| } | ||
| ); | ||
|
|
||
| runResult.assertFileContent(filePath, content); | ||
| }); | ||
|
|
||
| it(`should create file ${path.join( | ||
| botName, | ||
| 'schemas', | ||
| 'sdk.schema' | ||
| )}`, function () { | ||
| const filePath = path.join(botName, 'schemas', 'sdk.schema'); | ||
| const content = reader.getFileContent( | ||
| path.join('assets', 'schemas', 'sdk.schema') | ||
| ); | ||
|
|
||
| runResult.assertFileContent(filePath, content); | ||
| }); | ||
|
|
||
| it(`should create file ${path.join( | ||
| botName, | ||
| 'schemas', | ||
| 'sdk.uischema' | ||
| )}`, function () { | ||
| const filePath = path.join(botName, 'schemas', 'sdk.uischema'); | ||
| const content = reader.getFileContent( | ||
| path.join('assets', 'schemas', 'sdk.uischema') | ||
| ); | ||
|
|
||
| runResult.assertFileContent(filePath, content); | ||
| }); | ||
|
|
||
| it(`should create file ${path.join( | ||
| botName, | ||
| 'schemas', | ||
| 'update-schema.ps1' | ||
| )}`, function () { | ||
| const filePath = path.join(botName, 'schemas', 'update-schema.ps1'); | ||
| const content = reader.getFileContent( | ||
| path.join('assets', 'schemas', 'update-schema.ps1') | ||
| ); | ||
|
|
||
| runResult.assertFileContent(filePath, content); | ||
| }); | ||
|
|
||
| it(`should create file ${path.join( | ||
| botName, | ||
| 'schemas', | ||
| 'update-schema.sh' | ||
| )}`, function () { | ||
| const filePath = path.join(botName, 'schemas', 'update-schema.sh'); | ||
| const content = reader.getFileContent( | ||
| path.join('assets', 'schemas', 'update-schema.sh') | ||
| ); | ||
|
|
||
| runResult.assertFileContent(filePath, content); | ||
| }); | ||
| }); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.