mirror of
https://github.com/trympet/nextcloud-artifacts-action.git
synced 2025-04-24 12:06:09 +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-check": "prettier --check **/*.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": {
|
||||
"type": "git",
|
||||
@ -37,11 +38,13 @@
|
||||
"@octokit/webhooks": "^9.6.3",
|
||||
"@types/archiver": "^5.1.0",
|
||||
"@types/btoa": "^1.2.3",
|
||||
"@types/jest": "^26.0.23",
|
||||
"@types/node": "^15.6.2",
|
||||
"@types/node-fetch": "^2.5.10",
|
||||
"@types/uuid": "^8.3.0",
|
||||
"@typescript-eslint/eslint-plugin": "^4.16.1",
|
||||
"@typescript-eslint/parser": "^4.16.1",
|
||||
"dotenv": "^10.0.0",
|
||||
"eslint": "^7.21.0",
|
||||
"eslint-plugin-github": "^4.1.3",
|
||||
"eslint-plugin-jest": "^24.1.7",
|
||||
@ -52,5 +55,15 @@
|
||||
"prettier": "2.2.1",
|
||||
"ts-jest": "^26.5.3",
|
||||
"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 {
|
||||
static get ArtifactName(): string {
|
||||
return core.getInput("name");
|
||||
}
|
||||
export interface Inputs {
|
||||
readonly ArtifactName: string
|
||||
|
||||
static get ArtifactPath(): string {
|
||||
return core.getInput("path");
|
||||
}
|
||||
readonly ArtifactPath: string
|
||||
|
||||
static get Retention(): string {
|
||||
return core.getInput("retention-days");
|
||||
}
|
||||
readonly Retention: string
|
||||
|
||||
static get Endpoint(): string {
|
||||
return core.getInput("nextcloud-url");
|
||||
}
|
||||
readonly Endpoint: string
|
||||
|
||||
static get Username(): string {
|
||||
return core.getInput("nextcloud-username");
|
||||
}
|
||||
readonly Username: string
|
||||
|
||||
static get Password(): string {
|
||||
return core.getInput("nextcloud-password");
|
||||
}
|
||||
readonly Password: string
|
||||
|
||||
static get NoFileBehvaior(): NoFileOption {
|
||||
const notFoundAction = core.getInput("if-no-files-found") || NoFileOption.warn;
|
||||
const noFileBehavior: NoFileOption = NoFileOption[notFoundAction as keyof typeof NoFileOption];
|
||||
readonly Token: string
|
||||
|
||||
if (!noFileBehavior) {
|
||||
core.setFailed(
|
||||
`Unrecognized ${"ifNoFilesFound"} input. Provided: ${notFoundAction}. Available options: ${Object.keys(
|
||||
NoFileOption
|
||||
)}`
|
||||
);
|
||||
}
|
||||
|
||||
return noFileBehavior;
|
||||
}
|
||||
readonly NoFileBehvaior: NoFileOption
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user