diff --git a/routes_test.go b/routes_test.go index 94677fb..69cce19 100644 --- a/routes_test.go +++ b/routes_test.go @@ -7,15 +7,31 @@ import ( "net" "net/http" "net/http/httptest" + "os" "testing" "time" + "github.com/jasonlovesdoggo/abacus/utils" + "github.com/goccy/go-json" "github.com/gin-gonic/gin" "github.com/stretchr/testify/assert" ) +func init() { + utils.LoadEnv() + + if os.Getenv("TESTING") != "true" { + fmt.Println("Running tests in non-testing mode. Exiting...") + os.Exit(0) + } + if Client.Get(context.Background(), "K:stats:Total") != nil { + fmt.Println("Running tests on a non-empty database. Exiting...") + os.Exit(0) + } +} + // mockResponseWriter wraps httptest.ResponseRecorder to implement http.CloseNotifier. type mockResponseWriter struct { *httptest.ResponseRecorder