Add negative conditions to search queries + tests + better error messages by including filename:line in error messages

This commit is contained in:
David Dworken
2022-04-11 22:36:52 -07:00
parent 970e5d75db
commit 5325fc75ae
4 changed files with 112 additions and 33 deletions

View File

@ -6,6 +6,7 @@ import (
"os"
"os/exec"
"path"
"runtime"
"strings"
"testing"
"time"
@ -98,12 +99,14 @@ func RunTestServer(t *testing.T) func() {
func Check(t *testing.T, err error) {
if err != nil {
t.Fatalf("Unexpected error: %v", err)
_, filename, line, _ := runtime.Caller(1)
t.Fatalf("Unexpected error at %s:%d: %v", filename, line, err)
}
}
func CheckWithInfo(t *testing.T, err error, additionalInfo string) {
if err != nil {
t.Fatalf("Unexpected error: %v! Additional info: %v", err, additionalInfo)
_, filename, line, _ := runtime.Caller(1)
t.Fatalf("Unexpected error: %v at %s:%d! Additional info: %v", err, filename, line, additionalInfo)
}
}