Tests passing when being run offline, still not integrated with the new API endpoints yet

This commit is contained in:
David Dworken
2022-04-28 11:26:55 -07:00
parent 8a018b71b8
commit 46d7e9e013
4 changed files with 22 additions and 4 deletions

View File

@ -3,6 +3,7 @@ package shared
import (
"bytes"
"fmt"
"net/http"
"os"
"os/exec"
"path"
@ -103,7 +104,7 @@ func RunTestServer() func() {
if err != nil && err.Error() != "os: process already finished" {
panic(fmt.Sprintf("failed to kill server process: %v", err))
}
if strings.Contains(stderr.String()+stdout.String(), "failed to") {
if strings.Contains(stderr.String()+stdout.String(), "failed to") && IsOnline() {
panic(fmt.Sprintf("server failed to do something: stderr=%#v, stdout=%#v", stderr.String(), stdout.String()))
}
if strings.Contains(stderr.String()+stdout.String(), "ERROR:") {
@ -126,3 +127,8 @@ func CheckWithInfo(t *testing.T, err error, additionalInfo string) {
t.Fatalf("Unexpected error: %v at %s:%d! Additional info: %v", err, filename, line, additionalInfo)
}
}
func IsOnline() bool {
_, err := http.Get("https://hishtory.dev")
return err == nil
}