From bda76d04d19f96678203c974fb4c0e853d79c9b4 Mon Sep 17 00:00:00 2001 From: David Dworken Date: Wed, 20 Dec 2023 17:18:00 -0800 Subject: [PATCH] Add tab completion tests for fish --- client/client_test.go | 18 ++++++++++++------ .../goldens/testTabCompletion-suggestions-fish | 1 + ...tions => testTabCompletion-suggestions-zsh} | 0 3 files changed, 13 insertions(+), 6 deletions(-) create mode 100644 client/lib/goldens/testTabCompletion-suggestions-fish rename client/lib/goldens/{testTabCompletion-suggestions => testTabCompletion-suggestions-zsh} (100%) diff --git a/client/client_test.go b/client/client_test.go index b2e9410..bebe7d2 100644 --- a/client/client_test.go +++ b/client/client_test.go @@ -98,8 +98,9 @@ func TestParam(t *testing.T) { t.Run("testPresavingDisabled/"+tester.ShellName(), func(t *testing.T) { testPresavingDisabled(t, tester) }) t.Run("testControlR/online/"+tester.ShellName(), func(t *testing.T) { testControlR(t, tester, tester.ShellName(), Online) }) t.Run("testControlR/offline/"+tester.ShellName(), func(t *testing.T) { testControlR(t, tester, tester.ShellName(), Offline) }) - t.Run("testTabCompletion/"+tester.ShellName(), func(t *testing.T) { testTabCompletion(t, tester) }) + t.Run("testTabCompletion/"+tester.ShellName(), func(t *testing.T) { testTabCompletion(t, tester, tester.ShellName()) }) } + t.Run("testTabCompletion/fish", func(t *testing.T) { testTabCompletion(t, zshTester{}, "fish") }) t.Run("testPresaving/fish", func(t *testing.T) { testPresaving(t, zshTester{}, "fish") }) t.Run("testControlR/fish", func(t *testing.T) { testControlR(t, bashTester{}, "fish", Online) }) t.Run("testTui/search/online", func(t *testing.T) { testTui_search(t, Online) }) @@ -2371,20 +2372,25 @@ func testPresaving(t *testing.T, tester shellTester, shellName string) { } } -func testTabCompletion(t *testing.T, tester shellTester) { +func testTabCompletion(t *testing.T, tester shellTester, shellName string) { // Setup defer testutils.BackupAndRestore(t)() installHishtory(t, tester, "") // Check that tab completions work to complete a command - out := captureTerminalOutput(t, tester, []string{"hishtory SPACE config-g Tab"}) + out := captureTerminalOutputWithShellName(t, tester, shellName, []string{"hishtory SPACE config-g Tab"}) expected := "hishtory config-get" require.True(t, strings.HasSuffix(out, expected), fmt.Sprintf("Expected out=%#v to end with %#v", out, expected)) // Check that tab completions work to view suggestions - out = captureTerminalOutput(t, tester, []string{"hishtory SPACE config- Tab"}) - out = strings.Join(strings.Split(out, "\n")[1:], "\n") - testutils.CompareGoldens(t, out, "testTabCompletion-suggestions") + out = captureTerminalOutputWithShellName(t, tester, shellName, []string{"hishtory SPACE config- Tab"}) + testutils.TestLog(t, "testTabCompletion: Pre-stripping: "+out) + if shellName == "fish" { + out = strings.Join(strings.Split(out, "\n")[3:], "\n") + } else { + out = strings.Join(strings.Split(out, "\n")[1:], "\n") + } + testutils.CompareGoldens(t, out, "testTabCompletion-suggestions-"+shellName) } func testUninstall(t *testing.T, tester shellTester) { diff --git a/client/lib/goldens/testTabCompletion-suggestions-fish b/client/lib/goldens/testTabCompletion-suggestions-fish new file mode 100644 index 0000000..f82869b --- /dev/null +++ b/client/lib/goldens/testTabCompletion-suggestions-fish @@ -0,0 +1 @@ +config-add (Add a config option) config-delete (Delete a config option) config-get (Get the value of a config option) config-set (Set the value of a config option) \ No newline at end of file diff --git a/client/lib/goldens/testTabCompletion-suggestions b/client/lib/goldens/testTabCompletion-suggestions-zsh similarity index 100% rename from client/lib/goldens/testTabCompletion-suggestions rename to client/lib/goldens/testTabCompletion-suggestions-zsh