@@ -17,33 +17,24 @@ const createEchoCli = async (tmpdir: string) => {
17
17
) ;
18
18
} ;
19
19
20
- // This is a sanity check test that validates the CLI is called correctly.
21
- // TODO(Tyler) that we may want to have these tests in python instead for simplicity
22
- test ( "Forwards inputs" , async ( ) => {
20
+ test ( "Forwards inputs - upload" , async ( ) => {
23
21
const tmpdir = await fs . mkdtemp (
24
22
path . resolve ( os . tmpdir ( ) , "trunk-analytics-uploader-test-" ) ,
25
23
) ;
26
24
await createEchoCli ( tmpdir ) ;
27
25
28
- const env = {
26
+ const env : Record < string , string > = {
29
27
"INPUT_JUNIT-PATHS" : "junit.xml" ,
30
28
"INPUT_ORG-SLUG" : "org" ,
31
29
INPUT_TOKEN : "token" ,
32
- "INPUT_REPO-HEAD-BRANCH" : "" ,
33
- "INPUT_REPO-ROOT" : "" ,
34
30
"INPUT_CLI-VERSION" : "0.0.0" ,
35
- INPUT_TEAM : "" ,
36
- INPUT_QUARANTINE : "" ,
37
- "INPUT_XCRESULT-PATH" : "" ,
38
- "INPUT_ALLOW-MISSING-JUNIT-FILES" : "" ,
39
- "INPUT_BAZEL-BEP-PATH" : "" ,
40
- "INPUT_HIDE-BANNER" : "" ,
41
31
} ;
42
32
43
33
const scriptPath = path . resolve ( repoRoot , "dist/index.js" ) ;
44
34
let stdout = "" ;
45
35
let stderr = "" ;
46
36
let exit_code : number ;
37
+ console . log ( process . env ) ;
47
38
try {
48
39
( { stdout, stderr } = await execPromise ( `node ${ scriptPath } ` , {
49
40
env : { ...process . env , ...env } ,
@@ -62,3 +53,40 @@ test("Forwards inputs", async () => {
62
53
expect ( exit_code ) . toBe ( 0 ) ;
63
54
await fs . rm ( tmpdir , { recursive : true , force : true } ) ;
64
55
} ) ;
56
+
57
+ test ( "Forwards inputs - test" , async ( ) => {
58
+ const tmpdir = await fs . mkdtemp (
59
+ path . resolve ( os . tmpdir ( ) , "trunk-analytics-uploader-test-" ) ,
60
+ ) ;
61
+ await createEchoCli ( tmpdir ) ;
62
+
63
+ const env = {
64
+ "INPUT_JUNIT-PATHS" : "junit.xml" ,
65
+ "INPUT_ORG-SLUG" : "org" ,
66
+ INPUT_TOKEN : "token" ,
67
+ "INPUT_CLI-VERSION" : "0.0.0" ,
68
+ INPUT_RUN : "exit 0" ,
69
+ } ;
70
+
71
+ const scriptPath = path . resolve ( repoRoot , "dist/index.js" ) ;
72
+ let stdout = "" ;
73
+ let stderr = "" ;
74
+ let exit_code : number ;
75
+ try {
76
+ ( { stdout, stderr } = await execPromise ( `node ${ scriptPath } ` , {
77
+ env : { ...process . env , ...env } ,
78
+ cwd : tmpdir ,
79
+ } ) ) ;
80
+ exit_code = 0 ;
81
+ /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
82
+ } catch ( err : any ) {
83
+ /* eslint-disable-next-line @typescript-eslint/no-unsafe-assignment */
84
+ ( { stdout, stderr, code : exit_code } = err ) ;
85
+ }
86
+ expect ( stdout ) . toMatch (
87
+ "test --junit-paths junit.xml --org-url-slug org --token token --repo-root . -- exit 0" ,
88
+ ) ;
89
+ expect ( stderr ) . toMatch ( "" ) ;
90
+ expect ( exit_code ) . toBe ( 0 ) ;
91
+ await fs . rm ( tmpdir , { recursive : true , force : true } ) ;
92
+ } ) ;
0 commit comments