all repos — gomponents @ 4858e5d47d5bed0221a19ab46af306b8eab5935d

HTML components in pure Go

Mark the assert test helpers as such (#90) Using `t.Helper()`. Also move the assert package to be internal.

Markus Wüstenberg
commit

4858e5d47d5bed0221a19ab46af306b8eab5935d

parent

33524d683661bf73fd224a76ec62fb88b2b3c767

M assert/assert.gointernal/assert/assert.go
@@ -10,17 +10,20 @@ )
// 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.Errorf("expected `%v` but got `%v`", expected, actual) - t.FailNow() + t.Fatalf(`expected "%v" but got "%v"`, expected, actual) } } // Error checks for a non-nil error. func Error(t *testing.T, err error) { + t.Helper() + if err == nil { - t.FailNow() + t.Fatal("error is nil") } }
M components/attributes_test.gocomponents/attributes_test.go
@@ -5,8 +5,8 @@ "os"
"testing" g "github.com/maragudk/gomponents" - "github.com/maragudk/gomponents/assert" c "github.com/maragudk/gomponents/components" + "github.com/maragudk/gomponents/internal/assert" ) func TestClasses(t *testing.T) {
M components/documents_test.gocomponents/documents_test.go
@@ -4,9 +4,9 @@ import (
"testing" g "github.com/maragudk/gomponents" - "github.com/maragudk/gomponents/assert" . "github.com/maragudk/gomponents/components" . "github.com/maragudk/gomponents/html" + "github.com/maragudk/gomponents/internal/assert" ) func TestHTML5(t *testing.T) {
M components/elements_test.gocomponents/elements_test.go
@@ -4,8 +4,8 @@ import (
"testing" g "github.com/maragudk/gomponents" - "github.com/maragudk/gomponents/assert" c "github.com/maragudk/gomponents/components" + "github.com/maragudk/gomponents/internal/assert" ) func TestInputHidden(t *testing.T) {
M gomponents_test.gogomponents_test.go
@@ -9,7 +9,7 @@ "strings"
"testing" g "github.com/maragudk/gomponents" - "github.com/maragudk/gomponents/assert" + "github.com/maragudk/gomponents/internal/assert" ) func TestNodeFunc(t *testing.T) {
M html/attributes_test.gohtml/attributes_test.go
@@ -5,8 +5,8 @@ "fmt"
"testing" g "github.com/maragudk/gomponents" - "github.com/maragudk/gomponents/assert" . "github.com/maragudk/gomponents/html" + "github.com/maragudk/gomponents/internal/assert" ) func TestBooleanAttributes(t *testing.T) {
M html/elements_test.gohtml/elements_test.go
@@ -6,8 +6,8 @@ "fmt"
"testing" g "github.com/maragudk/gomponents" - "github.com/maragudk/gomponents/assert" . "github.com/maragudk/gomponents/html" + "github.com/maragudk/gomponents/internal/assert" ) type erroringWriter struct{}
M svg/attributes_test.gosvg/attributes_test.go
@@ -5,7 +5,7 @@ "fmt"
"testing" g "github.com/maragudk/gomponents" - "github.com/maragudk/gomponents/assert" + "github.com/maragudk/gomponents/internal/assert" . "github.com/maragudk/gomponents/svg" )
M svg/elements_test.gosvg/elements_test.go
@@ -5,7 +5,7 @@ "fmt"
"testing" g "github.com/maragudk/gomponents" - "github.com/maragudk/gomponents/assert" + "github.com/maragudk/gomponents/internal/assert" . "github.com/maragudk/gomponents/svg" )