Skip to content

Commit

Permalink
Use Output() instead of Snapshot() as that was what the original …
Browse files Browse the repository at this point in the history
…implementation did, despite the name
  • Loading branch information
Naatan committed Aug 23, 2023
1 parent b78aa3f commit 3a069d5
Show file tree
Hide file tree
Showing 27 changed files with 56 additions and 56 deletions.
10 changes: 5 additions & 5 deletions cmd/state-installer/test/integration/installer_int_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func (suite *InstallerIntegrationTestSuite) TestInstallFromLocalSource() {
if runtime.GOOS == "darwin" && condition.OnCI() {
cp.Expect("You are running bash on macOS")
}
suite.NotContains(cp.Snapshot(), "Downloading State Tool")
suite.NotContains(cp.Output(), "Downloading State Tool")
cp.ExpectInput()
cp.SendLine("exit")
cp.ExpectExitCode(0)
Expand Down Expand Up @@ -113,7 +113,7 @@ func (suite *InstallerIntegrationTestSuite) TestInstallFromLocalSource() {
cp.SendLine("exit")
cp.ExpectExitCode(0)

snapshot := strings.Replace(cp.Snapshot(), "\n", "", -1)
snapshot := strings.Replace(cp.Output(), "\n", "", -1)
if !strings.Contains(snapshot, stateExec) && !strings.Contains(snapshot, stateExecResolved) {
suite.Fail(fmt.Sprintf("Snapshot does not include '%s' or '%s', snapshot:\n %s", stateExec, stateExecResolved, snapshot))
}
Expand Down Expand Up @@ -166,7 +166,7 @@ func (suite *InstallerIntegrationTestSuite) TestInstallNoErrorTips() {
)

cp.ExpectExitCode(1)
suite.Assert().NotContains(cp.Snapshot(), "Need More Help?", "error tips should not be displayed when invoking installer")
suite.Assert().NotContains(cp.Output(), "Need More Help?", "error tips should not be displayed when invoking installer")
}

func (suite *InstallerIntegrationTestSuite) TestInstallErrorTips() {
Expand All @@ -189,7 +189,7 @@ func (suite *InstallerIntegrationTestSuite) TestInstallErrorTips() {
cp.ExpectInput()
cp.SendLine("exit")
cp.Wait()
suite.Assert().Contains(cp.Snapshot(), "Need More Help?", "error tips should be displayed in shell created by installer")
suite.Assert().Contains(cp.Output(), "Need More Help?", "error tips should be displayed in shell created by installer")
}

func (suite *InstallerIntegrationTestSuite) TestStateTrayRemoval() {
Expand Down Expand Up @@ -248,7 +248,7 @@ func (suite *InstallerIntegrationTestSuite) TestStateTrayRemoval() {
stateExec, err := installation.StateExecFromDir(dir)
suite.Require().NoError(err)
cp = ts.SpawnCmdWithOpts(stateExec, e2e.OptArgs("--version"))
suite.Assert().NotContains(cp.Snapshot(), version)
suite.Assert().NotContains(cp.Output(), version)
cp.ExpectExitCode(0)
}

Expand Down
6 changes: 3 additions & 3 deletions cmd/state-svc/test/integration/svc_int_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,14 @@ func (suite *SvcIntegrationTestSuite) TestStartStop() {
// Verify the server is running on its reported port.
cp.ExpectRe("Port:\\s+:\\d+\\s")
portRe := regexp.MustCompile("Port:\\s+:(\\d+)")
port := portRe.FindStringSubmatch(cp.Snapshot())[1]
port := portRe.FindStringSubmatch(cp.Output())[1]
_, err := net.Listen("tcp", "localhost:"+port)
suite.Error(err)

// Verify it created and wrote to its reported log file.
cp.ExpectRe("Log:\\s+.+?\\.log")
logRe := regexp.MustCompile("Log:\\s+(.+?\\.log)")
logFile := logRe.FindStringSubmatch(cp.Snapshot())[1]
logFile := logRe.FindStringSubmatch(cp.Output())[1]
suite.True(fileutils.FileExists(logFile), "log file '"+logFile+"' does not exist")
suite.True(len(fileutils.ReadFileUnsafe(logFile)) > 0, "log file is empty")

Expand Down Expand Up @@ -113,7 +113,7 @@ func (suite *SvcIntegrationTestSuite) TestSignals() {
cp.Expect("Starting")
time.Sleep(1 * time.Second) // wait for the service to start up
cp.Cmd().Process.Signal(syscall.SIGTERM)
suite.NotContains(cp.Snapshot(), "caught a signal")
suite.NotContains(cp.Output(), "caught a signal")
cp.ExpectExitCode(0) // should exit gracefully

cp = ts.SpawnCmdWithOpts(ts.SvcExe, e2e.OptArgs("status"))
Expand Down
4 changes: 2 additions & 2 deletions test/automation/invite_neg_automation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ func (suite *InviteNegativeAutomationTestSuite) TestInvite_NonExistentArgValues_
// `-n` flag used
cp = ts.Spawn("invite", "[email protected]", "-n")
cp.ExpectExitCode(1)
suite.Assert().NotContains(cp.Snapshot(), "Invalid role") // there is an error, just not this one
suite.Assert().NotContains(cp.Output(), "Invalid role") // there is an error, just not this one
}

func (suite *InviteNegativeAutomationTestSuite) TestInvite_NonExistentArgValues_Private() {
Expand Down Expand Up @@ -153,7 +153,7 @@ func (suite *InviteNegativeAutomationTestSuite) TestInvite_NonExistentArgValues_
// `-n` flag used
cp = ts.Spawn("invite", "[email protected]", "-n")
cp.ExpectExitCode(1)
suite.Assert().NotContains(cp.Snapshot(), "Invalid role") // there is an error, just not this one
suite.Assert().NotContains(cp.Output(), "Invalid role") // there is an error, just not this one
}

func TestInviteAutomationTestSuite(t *testing.T) {
Expand Down
8 changes: 4 additions & 4 deletions test/integration/activate_int_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ func (suite *ActivateIntegrationTestSuite) TestActivate_PythonPath() {
} else {
cp.Send("echo $PYTHONPATH")
}
suite.Assert().NotContains(cp.Snapshot(), constants.LocalRuntimeTempDirectory)
suite.Assert().NotContains(cp.Output(), constants.LocalRuntimeTempDirectory)
// Verify the temp runtime setup directory has been removed.
runtimeFound := false
entries, err := fileutils.ListDir(ts.Dirs.Cache, true)
Expand Down Expand Up @@ -382,7 +382,7 @@ func (suite *ActivateIntegrationTestSuite) TestActivatePerl() {
cp.Expect("Installing", termtest.OptExpectTimeout(140*time.Second))
cp.Expect("Activated")

suite.assertCompletedStatusBarReport(cp.Snapshot())
suite.assertCompletedStatusBarReport(cp.Output())

// ensure that shell is functional
cp.ExpectInput()
Expand Down Expand Up @@ -511,7 +511,7 @@ func (suite *ActivateIntegrationTestSuite) TestActivate_FromCache() {
cp.Expect("Installing")
cp.Expect("Activated")

suite.assertCompletedStatusBarReport(cp.Snapshot())
suite.assertCompletedStatusBarReport(cp.Output())
cp.SendLine("exit")
cp.ExpectExitCode(0)

Expand All @@ -524,7 +524,7 @@ func (suite *ActivateIntegrationTestSuite) TestActivate_FromCache() {
cp.ExpectInput()
cp.SendLine("exit")
cp.ExpectExitCode(0)
suite.NotContains(cp.Snapshot(), "Downloading")
suite.NotContains(cp.Output(), "Downloading")
}

func TestActivateIntegrationTestSuite(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion test/integration/auth_int_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ func (suite *AuthIntegrationTestSuite) authOutput(method string) {
cp := ts.Spawn(tagsuite.Auth, "--output", method)
cp.Expect("false}")
cp.ExpectExitCode(0)
suite.Equal(fmt.Sprintf("%s", string(expected)), cp.Snapshot())
suite.Equal(fmt.Sprintf("%s", string(expected)), cp.Output())
}

func (suite *AuthIntegrationTestSuite) TestAuth_JsonOutput() {
Expand Down
4 changes: 2 additions & 2 deletions test/integration/condition_int_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ func (suite *ConditionIntegrationTestSuite) TestMixin() {
e2e.OptArgs("run", "MixinUser"),
)
cp.ExpectExitCode(0)
suite.Assert().NotContains(cp.Snapshot(), "authenticated: yes", "expected not to be authenticated, output was:\n%s.", cp.Snapshot())
suite.Assert().NotContains(cp.Snapshot(), e2e.PersistentUsername, "expected not to be authenticated, output was:\n%s", cp.Snapshot())
suite.Assert().NotContains(cp.Output(), "authenticated: yes", "expected not to be authenticated, output was:\n%s.", cp.Output())
suite.Assert().NotContains(cp.Output(), e2e.PersistentUsername, "expected not to be authenticated, output was:\n%s", cp.Output())

ts.LoginAsPersistentUser()
defer ts.LogoutUser()
Expand Down
2 changes: 1 addition & 1 deletion test/integration/edit_int_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ func (suite *EditIntegrationTestSuite) TestEdit_UpdateCorrectPlatform() {
suite.Require().NotNil(s, "test-script should not be empty")
v, err := s.Value()
suite.Require().NoError(err)
suite.Contains(v, "more info!", "Output of edit command:\n%s", cp.Snapshot())
suite.Contains(v, "more info!", "Output of edit command:\n%s", cp.Output())
}

func TestEditIntegrationTestSuite(t *testing.T) {
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 @@ -59,7 +59,7 @@ events:
cp.ExpectInput()
cp.SendLine("exit")
cp.ExpectExitCode(0)
output := cp.Snapshot()
output := cp.Output()
if strings.Contains(output, "First activate event") {
suite.T().Fatal("Output from second activate event should not contain first-activate output")
}
Expand Down
2 changes: 1 addition & 1 deletion test/integration/exec_int_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func (suite *ExecIntegrationTestSuite) TestExec_Environment() {
e2e.OptArgs("exec", testScript),
)
cp.ExpectExitCode(0)
output := cp.Snapshot()
output := cp.Output()
suite.Contains(output, ts.Dirs.Bin, "PATH was not updated to contain cache directory, original PATH:", os.Getenv("PATH"))
}

Expand Down
2 changes: 1 addition & 1 deletion test/integration/export_int_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func (suite *ExportIntegrationTestSuite) TestExport_Env() {
cp.Expect(`PATH: `)
cp.ExpectExitCode(0)

suite.Assert().NotContains(cp.Snapshot(), "ACTIVESTATE_ACTIVATED")
suite.Assert().NotContains(cp.Output(), "ACTIVESTATE_ACTIVATED")
}

func (suite *ExportIntegrationTestSuite) TestJSON() {
Expand Down
2 changes: 1 addition & 1 deletion test/integration/history_int_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func (suite *HistoryIntegrationTestSuite) TestHistory_History() {
cp.Expect("+ autopip 1.6.0")
cp.Expect("- convertdate")
cp.Expect(`+ Platform`)
suite.Assert().NotContains(cp.Snapshot(), "StructuredChanges")
suite.Assert().NotContains(cp.Output(), "StructuredChanges")
cp.ExpectExitCode(0)
}

Expand Down
2 changes: 1 addition & 1 deletion test/integration/install_scripts_int_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ func (suite *InstallScriptsIntegrationTestSuite) assertCorrectVersion(ts *e2e.Se
cp := ts.SpawnCmd(stateExec, "--version", "--output=json")
cp.ExpectExitCode(0)
actual := versionData{}
out := strings.Trim(cp.Snapshot(), "\x00")
out := strings.Trim(cp.Output(), "\x00")
json.Unmarshal([]byte(out), &actual)

if expectedVersion != "" {
Expand Down
2 changes: 1 addition & 1 deletion test/integration/languages_int_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func (suite *LanguagesIntegrationTestSuite) TestLanguages_install() {
cp.ExpectExitCode(0)

// assert that version number changed
output := cp.Snapshot()
output := cp.Output()
vs := versionRe.FindString(output)
v, err := goversion.NewVersion(vs)
suite.Require().NoError(err, "parsing version %s", vs)
Expand Down
8 changes: 4 additions & 4 deletions test/integration/msg_int_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func (suite *MsgIntegrationTestSuite) TestMessage_Basic() {
}
cp.ExpectExitCode(0)
if !tt.ExpectRepeat {
suite.Require().NotContains(cp.Snapshot(), "This is a simple message", "Should not repeat as that's the default behavior")
suite.Require().NotContains(cp.Output(), "This is a simple message", "Should not repeat as that's the default behavior")
}
})
}
Expand Down Expand Up @@ -136,7 +136,7 @@ func (suite *MsgIntegrationTestSuite) TestMessage_Basic_InterruptPrompt() {
cp.Expect(`This is a simple message`)
cp.Expect("Press ENTER to continue")
time.Sleep(time.Millisecond * 100)
suite.Require().NotContains(cp.Snapshot(), "Usage:")
suite.Require().NotContains(cp.Output(), "Usage:")
cp.SendLine("")
cp.Expect("Usage:")
cp.ExpectExitCode(0)
Expand All @@ -146,7 +146,7 @@ func (suite *MsgIntegrationTestSuite) TestMessage_Basic_InterruptPrompt() {
cp.Expect(`This is a simple message`)
cp.Expect("Usage:")
cp.ExpectExitCode(0)
suite.Require().NotContains(cp.Snapshot(), "Press ENTER to continue")
suite.Require().NotContains(cp.Output(), "Press ENTER to continue")
}

func (suite *MsgIntegrationTestSuite) TestMessage_Basic_InterruptExit() {
Expand All @@ -166,7 +166,7 @@ func (suite *MsgIntegrationTestSuite) TestMessage_Basic_InterruptExit() {
cp := ts.SpawnWithOpts(e2e.OptArgs("config"), e2e.OptAppendEnv(constants.MessagesOverrideEnvVarName+"="+msgFile))
cp.Expect(`This is a simple message`)
cp.ExpectExitCode(1)
suite.Require().NotContains(cp.Snapshot(), "Usage:")
suite.Require().NotContains(cp.Output(), "Usage:")
}

func TestMsgIntegrationTestSuite(t *testing.T) {
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 @@ -566,7 +566,7 @@ func (suite *PackageIntegrationTestSuite) TestNormalize() {
)
cp.Expect("charset-normalizer")
cp.ExpectExitCode(0)
suite.NotContains(cp.Snapshot(), "is different")
suite.NotContains(cp.Output(), "is different")
}

func (suite *PackageIntegrationTestSuite) TestInstall_InvalidVersion() {
Expand Down
6 changes: 3 additions & 3 deletions test/integration/performance_int_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,16 @@ func performanceTest(commands []string, expect string, samples int, maxTime time
cp.Expect(expect)
}
cp.ExpectExitCode(0)
v := rx.FindStringSubmatch(cp.Snapshot())
v := rx.FindStringSubmatch(cp.Output())
if len(v) < 2 {
suite.T().Fatalf("Could not find '%s' in output: %s", rx.String(), cp.Snapshot())
suite.T().Fatalf("Could not find '%s' in output: %s", rx.String(), cp.Output())
}
durMS, err := strconv.Atoi(v[1])
suite.Require().NoError(err)
dur := time.Millisecond * time.Duration(durMS)

if firstEntry == "" {
firstEntry = cp.Snapshot()
firstEntry = cp.Output()
firstLogs = ts.DebugLogs()
}
if x == 0 {
Expand Down
4 changes: 2 additions & 2 deletions test/integration/platforms_int_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func (suite *PlatformsIntegrationTestSuite) TestPlatforms_addRemove() {

cp = ts.Spawn("platforms")
cp.ExpectExitCode(0)
output := cp.Snapshot()
output := cp.Output()
if strings.Contains(output, "Windows") {
suite.T().Fatal("Windows platform should not be present after removal")
}
Expand Down Expand Up @@ -127,7 +127,7 @@ func (suite *PlatformsIntegrationTestSuite) TestPlatforms_addRemoveLatest() {

cp = ts.Spawn("platforms")
cp.ExpectExitCode(0)
output := cp.Snapshot()
output := cp.Output()
if strings.Contains(output, "Windows") {
suite.T().Fatal("Windows platform should not be present after removal")
}
Expand Down
2 changes: 1 addition & 1 deletion test/integration/progress_int_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func (suite *ProgressIntegrationTestSuite) TestProgress() {
)
cp.Expect(locale.T("setup_runtime"))
cp.Expect("Checked out")
suite.Assert().NotContains(cp.Snapshot(), "...")
suite.Assert().NotContains(cp.Output(), "...")
cp.ExpectExitCode(0)

cp = ts.SpawnWithOpts(
Expand Down
2 changes: 1 addition & 1 deletion test/integration/projects_int_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func (suite *ProjectsIntegrationTestSuite) TestEdit_Name() {

// If the checkout failed, it's probably because the project name was changed
// in a previous run of this test. Try again with the new name.
if strings.Contains(cp.Snapshot(), "Could not checkout project") {
if strings.Contains(cp.Output(), "Could not checkout project") {
cp = ts.Spawn("checkout", fmt.Sprintf("ActiveState-CLI/%s", newName))
originalName = newName
newName = originalName
Expand Down
2 changes: 1 addition & 1 deletion test/integration/refresh_int_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func (suite *RefreshIntegrationTestSuite) TestRefresh() {
cp.ExpectExitCode(0)

cp = ts.Spawn("refresh")
suite.Assert().NotContains(cp.Snapshot(), "Setting Up Runtime", "Unchanged runtime should not refresh")
suite.Assert().NotContains(cp.Output(), "Setting Up Runtime", "Unchanged runtime should not refresh")
cp.Expect("Runtime updated")
cp.ExpectExitCode(0)
}
Expand Down
2 changes: 1 addition & 1 deletion test/integration/revert_int_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func (suite *RevertIntegrationTestSuite) TestRevert() {
cp.SendLine("import urllib3")
cp.Expect("No module named 'urllib3'")
cp.SendLine("import argparse")
suite.Assert().NotContains(cp.Snapshot(), "No module named 'argparse'")
suite.Assert().NotContains(cp.Output(), "No module named 'argparse'")
cp.SendLine("exit()") // exit python3
cp.SendLine("exit") // exit state shell
cp.ExpectExitCode(0)
Expand Down
4 changes: 2 additions & 2 deletions test/integration/run_int_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ func (suite *RunIntegrationTestSuite) TestInActivatedEnv() {
cp.SendLine("exit 0")
cp.ExpectExitCode(0)
suite.Require().NotContains(
cp.Snapshot(), "not printed after second interrupt",
cp.Output(), "not printed after second interrupt",
)
}

Expand Down Expand Up @@ -196,7 +196,7 @@ func (suite *RunIntegrationTestSuite) TestTwoInterrupts() {
suite.expectTerminateBatchJob(cp)
cp.ExpectExitCode(123)
suite.Require().NotContains(
cp.Snapshot(), "not printed after second interrupt",
cp.Output(), "not printed after second interrupt",
)
}

Expand Down
2 changes: 1 addition & 1 deletion test/integration/secrets_int_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func (suite *SecretsIntegrationTestSuite) TestSecrets_JSON() {

cp = ts.Spawn("secrets", "get", "project.test-secret", "--output", "json")
cp.ExpectExitCode(0)
suite.Equal(string(expected), cp.Snapshot())
suite.Equal(string(expected), cp.Output())

cp = ts.Spawn("secrets", "sync")
cp.Expect("Operating on project cli-integration-tests/Python3")
Expand Down
2 changes: 1 addition & 1 deletion test/integration/shell_int_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ func (suite *ShellIntegrationTestSuite) TestNestedShellNotification() {
e2e.OptArgs("shell", "small-python"),
e2e.OptAppendEnv(env...))
cp.Expect("Activated")
suite.Assert().NotContains(cp.Snapshot(), "State Tool is operating on project")
suite.Assert().NotContains(cp.Output(), "State Tool is operating on project")
cp.SendLine(fmt.Sprintf(`export HOME="%s"`, ts.Dirs.HomeDir)) // some shells do not forward this

cp.SendLine(ss.Binary()) // platform-specific shell (zsh on macOS, bash on Linux, etc.)
Expand Down
4 changes: 2 additions & 2 deletions test/integration/update_int_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func (suite *UpdateIntegrationTestSuite) versionCompare(ts *e2e.Session, expecte
cp.ExpectExitCode(0)

version := versionData{}
out := strings.Trim(cp.Snapshot(), "\x00")
out := strings.Trim(cp.Output(), "\x00")
json.Unmarshal([]byte(out), &version)

matcher(expected, version.Version, fmt.Sprintf("Version could not be matched, output:\n\n%s", out))
Expand All @@ -88,7 +88,7 @@ func (suite *UpdateIntegrationTestSuite) branchCompare(ts *e2e.Session, expected
cp.ExpectExitCode(0, termtest.OptExpectTimeout(30*time.Second))

branch := branchData{}
out := strings.Trim(cp.Snapshot(), "\x00")
out := strings.Trim(cp.Output(), "\x00")
json.Unmarshal([]byte(out), &branch)

matcher(expected, branch.Branch, fmt.Sprintf("Branch could not be matched, output:\n\n%s", out))
Expand Down
2 changes: 1 addition & 1 deletion test/integration/version_int_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func (suite *VersionIntegrationTestSuite) TestNotDev() {
defer ts.Close()

cp := ts.Spawn("--version")
suite.NotContains(cp.Snapshot(), "(dev)")
suite.NotContains(cp.Output(), "(dev)")
cp.ExpectExitCode(0)
}

Expand Down
Loading

0 comments on commit 3a069d5

Please sign in to comment.