Skip to content

Instantly share code, notes, and snippets.

@avrebarra
Created November 18, 2019 09:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save avrebarra/f4148a3eeefc33b7cd48bb3aefb73f11 to your computer and use it in GitHub Desktop.
Save avrebarra/f4148a3eeefc33b7cd48bb3aefb73f11 to your computer and use it in GitHub Desktop.
Golang Basic Testing Helper
package some_test
import (
"testing"
)
// Credits to (Cory Jacobsen) from this file here https://github.com/unrolled/render/blob/7fc1b8f68b9beddc94385fd212c293caf729277a/render_test.go#L44
/* Test Helper */
func expect(t *testing.T, a interface{}, b interface{}) {
if a != b {
t.Errorf("Expected ||%#v|| (type %v) - Got ||%#v|| (type %v)", b, reflect.TypeOf(b), a, reflect.TypeOf(a))
}
}
func expectNil(t *testing.T, a interface{}) {
if a != nil {
t.Errorf("Expected ||nil|| - Got ||%#v|| (type %v)", a, reflect.TypeOf(a))
}
}
func expectNotNil(t *testing.T, a interface{}) {
if a == nil {
t.Errorf("Expected ||not nil|| - Got ||nil|| (type %v)", reflect.TypeOf(a))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment