(t *testing.T, tester shellTester, onlineStatus OnlineStatus)
| 1100 | } |
| 1101 | |
| 1102 | func testInstallViaPythonScriptChild(t *testing.T, tester shellTester, onlineStatus OnlineStatus) { |
| 1103 | if !testutils.IsOnline() { |
| 1104 | t.Skip("skipping because we're currently offline") |
| 1105 | } |
| 1106 | |
| 1107 | // Set up |
| 1108 | defer testutils.BackupAndRestoreEnv("HISHTORY_TEST")() |
| 1109 | |
| 1110 | // Install via the python script |
| 1111 | additionalFlags := " " |
| 1112 | if onlineStatus == Offline { |
| 1113 | additionalFlags = "--offline" |
| 1114 | } |
| 1115 | out := tester.RunInteractiveShell(t, `curl https://hishtory.dev/install.py | python3 - `+additionalFlags) |
| 1116 | require.Contains(t, out, "Succesfully installed hishtory") |
| 1117 | r := regexp.MustCompile(`Setting secret hishtory key to (.*)`) |
| 1118 | matches := r.FindStringSubmatch(out) |
| 1119 | if len(matches) != 2 { |
| 1120 | t.Fatalf("Failed to extract userSecret from output=%#v: matches=%#v", out, matches) |
| 1121 | } |
| 1122 | userSecret := matches[1] |
| 1123 | |
| 1124 | // Test the status subcommand |
| 1125 | downloadData, err := cmd.GetDownloadData(makeTestOnlyContextWithFakeConfig()) |
| 1126 | require.NoError(t, err) |
| 1127 | out = tester.RunInteractiveShell(t, `hishtory status`) |
| 1128 | expectedOut := fmt.Sprintf("hiSHtory: %s\nEnabled: true\nSecret Key: %s\nCommit Hash: ", downloadData.Version, userSecret) |
| 1129 | require.Contains(t, out, expectedOut) |
| 1130 | |
| 1131 | // And test that it recorded that command |
| 1132 | time.Sleep(time.Second) |
| 1133 | out = tester.RunInteractiveShell(t, `hishtory export -pipefail`) |
| 1134 | if out != "hishtory status\n" { |
| 1135 | t.Fatalf("unexpected output from hishtory export=%#v", out) |
| 1136 | } |
| 1137 | } |
| 1138 | |
| 1139 | func TestInstallViaPythonScriptFromHead(t *testing.T) { |
| 1140 | markTestForSharding(t, 2) |
no test coverage detected