11import { describe , expect } from 'vitest'
22
33import constants from '../../../src/constants.mts'
4- import { cmdit , invokeNpm } from '../../../test/utils.mts'
4+ import { cmdit , invokeNpm , testPath } from '../../../test/utils.mts'
55
66describe ( 'socket manifest conda' , async ( ) => {
77 const { binCliPath } = constants
@@ -10,7 +10,12 @@ describe('socket manifest conda', async () => {
1010 [ 'manifest' , 'conda' , '--help' , '--config' , '{}' ] ,
1111 'should support --help' ,
1212 async cmd => {
13- const { code, stderr, stdout } = await invokeNpm ( binCliPath , cmd )
13+ const { code, stderr, stdout } = await invokeNpm (
14+ binCliPath ,
15+ cmd ,
16+ { } ,
17+ testPath ,
18+ )
1419 expect ( stdout ) . toMatchInlineSnapshot (
1520 `
1621 "[beta] Convert a Conda environment.yml file to a python requirements.txt
@@ -61,7 +66,12 @@ describe('socket manifest conda', async () => {
6166 [ 'manifest' , 'conda' , '--dry-run' , '--config' , '{}' ] ,
6267 'should require args with just dry-run' ,
6368 async cmd => {
64- const { code, stderr, stdout } = await invokeNpm ( binCliPath , cmd )
69+ const { code, stderr, stdout } = await invokeNpm (
70+ binCliPath ,
71+ cmd ,
72+ { } ,
73+ testPath ,
74+ )
6575 expect ( stdout ) . toMatchInlineSnapshot ( `"[DryRun]: Bailing now"` )
6676 expect ( `\n ${ stderr } ` ) . toMatchInlineSnapshot ( `
6777 "
@@ -82,25 +92,33 @@ describe('socket manifest conda', async () => {
8292 [
8393 'manifest' ,
8494 'conda' ,
85- 'two ' ,
86- 'three' , // this triggers the error
95+ 'fixtures/commands/manifest/conda ' ,
96+ '--stdout' ,
8797 '--config' ,
8898 '{}' ,
8999 ] ,
90100 'should print raw text without flags' ,
91101 async cmd => {
92- const { stderr, stdout } = await invokeNpm ( binCliPath , cmd )
93- expect ( stdout ) . toMatchInlineSnapshot ( `""` )
102+ const { code, stderr, stdout } = await invokeNpm (
103+ binCliPath ,
104+ cmd ,
105+ { } ,
106+ testPath ,
107+ )
108+ expect ( stdout ) . toMatchInlineSnapshot ( `
109+ "qgrid==1.3.0
110+ mplstereonet
111+ pyqt5
112+ gempy==2.1.0"
113+ ` )
94114 expect ( `\n ${ stderr } ` ) . toMatchInlineSnapshot ( `
95115 "
96116 _____ _ _ /---------------
97117 | __|___ ___| |_ ___| |_ | Socket.dev CLI ver <redacted>
98118 |__ | * | _| '_| -_| _| | Node: <redacted>, API token: <redacted>, org: <redacted>
99119 |_____|___|___|_,_|___|_|.dev | Command: \`socket manifest conda\`, cwd: <redacted>
100120
101- \\xd7 Input error: Please review the input requirements and try again
102-
103- \\xd7 Can only accept one DIR (make sure to escape spaces!) (received 2)"
121+ \\u203c Warning: This will approximate your Conda dependencies using PyPI. We do not yet officially support Conda. Use at your own risk."
104122 ` )
105123 } ,
106124 )
@@ -109,25 +127,32 @@ describe('socket manifest conda', async () => {
109127 [
110128 'manifest' ,
111129 'conda' ,
112- 'two' ,
113- 'three' , // this triggers the error
130+ 'fixtures/commands/manifest/conda' ,
114131 '--json' ,
132+ '--stdout' ,
115133 '--config' ,
116134 '{}' ,
117135 ] ,
118136 'should print a json blurb with --json flag' ,
119137 async cmd => {
120- const { stderr, stdout } = await invokeNpm ( binCliPath , cmd )
138+ const { stderr, stdout } = await invokeNpm (
139+ binCliPath ,
140+ cmd ,
141+ { } ,
142+ testPath ,
143+ )
121144 expect ( stdout ) . toMatchInlineSnapshot ( `
122145 "{
123- "ok": false,
124- "message": "Input error",
125- "data": "Please review the input requirements and try again\\n\\n \\xd7 Can only accept one DIR (make sure to escape spaces!) (received 2)"
146+ "ok": true,
147+ "data": {
148+ "content": "name: my_stuff\\n\\nchannels:\\n - conda-thing\\n - defaults\\ndependencies:\\n - python=3.8\\n - pandas=1.3.4\\n - numpy=1.19.0\\n - scipy\\n - mkl-service\\n - libpython\\n - m2w64-toolchain\\n - pytest\\n - requests\\n - pip\\n - pip:\\n - qgrid==1.3.0\\n - mplstereonet\\n - pyqt5\\n - gempy==2.1.0\\n",
149+ "pip": "qgrid==1.3.0\\nmplstereonet\\npyqt5\\ngempy==2.1.0"
150+ }
126151 }"
127152 ` )
128153 expect ( `\n ${ stderr } ` ) . toMatchInlineSnapshot ( `
129154 "
130- "
155+ \\u203c Warning: This will approximate your Conda dependencies using PyPI. We do not yet officially support Conda. Use at your own risk. "
131156 ` )
132157 } ,
133158 )
@@ -136,21 +161,35 @@ describe('socket manifest conda', async () => {
136161 [
137162 'manifest' ,
138163 'conda' ,
139- 'two' ,
140- 'three' , // this triggers the error
164+ 'fixtures/commands/manifest/conda' ,
141165 '--markdown' ,
166+ '--stdout' ,
142167 '--config' ,
143168 '{}' ,
144169 ] ,
145170 'should print a markdown blurb with --markdown flag' ,
146171 async cmd => {
147- const { stderr, stdout } = await invokeNpm ( binCliPath , cmd )
148- expect ( stdout ) . toMatchInlineSnapshot ( `""` )
172+ const { code, stderr, stdout } = await invokeNpm (
173+ binCliPath ,
174+ cmd ,
175+ { } ,
176+ testPath ,
177+ )
178+ expect ( stdout ) . toMatchInlineSnapshot ( `
179+ "# Converted Conda file
180+
181+ This is the Conda \`environment.yml\` file converted to python \`requirements.txt\`:
182+
183+ \`\`\`file=requirements.txt
184+ qgrid==1.3.0
185+ mplstereonet
186+ pyqt5
187+ gempy==2.1.0
188+ \`\`\`"
189+ ` )
149190 expect ( `\n ${ stderr } ` ) . toMatchInlineSnapshot ( `
150191 "
151- \\xd7 Input error: Please review the input requirements and try again
152-
153- \\xd7 Can only accept one DIR (make sure to escape spaces!) (received 2)"
192+ \\u203c Warning: This will approximate your Conda dependencies using PyPI. We do not yet officially support Conda. Use at your own risk."
154193 ` )
155194 } ,
156195 )
0 commit comments