FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
setup-python/__tests__/install-python.test.ts at main · eFog-R/setup-python · GitHub
eFog-R
/
setup-python
Public
forked from
actions/setup-python
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
setup-python
/
__tests__
/
install-python.test.ts
Copy path
More file actions
More file actions
Latest commit
History
History
History
77 lines (70 loc) · 2.12 KB
Breadcrumbs
setup-python
/
__tests__
/
install-python.test.ts
Copy path
File metadata and controls
77 lines (70 loc) · 2.12 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
68
69
70
71
72
73
74
75
76
77
import
{
getManifest
,
getManifestFromRepo
,
getManifestFromURL
}
from
'../src/install-python'
;
import
*
as
httpm
from
'@actions/http-client'
;
import
*
as
tc
from
'@actions/tool-cache'
;
jest
.
mock
(
'@actions/http-client'
)
;
jest
.
mock
(
'@actions/tool-cache'
)
;
jest
.
mock
(
'@actions/tool-cache'
,
(
)
=>
(
{
getManifestFromRepo
:
jest
.
fn
(
)
}
)
)
;
const
mockManifest
=
[
{
version
:
'1.0.0'
,
stable
:
true
,
files
:
[
{
filename
:
'tool-v1.0.0-linux-x64.tar.gz'
,
platform
:
'linux'
,
arch
:
'x64'
,
download_url
:
'https://example.com/tool-v1.0.0-linux-x64.tar.gz'
}
]
}
]
;
describe
(
'getManifest'
,
(
)
=>
{
beforeEach
(
(
)
=>
{
jest
.
resetAllMocks
(
)
;
}
)
;
it
(
'should return manifest from repo'
,
async
(
)
=>
{
(
tc
.
getManifestFromRepo
as
jest
.
Mock
)
.
mockResolvedValue
(
mockManifest
)
;
const
manifest
=
await
getManifest
(
)
;
expect
(
manifest
)
.
toEqual
(
mockManifest
)
;
}
)
;
it
(
'should return manifest from URL if repo fetch fails'
,
async
(
)
=>
{
(
tc
.
getManifestFromRepo
as
jest
.
Mock
)
.
mockRejectedValue
(
new
Error
(
'Fetch failed'
)
)
;
(
httpm
.
HttpClient
.
prototype
.
getJson
as
jest
.
Mock
)
.
mockResolvedValue
(
{
result
:
mockManifest
}
)
;
const
manifest
=
await
getManifest
(
)
;
expect
(
manifest
)
.
toEqual
(
mockManifest
)
;
}
)
;
}
)
;
describe
(
'getManifestFromRepo'
,
(
)
=>
{
it
(
'should return manifest from repo'
,
async
(
)
=>
{
(
tc
.
getManifestFromRepo
as
jest
.
Mock
)
.
mockResolvedValue
(
mockManifest
)
;
const
manifest
=
await
getManifestFromRepo
(
)
;
expect
(
manifest
)
.
toEqual
(
mockManifest
)
;
}
)
;
}
)
;
describe
(
'getManifestFromURL'
,
(
)
=>
{
it
(
'should return manifest from URL'
,
async
(
)
=>
{
(
httpm
.
HttpClient
.
prototype
.
getJson
as
jest
.
Mock
)
.
mockResolvedValue
(
{
result
:
mockManifest
}
)
;
const
manifest
=
await
getManifestFromURL
(
)
;
expect
(
manifest
)
.
toEqual
(
mockManifest
)
;
}
)
;
it
(
'should throw error if unable to get manifest from URL'
,
async
(
)
=>
{
(
httpm
.
HttpClient
.
prototype
.
getJson
as
jest
.
Mock
)
.
mockResolvedValue
(
{
result
:
null
}
)
;
await
expect
(
getManifestFromURL
(
)
)
.
rejects
.
toThrow
(
'Unable to get manifest from'
)
;
}
)
;
}
)
;
Back
|
FazBrowse Home
|
New Git URL