MCPcopy
hub / github.com/ddworken/hishtory / testInitialHistoryImport

Function testInitialHistoryImport

client/integration_test.go:1397–1429  ·  view source on GitHub ↗
(t *testing.T, tester shellTester)

Source from the content-addressed store, hash-verified

1395}
1396
1397func 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
1407echo %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
1416echo UUID-foo
1417echo UUID-bar
1418hishtory 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
1431func testLocalRedaction(t *testing.T, tester shellTester, onlineStatus OnlineStatus) {
1432 // Setup

Callers 1

TestParamFunction · 0.85

Calls 6

BackupAndRestoreFunction · 0.92
BackupAndRestoreEnvFunction · 0.92
installHishtoryFunction · 0.85
StringMethod · 0.80
RunInteractiveShellMethod · 0.65

Tested by

no test coverage detected