Run tests without CGO since that is how prod is built + fix broken tests from previous commit

This commit is contained in:
David Dworken 2022-09-21 19:58:10 -07:00
parent fb401dab88
commit 4fceaa3110

View File

@ -27,6 +27,8 @@ import (
func TestMain(m *testing.M) { func TestMain(m *testing.M) {
defer shared.RunTestServer()() defer shared.RunTestServer()()
cmd := exec.Command("go", "build", "-o", "/tmp/client") cmd := exec.Command("go", "build", "-o", "/tmp/client")
cmd.Env = os.Environ()
cmd.Env = append(cmd.Env, "CGO_ENABLED=0")
err := cmd.Run() err := cmd.Run()
if err != nil { if err != nil {
panic(fmt.Sprintf("failed to build client: %v", err)) panic(fmt.Sprintf("failed to build client: %v", err))
@ -1365,7 +1367,7 @@ ls /tmp`, randomCmdUuid, randomCmdUuid)
// Redact foo // Redact foo
out = tester.RunInteractiveShell(t, `hishtory redact --force foo`) out = tester.RunInteractiveShell(t, `hishtory redact --force foo`)
if out != "Permanently deleting 2 entries" { if out != "Permanently deleting 2 entries\n" {
t.Fatalf("hishtory redact gave unexpected output=%#v", out) t.Fatalf("hishtory redact gave unexpected output=%#v", out)
} }
@ -1378,7 +1380,7 @@ ls /tmp`, randomCmdUuid, randomCmdUuid)
// Redact s // Redact s
out = tester.RunInteractiveShell(t, `hishtory redact --force s`) out = tester.RunInteractiveShell(t, `hishtory redact --force s`)
if out != "Permanently deleting 10 entries" { if out != "Permanently deleting 10 entries\n" {
t.Fatalf("hishtory redact gave unexpected output=%#v", out) t.Fatalf("hishtory redact gave unexpected output=%#v", out)
} }
@ -1426,7 +1428,7 @@ ls /tmp`, randomCmdUuid, randomCmdUuid)
restoreInstall2 := shared.BackupAndRestoreWithId(t, "-2") restoreInstall2 := shared.BackupAndRestoreWithId(t, "-2")
restoreInstall1() restoreInstall1()
out = tester.RunInteractiveShell(t, `hishtory redact --force `+randomCmdUuid) out = tester.RunInteractiveShell(t, `hishtory redact --force `+randomCmdUuid)
if out != "Permanently deleting 2 entries" { if out != "Permanently deleting 2 entries\n" {
t.Fatalf("hishtory redact gave unexpected output=%#v", out) t.Fatalf("hishtory redact gave unexpected output=%#v", out)
} }