This repository has been archived by the owner on Apr 22, 2022. It is now read-only.
forked from Azure/powershell
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* initial commit * Create main.yml * Update main.yml * added action.yml * added action.yml * added action.yml * Delete main.yml * removed node_modules * changes in .gitignore * changes in PowerShellToolRunner * Added changes for review comments * added inputs in action.yml * changes in package.json * added review comments * Update action.yml * Update action.yml * fix in ScriptRunner.ts * changes in URL * added review comments * changes for review comments * added args in PowerShellToolRunner * changes in PowerShellToolRunner * fixed action.yml * removed debug logs * changes in main * added unit tests * added ci.yml * update tsconfig json * update ci.yml * added unit tests * update tests
- Loading branch information
Showing
8 changed files
with
4,708 additions
and
33 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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
on: | ||
pull_request: | ||
branches: | ||
- master | ||
push: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
build_test_job: | ||
name: 'Build and test job' | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
os: [windows-latest, ubuntu-latest, macos-latest] | ||
steps: | ||
|
||
- name: 'Checking out repo code' | ||
uses: actions/checkout@v2 | ||
|
||
- name: 'Validate build' | ||
run: | | ||
npm install | ||
npm run build | ||
- name: 'Run L0 tests' | ||
run: | | ||
npm run test |
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,22 @@ | ||
import InitializeAzure from '../src/InitializeAzure'; | ||
|
||
jest.mock('../src/Utilities/Utils'); | ||
jest.mock('../src/Utilities/PowerShellToolRunner'); | ||
|
||
afterEach(() => { | ||
jest.restoreAllMocks(); | ||
}); | ||
|
||
describe('Testing importAzModule', () => { | ||
let importAzModuleSpy; | ||
beforeEach(() => { | ||
importAzModuleSpy = jest.spyOn(InitializeAzure, 'importAzModule'); | ||
}); | ||
|
||
test('InitializeAzure importAzModule should pass', async () => { | ||
const azVersion: string = '9.0.0'; | ||
await InitializeAzure.importAzModule(azVersion); | ||
await InitializeAzure.importAzModule('latest'); | ||
expect(importAzModuleSpy).toHaveBeenCalledTimes(2); | ||
}); | ||
}); |
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,26 @@ | ||
import ScriptRunner from '../src/ScriptRunner'; | ||
|
||
jest.mock('../src/Utilities/FileUtils'); | ||
jest.mock('../src/Utilities/PowerShellToolRunner'); | ||
jest.mock('../src/Utilities/ScriptBuilder'); | ||
let scriptRunner: ScriptRunner; | ||
|
||
beforeAll(() => { | ||
scriptRunner = new ScriptRunner("inlineScript", "Stop", true); | ||
}); | ||
|
||
afterEach(() => { | ||
jest.restoreAllMocks(); | ||
}); | ||
|
||
describe('Testing ScriptRunner', () => { | ||
let executeFileSpy; | ||
beforeEach(() => { | ||
executeFileSpy = jest.spyOn(scriptRunner, 'executeFile'); | ||
}); | ||
test('executeFile should pass', async () => { | ||
executeFileSpy.mockImplementationOnce(() => Promise.resolve()); | ||
await scriptRunner.executeFile(); | ||
expect(executeFileSpy).toHaveBeenCalled(); | ||
}); | ||
}); |
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,57 @@ | ||
import Utils from '../../src/Utilities/Utils'; | ||
|
||
const version: string = '9.0.0'; | ||
const moduleName: string = 'az'; | ||
|
||
afterEach(() => { | ||
jest.restoreAllMocks(); | ||
}); | ||
|
||
describe('Testing isValidVersion', () => { | ||
const validVersion: string = '1.2.4'; | ||
const invalidVersion: string = 'a.bcd'; | ||
|
||
test('isValidVersion should be true', () => { | ||
expect(Utils.isValidVersion(validVersion)).toBeTruthy(); | ||
}); | ||
test('isValidVersion should be false', () => { | ||
expect(Utils.isValidVersion(invalidVersion)).toBeFalsy(); | ||
}); | ||
}); | ||
|
||
describe('Testing setPSModulePath', () => { | ||
test('PSModulePath with azPSVersion non-empty', () => { | ||
Utils.setPSModulePath(version); | ||
expect(process.env.PSModulePath).toContain(version); | ||
}); | ||
test('PSModulePath with azPSVersion empty', () => { | ||
const prevPSModulePath = process.env.PSModulePath; | ||
Utils.setPSModulePath(); | ||
expect(process.env.PSModulePath).not.toEqual(prevPSModulePath); | ||
}); | ||
}); | ||
|
||
describe('Testing getLatestModule', () => { | ||
let getLatestModuleSpy; | ||
|
||
beforeEach(() => { | ||
getLatestModuleSpy = jest.spyOn(Utils, 'getLatestModule'); | ||
}); | ||
test('getLatestModule should pass', async () => { | ||
getLatestModuleSpy.mockImplementationOnce((_moduleName: string) => Promise.resolve(version)); | ||
await Utils.getLatestModule(moduleName); | ||
expect(getLatestModuleSpy).toHaveBeenCalled(); | ||
}); | ||
}); | ||
|
||
describe('Testing checkModuleVersion', () => { | ||
let checkModuleVersionSpy; | ||
beforeEach(() => { | ||
checkModuleVersionSpy = jest.spyOn(Utils, 'checkModuleVersion'); | ||
}); | ||
test('checkModuleVersion should pass', async () => { | ||
checkModuleVersionSpy.mockImplementationOnce((_moduleName: string, _version: string) => Promise.resolve()); | ||
await Utils.checkModuleVersion(moduleName, version); | ||
expect(checkModuleVersionSpy).toHaveBeenCalled(); | ||
}); | ||
}); |
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,15 @@ | ||
// For a detailed explanation regarding each configuration property, visit: | ||
// https://jestjs.io/docs/en/configuration.html | ||
|
||
module.exports = { | ||
clearMocks: true, | ||
moduleFileExtensions: ['js', 'ts'], | ||
testEnvironment: 'node', | ||
testMatch: ['**/*.test.ts'], | ||
testRunner: 'jest-circus/runner', | ||
transform: { | ||
'^.+\\.ts$': 'ts-jest' | ||
}, | ||
verbose: true | ||
}; | ||
|
Oops, something went wrong.