(t *testing.T)
| 1137 | } |
| 1138 | |
| 1139 | func TestInstallViaPythonScriptFromHead(t *testing.T) { |
| 1140 | markTestForSharding(t, 2) |
| 1141 | defer testutils.BackupAndRestore(t)() |
| 1142 | tester := zshTester{} |
| 1143 | |
| 1144 | // Set up |
| 1145 | defer testutils.BackupAndRestoreEnv("HISHTORY_TEST")() |
| 1146 | |
| 1147 | // Install via the python script |
| 1148 | out := tester.RunInteractiveShell(t, `cat backend/web/landing/www/install.py | python3 -`) |
| 1149 | require.Contains(t, out, "Succesfully installed hishtory") |
| 1150 | r := regexp.MustCompile(`Setting secret hishtory key to (.*)`) |
| 1151 | matches := r.FindStringSubmatch(out) |
| 1152 | if len(matches) != 2 { |
| 1153 | t.Fatalf("Failed to extract userSecret from output=%#v: matches=%#v", out, matches) |
| 1154 | } |
| 1155 | userSecret := matches[1] |
| 1156 | |
| 1157 | // Test the status subcommand |
| 1158 | downloadData, err := cmd.GetDownloadData(makeTestOnlyContextWithFakeConfig()) |
| 1159 | require.NoError(t, err) |
| 1160 | out = tester.RunInteractiveShell(t, `hishtory status`) |
| 1161 | expectedOut := fmt.Sprintf("hiSHtory: %s\nEnabled: true\nSecret Key: %s\nCommit Hash: ", downloadData.Version, userSecret) |
| 1162 | require.Contains(t, out, expectedOut) |
| 1163 | |
| 1164 | // And test that it recorded that command |
| 1165 | time.Sleep(time.Second) |
| 1166 | out = tester.RunInteractiveShell(t, `hishtory export -pipefail`) |
| 1167 | if out != "hishtory status\n" { |
| 1168 | t.Fatalf("unexpected output from hishtory export=%#v", out) |
| 1169 | } |
| 1170 | |
| 1171 | // And check that it installed in online mode |
| 1172 | out = tester.RunInteractiveShell(t, `hishtory status -v`) |
| 1173 | require.Contains(t, out, "\nSync Mode: Enabled\n") |
| 1174 | } |
| 1175 | |
| 1176 | func testExportWithQuery(t *testing.T, tester shellTester) { |
| 1177 | // Setup |
nothing calls this directly
no test coverage detected