internal/assert/assert.go (view raw)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | // Package assert provides testing helpers. package assert import ( "strings" "testing" g "go.alanpearce.eu/gomponents" ) // Equal checks for equality between the given expected string and the rendered Node string. func Equal(t *testing.T, expected string, actual g.Node) { t.Helper() var b strings.Builder _ = actual.Render(&b) if expected != b.String() { t.Fatalf(`expected "%v" but got "%v"`, expected, b.String()) } } // Error checks for a non-nil error. func Error(t *testing.T, err error) { t.Helper() if err == nil { t.Fatal("error is nil") } } |