File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -204,6 +204,41 @@ func Test_Env_AddCommand(t *testing.T) {
204204 )
205205 },
206206 },
207+ "add a numeric variable using prompts to the .env file" : {
208+ CmdArgs : []string {},
209+ Setup : func (t * testing.T , ctx context.Context , cm * shared.ClientsMock , cf * shared.ClientFactory ) {
210+ setupEnvAddDotenvMocks (ctx , cm , cf )
211+ cm .IO .On (
212+ "InputPrompt" ,
213+ mock .Anything ,
214+ "Variable name" ,
215+ mock .Anything ,
216+ ).Return (
217+ "PORT" ,
218+ nil ,
219+ )
220+ cm .IO .On (
221+ "PasswordPrompt" ,
222+ mock .Anything ,
223+ "Variable value" ,
224+ iostreams .MatchPromptConfig (iostreams.PasswordPromptConfig {
225+ Flag : cm .Config .Flags .Lookup ("value" ),
226+ }),
227+ ).Return (
228+ iostreams.PasswordPromptResponse {
229+ Prompt : true ,
230+ Value : "3000" ,
231+ },
232+ nil ,
233+ )
234+ },
235+ ExpectedAsserts : func (t * testing.T , ctx context.Context , cm * shared.ClientsMock ) {
236+ cm .API .AssertNotCalled (t , "AddVariable" )
237+ content , err := afero .ReadFile (cm .Fs , ".env" )
238+ assert .NoError (t , err )
239+ assert .Equal (t , "PORT=3000\n " , string (content ))
240+ },
241+ },
207242 "add a variable to the .env file for non-hosted app" : {
208243 CmdArgs : []string {"NEW_VAR" , "new_value" },
209244 Setup : func (t * testing.T , ctx context.Context , cm * shared.ClientsMock , cf * shared.ClientFactory ) {
You can’t perform that action at this time.
0 commit comments