|
1 | 1 | import * as process from 'process' |
2 | 2 | import * as cp from 'child_process' |
3 | 3 | import * as path from 'path' |
4 | | -import {afterEach, beforeEach, test} from '@jest/globals' |
| 4 | +import {afterEach, beforeEach, test, expect} from '@jest/globals' |
5 | 5 | import fs from 'fs' |
6 | 6 | import os from 'os' |
7 | 7 |
|
@@ -55,7 +55,10 @@ test('test runs upload', () => { |
55 | 55 | const options: cp.ExecFileSyncOptions = { |
56 | 56 | env: process.env |
57 | 57 | } |
58 | | - console.log(cp.execFileSync(np, [ip], options).toString()) |
| 58 | + const output: string = cp.execFileSync(np, [ip], options).toString() |
| 59 | + console.log(output) |
| 60 | + // output should not contain the warning mentioning that the file is not found |
| 61 | + expect(output).not.toContain('No files found for the provided path') |
59 | 62 | }) |
60 | 63 |
|
61 | 64 | test('test runs upload absolute path', () => { |
@@ -102,3 +105,22 @@ test('test runs get method', () => { |
102 | 105 | } |
103 | 106 | console.log(cp.execFileSync(np, [ip], options).toString()) |
104 | 107 | }) |
| 108 | + |
| 109 | +test('test runs upload with no file in folder', () => { |
| 110 | + const workspace: string = process.env['GITHUB_WORKSPACE'] || '' |
| 111 | + const source: string = 'artifacts' |
| 112 | + process.env['INPUT_METHOD'] = 'upload' |
| 113 | + |
| 114 | + fs.mkdirSync(path.join(workspace, source)) |
| 115 | + |
| 116 | + process.env['INPUT_SOURCE'] = source |
| 117 | + |
| 118 | + const np = process.execPath |
| 119 | + const ip = path.join(__dirname, '..', 'lib', 'main.js') |
| 120 | + const options: cp.ExecFileSyncOptions = { |
| 121 | + env: process.env |
| 122 | + } |
| 123 | + const output: string = cp.execFileSync(np, [ip], options).toString() |
| 124 | + console.log(output) |
| 125 | + expect(output).toContain('No files found for the provided path') |
| 126 | +}) |
0 commit comments