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

Function TestFish

client/integration_test.go:1654–1705  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1652}
1653
1654func TestFish(t *testing.T) {
1655 // Setup
1656 markTestForSharding(t, 5)
1657 defer testutils.BackupAndRestore(t)()
1658 tester := bashTester{}
1659 installHishtory(t, tester, "")
1660
1661 // Test recording in fish
1662 require.NoError(t, os.Chdir("/"))
1663 out := captureTerminalOutputWithShellName(t, tester, "fish", []string{
1664 "echo SPACE foo ENTER",
1665 "ENTER",
1666 "SPACE echo SPACE baz ENTER",
1667 "echo SPACE bar ENTER",
1668 "echo SPACE '\"foo\"' ENTER",
1669 "SPACE echo SPACE foobar ENTER",
1670 "ls SPACE /tmp/ SPACE '&' ENTER",
1671 })
1672 require.Contains(t, out, "Welcome to fish, the friendly interactive shell")
1673 require.Contains(t, out, "\nfoo\n")
1674 require.Contains(t, out, "\nbar\n")
1675 require.Contains(t, out, "\nbaz\n")
1676 require.Contains(t, out, "\nfoobar\n")
1677
1678 // And test that fish exits properly, for #117
1679 out = captureTerminalOutputWithShellName(t, tester, "bash", []string{
1680 "fish ENTER",
1681 "echo SPACE foo ENTER",
1682 "exit ENTER",
1683 })
1684 require.Contains(t, out, "Welcome to fish, the friendly interactive shell")
1685 require.Contains(t, out, "\nfoo\n")
1686 require.NotContains(t, out, "There are still jobs active")
1687 require.NotContains(t, out, "A second attempt to exit will terminate them.")
1688 if runtime.GOOS == "darwin" {
1689 require.Contains(t, out, "exit\nbash")
1690 } else {
1691 require.Contains(t, out, "exit\nrunner@ghaction-runner-hostname:/$")
1692 }
1693
1694 // Check export
1695 out = tester.RunInteractiveShell(t, `hishtory export | grep -v pipefail | grep -v ps`)
1696 expectedOutput := "echo foo\necho bar\necho \"foo\"\nls /tmp/ &\nfish\necho foo\nexit\n"
1697 if diff := cmp.Diff(expectedOutput, out); diff != "" {
1698 t.Fatalf("hishtory export mismatch (-expected +got):\n%s\nout=%#v", diff, out)
1699 }
1700
1701 // Check a table to see some other metadata
1702 tester.RunInteractiveShell(t, `hishtory config-set displayed-columns CWD Hostname 'Exit Code' Command`)
1703 out = hishtoryQuery(t, tester, "-pipefail")
1704 testutils.CompareGoldens(t, out, "TestFish-table")
1705}
1706
1707func setupTestTui(t testing.TB, onlineStatus OnlineStatus) (shellTester, string, *gorm.DB) {
1708 tester := zshTester{}

Callers

nothing calls this directly

Calls 7

RunInteractiveShellMethod · 0.95
BackupAndRestoreFunction · 0.92
CompareGoldensFunction · 0.92
markTestForShardingFunction · 0.85
installHishtoryFunction · 0.85
hishtoryQueryFunction · 0.85

Tested by

no test coverage detected