(t *testing.T, tester shellTester)
| 1395 | } |
| 1396 | |
| 1397 | func testInitialHistoryImport(t *testing.T, tester shellTester) { |
| 1398 | // Setup |
| 1399 | defer testutils.BackupAndRestore(t)() |
| 1400 | defer testutils.BackupAndRestoreEnv("HISHTORY_SKIP_INIT_IMPORT")() |
| 1401 | os.Setenv("HISHTORY_SKIP_INIT_IMPORT", "") |
| 1402 | |
| 1403 | // Record some commands before installing hishtory |
| 1404 | randomCmdUuid := uuid.Must(uuid.NewRandom()).String() |
| 1405 | captureTerminalOutputWithShellName(t, tester, "fish", []string{fmt.Sprintf("echo SPACE %s-fishcommand ENTER", randomCmdUuid)}) |
| 1406 | randomCmd := fmt.Sprintf(`echo %v-foo |
| 1407 | echo %v-bar`, randomCmdUuid, randomCmdUuid) |
| 1408 | tester.RunInteractiveShell(t, randomCmd) |
| 1409 | |
| 1410 | // Install hishtory |
| 1411 | installHishtory(t, tester, "") |
| 1412 | |
| 1413 | // Check that hishtory export has the commands |
| 1414 | out := tester.RunInteractiveShell(t, `hishtory export `+randomCmdUuid[:5]) |
| 1415 | expectedOutput := strings.ReplaceAll(`echo UUID-fishcommand |
| 1416 | echo UUID-foo |
| 1417 | echo UUID-bar |
| 1418 | hishtory export `+randomCmdUuid[:5]+` |
| 1419 | `, "UUID", randomCmdUuid) |
| 1420 | if diff := cmp.Diff(expectedOutput, out); diff != "" { |
| 1421 | t.Fatalf("hishtory export mismatch (-expected +got):\n%s\nout=%#v", diff, out) |
| 1422 | } |
| 1423 | |
| 1424 | // Compare the rest of the hishtory export |
| 1425 | out = tester.RunInteractiveShell(t, `hishtory export -pipefail -/tmp/client -`+randomCmdUuid[:5]) |
| 1426 | if out != "" { |
| 1427 | t.Fatalf("expected hishtory export to be empty, was=%v", out) |
| 1428 | } |
| 1429 | } |
| 1430 | |
| 1431 | func testLocalRedaction(t *testing.T, tester shellTester, onlineStatus OnlineStatus) { |
| 1432 | // Setup |
no test coverage detected