-
-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathupm.test.ts
67 lines (60 loc) · 1.91 KB
/
upm.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import { setGlobals } from '../../utils/helpers';
import { NoneArtifactProvider } from '../../artifact_providers/none';
import { ARTIFACT_NAME, UpmTarget } from '../upm';
describe('UPM Target', () => {
const cleanEnv = { ...process.env };
let upmTarget: UpmTarget;
beforeEach(() => {
process.env = {
...cleanEnv,
GITHUB_TOKEN: 'test github token',
};
setGlobals({ 'dry-run': false, 'log-level': 'Info', 'no-input': true });
jest.resetAllMocks();
upmTarget = new UpmTarget(
{
name: 'upm-test',
releaseRepoOwner: 'getsentry-test',
releaseRepoName: 'unity-test',
},
new NoneArtifactProvider(),
{ owner: 'testSourceOwner', repo: 'testSourceRepo' }
);
});
describe('artifacts', () => {
beforeEach(() => {
setGlobals({ 'dry-run': false, 'log-level': 'Info', 'no-input': true });
});
test.each`
artifacts | error
${[]} | ${'Cannot publish UPM: No release artifact found.'}
${['file1', 'file2']} | ${'Cannot publish UPM: Failed to find "' + ARTIFACT_NAME + '" in the artifacts.'}
`(
'error with artifact count $artifacts.length',
async ({ artifacts, error }) => {
upmTarget.getArtifactsForRevision = jest
.fn()
.mockResolvedValueOnce(artifacts);
await expect(upmTarget.fetchArtifact('revision')).rejects.toThrow(
error
);
}
);
});
// TODO(byk): Add more tests for this
describe.skip('publish', () => {
beforeEach(() => {
upmTarget.fetchArtifact = jest
.fn()
.mockResolvedValueOnce({ filename: 'artifact.zip' });
upmTarget.artifactProvider.downloadArtifact = jest
.fn()
.mockResolvedValueOnce('some/test/path');
});
test('publish', () => {
return expect(
upmTarget.publish('version', 'revision')
).resolves.not.toThrow();
});
});
});