tests passing inside act, hopefully on real actions

This commit is contained in:
David Dworken 2022-04-13 21:30:27 -07:00
parent 908257306e
commit e2b5fd13bf
4 changed files with 12 additions and 5 deletions

View File

@ -119,7 +119,7 @@ func TestUpdateReleaseVersion(t *testing.T) {
// Check that ReleaseVersion hasn't been set yet
if ReleaseVersion != "UNKNOWN" {
t.Fatalf("ReleaseVersion isn't as expected: %#v", ReleaseVersion)
t.Fatalf("initial ReleaseVersion isn't as expected: %#v", ReleaseVersion)
}
// Update it
@ -130,7 +130,7 @@ func TestUpdateReleaseVersion(t *testing.T) {
// And check that the new value looks reasonable
if !strings.HasPrefix(ReleaseVersion, "v0.") {
t.Fatalf("ReleaseVersion isn't as expected: %#v", ReleaseVersion)
t.Fatalf("ReleaseVersion wasn't updated to contain a version: %#v", ReleaseVersion)
}
}

View File

@ -420,11 +420,11 @@ func TestAdvancedQuery(t *testing.T) {
// Test filtering out a search item that also looks like it could be a search for a flag
entry = data.MakeFakeHistoryEntry("foo -echo")
manuallySubmitHistoryEntry(t, userSecret, entry)
out = RunInteractiveBashCommands(t, `hishtory query -echo`)
out = RunInteractiveBashCommands(t, `hishtory query -echo -install`)
if strings.Contains(out, "echo") {
t.Fatalf("hishtory query contains unexpected result, out=%#v", out)
}
if strings.Count(out, "\n") != 7 {
if strings.Count(out, "\n") != 5 {
t.Fatalf("hishtory query has the wrong number of lines=%d, out=%#v", strings.Count(out, "\n"), out)
}
}

View File

@ -342,6 +342,12 @@ func installBinary(homedir string) (string, error) {
if err != nil {
clientPath = path.Join(homedir, shared.HISHTORY_PATH, "hishtory")
}
if _, err := os.Stat(clientPath); err == nil {
err = syscall.Unlink(clientPath)
if err != nil {
return "", fmt.Errorf("failed to unlink %s for install: %v", clientPath, err)
}
}
err = copyFile(os.Args[0], clientPath)
if err != nil {
return "", fmt.Errorf("failed to copy hishtory binary to $PATH: %v", err)
@ -394,7 +400,7 @@ func Update(url string) error {
}
err = syscall.Unlink(path.Join(homedir, shared.HISHTORY_PATH, "hishtory"))
if err != nil {
return fmt.Errorf("failed to unlink %s: %v", path.Join(homedir, shared.HISHTORY_PATH, "hishtory"), err)
return fmt.Errorf("failed to unlink %s for update: %v", path.Join(homedir, shared.HISHTORY_PATH, "hishtory"), err)
}
// TODO: Check the SLSA attestation before installing
cmd = exec.Command("/tmp/hishtory-client", "install")

View File

@ -81,6 +81,7 @@ func RunTestServer(t *testing.T) func() {
if err != nil {
t.Fatalf("failed to start server: %v", err)
}
// TODO: Optimize this by streaming stdout and waiting until we see the "listening ..." message
time.Sleep(time.Second * 3)
go func() {
_ = cmd.Wait()