Skip to content

Commit

Permalink
Fix tests using Send() where they should be using SendLine()
Browse files Browse the repository at this point in the history
  • Loading branch information
Naatan committed Aug 23, 2023
1 parent 62a713e commit ef1f227
Show file tree
Hide file tree
Showing 10 changed files with 29 additions and 30 deletions.
11 changes: 5 additions & 6 deletions internal/testhelpers/e2e/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -353,16 +353,15 @@ func (s *Session) CreateNewUser() (string, string) {
p := s.Spawn(tagsuite.Auth, "signup", "--prompt")

p.Expect("I accept")
time.Sleep(time.Millisecond * 100)
p.Send("y")
p.SendLine("")
p.Expect("username:")
p.Send(username)
p.SendLine(username)
p.Expect("password:")
p.Send(password)
p.SendLine(password)
p.Expect("again:")
p.Send(password)
p.SendLine(password)
p.Expect("email:")
p.Send(email)
p.SendLine(email)
p.Expect("account has been registered", termtest.OptExpectTimeout(defaultnTimeout))
p.ExpectExitCode(0)

Expand Down
6 changes: 3 additions & 3 deletions test/integration/activate_int_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -304,9 +304,9 @@ func (suite *ActivateIntegrationTestSuite) TestActivate_PythonPath() {
// Verify that PYTHONPATH is set correctly to the installed site-packages, not a temp runtime
// setup directory.
if runtime.GOOS == "windows" {
cp.Send("echo %PYTHONPATH%")
cp.SendLine("echo %PYTHONPATH%")
} else {
cp.Send("echo $PYTHONPATH")
cp.SendLine("echo $PYTHONPATH")
}
suite.Assert().NotContains(cp.Output(), constants.LocalRuntimeTempDirectory)
// Verify the temp runtime setup directory has been removed.
Expand All @@ -323,7 +323,7 @@ func (suite *ActivateIntegrationTestSuite) TestActivate_PythonPath() {

// test that PYTHONPATH is preserved in environment (https://www.pivotaltracker.com/story/show/178458102)
if runtime.GOOS == "windows" {
cp.Send("set PYTHONPATH=/custom_pythonpath")
cp.SendLine("set PYTHONPATH=/custom_pythonpath")
cp.SendLine(`python3 -c 'import os; print(os.environ["PYTHONPATH"]);'`)
} else {
cp.SendLine(`PYTHONPATH=/custom_pythonpath python3 -c 'import os; print(os.environ["PYTHONPATH"]);'`)
Expand Down
4 changes: 2 additions & 2 deletions test/integration/auth_int_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ func (suite *AuthIntegrationTestSuite) TestAuthToken() {
func (suite *AuthIntegrationTestSuite) interactiveLogin(ts *e2e.Session, username, password string) {
cp := ts.Spawn(tagsuite.Auth, "--prompt")
cp.Expect("username:")
cp.Send(username)
cp.SendLine(username)
cp.Expect("password:")
cp.Send(password)
cp.SendLine(password)
cp.Expect("logged in")
cp.ExpectExitCode(0)

Expand Down
4 changes: 2 additions & 2 deletions test/integration/edit_int_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func (suite *EditIntegrationTestSuite) TestEdit() {
cp := ts.SpawnWithOpts(e2e.OptArgs("scripts", "edit", "test-script"), env)
cp.Expect("Watching file changes")
cp.Expect("Script changes detected")
cp.Send("Y")
cp.SendLine("Y")
cp.ExpectExitCode(0)
}

Expand Down Expand Up @@ -103,7 +103,7 @@ func (suite *EditIntegrationTestSuite) TestEdit_UpdateCorrectPlatform() {
e2e.OptWD(ts.Dirs.Work),
env,
)
cp.Send("Y")
cp.SendLine("Y")
cp.ExpectExitCode(0)

time.Sleep(time.Second * 2) // let CI env catch up
Expand Down
2 changes: 1 addition & 1 deletion test/integration/events_int_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ events:
`))

cp := ts.Spawn("activate")
cp.Send("")
cp.SendLine("")
cp.Expect("before-script")
cp.Expect("First activate event")
cp.Expect("Activate event")
Expand Down
2 changes: 1 addition & 1 deletion test/integration/package_int_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ func (suite *PackageIntegrationTestSuite) TestPackage_import() {

cp = ts.Spawn("import", "requirements.txt")
cp.Expect("Are you sure you want to do this")
cp.Send("n")
cp.SendLine("n")
cp.ExpectNotExitCode(0, termtest.OptExpectTimeout(time.Second*60))
})
}
Expand Down
8 changes: 4 additions & 4 deletions test/integration/projects_int_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ func (suite *ProjectsIntegrationTestSuite) TestEdit_Name() {

cp = ts.Spawn("projects", "edit", fmt.Sprintf("ActiveState-CLI/%s", originalName), "--name", newName)
cp.Expect("You are about to edit")
cp.Send("y")
cp.SendLine("y")
cp.Expect("Project edited successfully")
cp.ExpectExitCode(0)

Expand All @@ -120,7 +120,7 @@ func (suite *ProjectsIntegrationTestSuite) TestEdit_Name() {
// Change name back to original
cp = ts.Spawn("projects", "edit", fmt.Sprintf("ActiveState-CLI/%s", newName), "--name", originalName)
cp.Expect("You are about to edit")
cp.Send("y")
cp.SendLine("y")
cp.Expect("Project edited successfully")
cp.ExpectExitCode(0)

Expand All @@ -141,7 +141,7 @@ func (suite *ProjectsIntegrationTestSuite) TestEdit_Visibility() {

cp := ts.Spawn("projects", "edit", namespace, "--visibility", "private")
cp.Expect("You are about to edit")
cp.Send("y")
cp.SendLine("y")
cp.Expect("Project edited successfully")
cp.ExpectExitCode(0)

Expand All @@ -155,7 +155,7 @@ func (suite *ProjectsIntegrationTestSuite) TestEdit_Visibility() {

cp = ts.Spawn("projects", "edit", namespace, "--visibility", "public")
cp.Expect("You are about to edit")
cp.Send("y")
cp.SendLine("y")
cp.Expect("Project edited successfully")
cp.ExpectExitCode(0)
}
Expand Down
16 changes: 8 additions & 8 deletions test/integration/push_int_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,11 @@ func (suite *PushIntegrationTestSuite) TestPush_HeadlessConvert_NewProject() {

cp = ts.SpawnWithOpts(e2e.OptArgs("push"))
cp.Expect("Who would you like the owner of this project to be?")
cp.Send("")
cp.SendLine("")
cp.Expect("What would you like the name of this project to be?")
cp.Send(string([]byte{0033, '[', 'B'})) // move cursor down, and then press enter
cp.SendLine(string([]byte{0033, '[', 'B'})) // move cursor down, and then press enter
cp.Expect("> Other")
cp.Send("")
cp.SendLine("")
cp.Expect(">")
cp.SendLine(pname.String())
cp.Expect("Project created")
Expand Down Expand Up @@ -185,13 +185,13 @@ func (suite *PushIntegrationTestSuite) TestPush_NoPermission_NewProject() {

cp = ts.SpawnWithOpts(e2e.OptArgs("push"))
cp.Expect("not authorized")
cp.Send("y")
cp.SendLine("y")
cp.Expect("Who would you like the owner of this project to be?")
cp.Send("")
cp.SendLine("")
cp.Expect("What would you like the name of this project to be?")
cp.Send(string([]byte{0033, '[', 'B'})) // move cursor down, and then press enter
cp.SendLine(string([]byte{0033, '[', 'B'})) // move cursor down, and then press enter
cp.Expect("> Other")
cp.Send("")
cp.SendLine("")
cp.Expect(">")
cp.SendLine(pname.String())
cp.Expect("Project created")
Expand Down Expand Up @@ -250,7 +250,7 @@ func (suite *PushIntegrationTestSuite) TestCarlisle() {

cp = ts.SpawnWithOpts(e2e.OptArgs("push", namespace), e2e.OptWD(wd))
cp.Expect("You are about to create the project")
cp.Send("y")
cp.SendLine("y")
cp.Expect("Project created")
cp.ExpectExitCode(0)
ts.NotifyProjectCreated(suite.username, pname.String())
Expand Down
2 changes: 1 addition & 1 deletion test/integration/run_int_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func (suite *RunIntegrationTestSuite) expectTerminateBatchJob(cp *e2e.SpawnedCmd
// send N to "Terminate batch job (Y/N)" question
cp.Expect("Terminate batch job")
time.Sleep(200 * time.Millisecond)
cp.Send("N")
cp.SendLine("N")
cp.Expect("N", termtest.OptExpectTimeout(500*time.Millisecond))
}
}
Expand Down
4 changes: 2 additions & 2 deletions test/integration/update_lock_int_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,10 @@ func (suite *UpdateIntegrationTestSuite) TestUpdateLockedConfirmation() {
)
cp.Expect("sure you want")
if tt.Confirm || tt.Forced {
cp.Send("y")
cp.SendLine("y")
cp.Expect("Version locked at")
} else {
cp.Send("n")
cp.SendLine("n")
cp.Expect("Cancelling")
}
cp.ExpectNotExitCode(0)
Expand Down

0 comments on commit ef1f227

Please sign in to comment.