mirror of
https://github.com/ddworken/hishtory.git
synced 2025-02-22 13:31:11 +01:00
Add tests for configuring displayed-columns
This commit is contained in:
parent
8b575e98c6
commit
267aa086fa
@ -1598,25 +1598,47 @@ func testConfigGetSet(t *testing.T, tester shellTester) {
|
||||
defer testutils.BackupAndRestore(t)()
|
||||
installHishtory(t, tester, "")
|
||||
|
||||
// Initially is true
|
||||
// Config-get and set for enable-control-r
|
||||
out := tester.RunInteractiveShell(t, `hishtory config-get enable-control-r`)
|
||||
if out != "true" {
|
||||
t.Fatalf("unexpected config-get output: %#v", out)
|
||||
}
|
||||
|
||||
// Set to false and check
|
||||
tester.RunInteractiveShell(t, `hishtory config-set enable-control-r false`)
|
||||
out = tester.RunInteractiveShell(t, `hishtory config-get enable-control-r`)
|
||||
if out != "false" {
|
||||
t.Fatalf("unexpected config-get output: %#v", out)
|
||||
}
|
||||
|
||||
// Set to true and check
|
||||
tester.RunInteractiveShell(t, `hishtory config-set enable-control-r true`)
|
||||
out = tester.RunInteractiveShell(t, `hishtory config-get enable-control-r`)
|
||||
if out != "true" {
|
||||
t.Fatalf("unexpected config-get output: %#v", out)
|
||||
}
|
||||
|
||||
// config for displayed-columns
|
||||
out = tester.RunInteractiveShell(t, `hishtory config-get displayed-columns`)
|
||||
if out != "Hostname CWD Timestamp Runtime \"Exit Code\" Command \n" {
|
||||
t.Fatalf("unexpected config-get output: %#v", out)
|
||||
}
|
||||
tester.RunInteractiveShell(t, `hishtory config-set displayed-columns Hostname Command 'Exit Code'`)
|
||||
out = tester.RunInteractiveShell(t, `hishtory config-get displayed-columns`)
|
||||
if out != "Hostname Command \"Exit Code\" \n" {
|
||||
t.Fatalf("unexpected config-get output: %#v", out)
|
||||
}
|
||||
tester.RunInteractiveShell(t, `hishtory config-add displayed-columns Timestamp`)
|
||||
out = tester.RunInteractiveShell(t, `hishtory config-get displayed-columns`)
|
||||
if out != "Hostname Command \"Exit Code\" Timestamp \n" {
|
||||
t.Fatalf("unexpected config-get output: %#v", out)
|
||||
}
|
||||
tester.RunInteractiveShell(t, `hishtory config-delete displayed-columns Hostname`)
|
||||
out = tester.RunInteractiveShell(t, `hishtory config-get displayed-columns`)
|
||||
if out != "Command \"Exit Code\" Timestamp \n" {
|
||||
t.Fatalf("unexpected config-get output: %#v", out)
|
||||
}
|
||||
tester.RunInteractiveShell(t, `hishtory config-add displayed-columns foobar`)
|
||||
out = tester.RunInteractiveShell(t, `hishtory config-get displayed-columns`)
|
||||
if out != "Command \"Exit Code\" Timestamp foobar \n" {
|
||||
t.Fatalf("unexpected config-get output: %#v", out)
|
||||
}
|
||||
}
|
||||
|
||||
func clearControlRSearchFromConfig(t *testing.T) {
|
||||
|
10
hishtory.go
10
hishtory.go
@ -126,8 +126,14 @@ func main() {
|
||||
case "enable-control-r":
|
||||
fmt.Printf("%v", config.ControlRSearchEnabled)
|
||||
case "displayed-columns":
|
||||
// TODO: better formatting for the below
|
||||
fmt.Printf("%#v", config.DisplayedColumns)
|
||||
for _, col := range config.DisplayedColumns {
|
||||
if strings.Contains(col, " ") {
|
||||
fmt.Printf("%q ", col)
|
||||
} else {
|
||||
fmt.Print(col + " ")
|
||||
}
|
||||
}
|
||||
fmt.Print("\n")
|
||||
case "custom-columns":
|
||||
// TODO: better formatting for this
|
||||
fmt.Printf("%#v", config.CustomColumns)
|
||||
|
Loading…
Reference in New Issue
Block a user