mirror of
https://github.com/ddworken/hishtory.git
synced 2025-01-13 17:58:50 +01:00
Fix missing newline in zshrc, add test for hishtory redact prompting, and tag TODOs with plans
This commit is contained in:
parent
bd70b68ffc
commit
c6d4f1ef68
@ -547,7 +547,7 @@ func cleanDatabase() error {
|
||||
if result.Error != nil {
|
||||
return result.Error
|
||||
}
|
||||
// TODO(future): Clean the database by deleting entries for users that haven't been used in X amount of time
|
||||
// TODO(optimization): Clean the database by deleting entries for users that haven't been used in X amount of time
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -570,4 +570,4 @@ func main() {
|
||||
log.Fatal(http.ListenAndServe(":8080", nil))
|
||||
}
|
||||
|
||||
// TODO: Maybe optimize the endpoints a bit to reduce the number of round trips required?
|
||||
// TODO(optimization): Maybe optimize the endpoints a bit to reduce the number of round trips required?
|
||||
|
@ -1448,6 +1448,28 @@ ls /tmp`, randomCmdUuid, randomCmdUuid)
|
||||
if diff := cmp.Diff(expectedOutput, out); diff != "" {
|
||||
t.Fatalf("hishtory export mismatch (-expected +got):\n%s\nout=%#v", diff, out)
|
||||
}
|
||||
|
||||
// Record another command
|
||||
tester.RunInteractiveShell(t, `echo hello`)
|
||||
out = tester.RunInteractiveShell(t, `hishtory export | grep -v pipefail`)
|
||||
expectedOutput = "hishtory redact --force s\necho hello\n"
|
||||
if diff := cmp.Diff(expectedOutput, out); diff != "" {
|
||||
t.Fatalf("hishtory export mismatch (-expected +got):\n%s\nout=%#v", diff, out)
|
||||
}
|
||||
|
||||
// Redact it without --force
|
||||
out, err := tester.RunInteractiveShellRelaxed(t, `yes | hishtory redact hello`)
|
||||
shared.Check(t, err)
|
||||
if out != "This will permanently delete 1 entries, are you sure? [y/N]" {
|
||||
t.Fatalf("hishtory redact gave unexpected output=%#v", out)
|
||||
}
|
||||
|
||||
// And check it was redacted
|
||||
out = tester.RunInteractiveShell(t, `hishtory export | grep -v pipefail`)
|
||||
expectedOutput = "hishtory redact --force s\nyes | hishtory redact hello\n"
|
||||
if diff := cmp.Diff(expectedOutput, out); diff != "" {
|
||||
t.Fatalf("hishtory export mismatch (-expected +got):\n%s\nout=%#v", diff, out)
|
||||
}
|
||||
}
|
||||
|
||||
func testRemoteRedaction(t *testing.T, tester shellTester) {
|
||||
|
@ -968,7 +968,6 @@ func Redact(ctx *context.Context, query string, force bool) error {
|
||||
if force {
|
||||
fmt.Printf("Permanently deleting %d entries\n", len(historyEntries))
|
||||
} else {
|
||||
// TODO: Find a way to test the prompting
|
||||
fmt.Printf("This will permanently delete %d entries, are you sure? [y/N]", len(historyEntries))
|
||||
reader := bufio.NewReader(os.Stdin)
|
||||
resp, err := reader.ReadString('\n')
|
||||
|
@ -102,7 +102,8 @@ func configureZshrc(homedir string) {
|
||||
_, err = f.WriteString(`export HISTFILE=~/.zsh_history
|
||||
export HISTSIZE=10000
|
||||
export SAVEHIST=1000
|
||||
setopt SHARE_HISTORY`)
|
||||
setopt SHARE_HISTORY
|
||||
`)
|
||||
checkError(err)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user