mirror of
https://github.com/trympet/nextcloud-artifacts-action.git
synced 2025-04-28 05:36:08 +02:00
add simple integration test
This commit is contained in:
parent
518c6f09f4
commit
7a45cee3de
37
__tests__/doubles/InputsDouble.ts
Normal file
37
__tests__/doubles/InputsDouble.ts
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
/* eslint-disable @typescript-eslint/no-non-null-assertion */
|
||||||
|
import { Inputs } from '../../src/Inputs'
|
||||||
|
import { NoFileOption } from '../../src/NoFileOption'
|
||||||
|
|
||||||
|
export class InputsDouble implements Inputs {
|
||||||
|
get ArtifactName(): string {
|
||||||
|
return process.env['ARTIFACT_NAME']!
|
||||||
|
}
|
||||||
|
|
||||||
|
get ArtifactPath(): string {
|
||||||
|
return process.env['ARTIFACT_PATH']!
|
||||||
|
}
|
||||||
|
|
||||||
|
get Retention(): string {
|
||||||
|
return ''
|
||||||
|
}
|
||||||
|
|
||||||
|
get Endpoint(): string {
|
||||||
|
return process.env['ENDPOINT']!
|
||||||
|
}
|
||||||
|
|
||||||
|
get Username(): string {
|
||||||
|
return process.env['USERNAME']!
|
||||||
|
}
|
||||||
|
|
||||||
|
get Password(): string {
|
||||||
|
return process.env['PASSWORD']!
|
||||||
|
}
|
||||||
|
|
||||||
|
get Token(): string {
|
||||||
|
return process.env['TOKEN']!
|
||||||
|
}
|
||||||
|
|
||||||
|
get NoFileBehvaior(): NoFileOption {
|
||||||
|
return NoFileOption.error
|
||||||
|
}
|
||||||
|
}
|
0
__tests__/fixtures/test-artifact/a.txt
Normal file
0
__tests__/fixtures/test-artifact/a.txt
Normal file
0
__tests__/fixtures/test-artifact/some-folder/b.txt
Normal file
0
__tests__/fixtures/test-artifact/some-folder/b.txt
Normal file
9
__tests__/integration.test.ts
Normal file
9
__tests__/integration.test.ts
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
import { NextcloudArtifact } from '../src/nextcloud/NextcloudArtifact'
|
||||||
|
import { InputsDouble } from './doubles/InputsDouble'
|
||||||
|
|
||||||
|
describe('integration tests', () => {
|
||||||
|
it('works', async () => {
|
||||||
|
const artifact = new NextcloudArtifact(new InputsDouble())
|
||||||
|
await artifact.run()
|
||||||
|
})
|
||||||
|
})
|
1
__tests__/setup.ts
Normal file
1
__tests__/setup.ts
Normal file
@ -0,0 +1 @@
|
|||||||
|
require("dotenv").config()
|
12
jest.config.js
Normal file
12
jest.config.js
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
module.exports = {
|
||||||
|
clearMocks: true,
|
||||||
|
moduleFileExtensions: ['js', 'ts'],
|
||||||
|
testEnvironment: 'node',
|
||||||
|
testMatch: ['**/*.test.ts'],
|
||||||
|
testRunner: 'jest-circus/runner',
|
||||||
|
transform: {
|
||||||
|
'^.+\\.ts$': 'ts-jest'
|
||||||
|
},
|
||||||
|
verbose: true,
|
||||||
|
setupFiles: ["./__tests__/setup.ts"]
|
||||||
|
}
|
15
package.json
15
package.json
@ -8,7 +8,8 @@
|
|||||||
"format": "prettier --write **/*.ts",
|
"format": "prettier --write **/*.ts",
|
||||||
"format-check": "prettier --check **/*.ts",
|
"format-check": "prettier --check **/*.ts",
|
||||||
"lint": "eslint src/**/*.ts",
|
"lint": "eslint src/**/*.ts",
|
||||||
"package": "npx ncc build --source-map --license licenses.txt"
|
"package": "npx ncc build --source-map --license licenses.txt",
|
||||||
|
"test": "jest --ci"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
@ -37,11 +38,13 @@
|
|||||||
"@octokit/webhooks": "^9.6.3",
|
"@octokit/webhooks": "^9.6.3",
|
||||||
"@types/archiver": "^5.1.0",
|
"@types/archiver": "^5.1.0",
|
||||||
"@types/btoa": "^1.2.3",
|
"@types/btoa": "^1.2.3",
|
||||||
|
"@types/jest": "^26.0.23",
|
||||||
"@types/node": "^15.6.2",
|
"@types/node": "^15.6.2",
|
||||||
"@types/node-fetch": "^2.5.10",
|
"@types/node-fetch": "^2.5.10",
|
||||||
"@types/uuid": "^8.3.0",
|
"@types/uuid": "^8.3.0",
|
||||||
"@typescript-eslint/eslint-plugin": "^4.16.1",
|
"@typescript-eslint/eslint-plugin": "^4.16.1",
|
||||||
"@typescript-eslint/parser": "^4.16.1",
|
"@typescript-eslint/parser": "^4.16.1",
|
||||||
|
"dotenv": "^10.0.0",
|
||||||
"eslint": "^7.21.0",
|
"eslint": "^7.21.0",
|
||||||
"eslint-plugin-github": "^4.1.3",
|
"eslint-plugin-github": "^4.1.3",
|
||||||
"eslint-plugin-jest": "^24.1.7",
|
"eslint-plugin-jest": "^24.1.7",
|
||||||
@ -52,5 +55,15 @@
|
|||||||
"prettier": "2.2.1",
|
"prettier": "2.2.1",
|
||||||
"ts-jest": "^26.5.3",
|
"ts-jest": "^26.5.3",
|
||||||
"typescript": "^4.3.2"
|
"typescript": "^4.3.2"
|
||||||
|
},
|
||||||
|
"jest-junit": {
|
||||||
|
"suiteName": "jest tests",
|
||||||
|
"outputDirectory": "__tests__/__results__",
|
||||||
|
"outputName": "jest-junit.xml",
|
||||||
|
"ancestorSeparator": " › ",
|
||||||
|
"uniqueOutputName": "false",
|
||||||
|
"suiteNameTemplate": "{filepath}",
|
||||||
|
"classNameTemplate": "{classname}",
|
||||||
|
"titleTemplate": "{title}"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,43 +1,19 @@
|
|||||||
import * as core from '@actions/core';
|
import { NoFileOption } from './NoFileOption'
|
||||||
import { NoFileOption } from './NoFileOption';
|
|
||||||
|
|
||||||
export class Inputs {
|
export interface Inputs {
|
||||||
static get ArtifactName(): string {
|
readonly ArtifactName: string
|
||||||
return core.getInput("name");
|
|
||||||
}
|
|
||||||
|
|
||||||
static get ArtifactPath(): string {
|
readonly ArtifactPath: string
|
||||||
return core.getInput("path");
|
|
||||||
}
|
|
||||||
|
|
||||||
static get Retention(): string {
|
readonly Retention: string
|
||||||
return core.getInput("retention-days");
|
|
||||||
}
|
|
||||||
|
|
||||||
static get Endpoint(): string {
|
readonly Endpoint: string
|
||||||
return core.getInput("nextcloud-url");
|
|
||||||
}
|
|
||||||
|
|
||||||
static get Username(): string {
|
readonly Username: string
|
||||||
return core.getInput("nextcloud-username");
|
|
||||||
}
|
|
||||||
|
|
||||||
static get Password(): string {
|
readonly Password: string
|
||||||
return core.getInput("nextcloud-password");
|
|
||||||
}
|
|
||||||
|
|
||||||
static get NoFileBehvaior(): NoFileOption {
|
readonly Token: string
|
||||||
const notFoundAction = core.getInput("if-no-files-found") || NoFileOption.warn;
|
|
||||||
const noFileBehavior: NoFileOption = NoFileOption[notFoundAction as keyof typeof NoFileOption];
|
|
||||||
|
|
||||||
if (!noFileBehavior) {
|
readonly NoFileBehvaior: NoFileOption
|
||||||
core.setFailed(
|
|
||||||
`Unrecognized ${"ifNoFilesFound"} input. Provided: ${notFoundAction}. Available options: ${Object.keys(
|
|
||||||
NoFileOption
|
|
||||||
)}`
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return noFileBehavior;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user