3
0
corteza/internal/test/assert.go
Denis Arh 500e8e317c Improve SMTP
API can now be started without properly configured SMTP (it complains when it is used)
Send() function can now use alternative dialers (mostly used for testing)
Added mailhog service (make mailhog.up) to ease mail testing
Add default .env example that points to localhost:1025 (mailhog) setup
Proper unit testing
2019-01-13 14:45:27 +01:00

28 lines
590 B
Go

package test
import (
"fmt"
"runtime"
"testing"
)
func Assert(t *testing.T, ok bool, format string, args ...interface{}) bool {
if !ok {
_, file, line, _ := runtime.Caller(1)
caller := fmt.Sprintf("\nAsserted at:%s:%d", file, line)
t.Fatalf(format+caller, args...)
}
return ok
}
func ErrNil(t *testing.T, err error, format string, args ...interface{}) bool {
if err != nil {
_, file, line, _ := runtime.Caller(1)
caller := fmt.Sprintf("\nAsserted at:%s:%d", file, line)
t.Fatalf(format+caller, append([]interface{}{err}, args...)...)
return false
}
return true
}