Repository: maragudk/gomponents
Pull request #90 (2021-10-06 18:47:51)

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


Patch:
diff --git a/assert/assert.go b/internal/assert/assert.go
similarity index 80%
rename from assert/assert.go
rename to internal/assert/assert.go
index deeb3e9..901b4ad 100644
--- a/assert/assert.go
+++ b/internal/assert/assert.go
@@ -10,17 +10,20 @@ import (
 
 // 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")
 	}
 }


Test patch:
diff --git a/components/attributes_test.go b/components/attributes_test.go
index 9de0604..dcfbad2 100644
--- a/components/attributes_test.go
+++ b/components/attributes_test.go
@@ -5,8 +5,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 TestClasses(t *testing.T) {
diff --git a/components/documents_test.go b/components/documents_test.go
index 07f8697..21261fa 100644
--- a/components/documents_test.go
+++ b/components/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) {
diff --git a/components/elements_test.go b/components/elements_test.go
index 7dc4eec..7afa7db 100644
--- a/components/elements_test.go
+++ b/components/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) {
diff --git a/gomponents_test.go b/gomponents_test.go
index db2dfee..d8e9e07 100644
--- a/gomponents_test.go
+++ b/gomponents_test.go
@@ -9,7 +9,7 @@ import (
 	"testing"
 
 	g "github.com/maragudk/gomponents"
-	"github.com/maragudk/gomponents/assert"
+	"github.com/maragudk/gomponents/internal/assert"
 )
 
 func TestNodeFunc(t *testing.T) {
diff --git a/html/attributes_test.go b/html/attributes_test.go
index 76e3390..665dc94 100644
--- a/html/attributes_test.go
+++ b/html/attributes_test.go
@@ -5,8 +5,8 @@ import (
 	"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) {
diff --git a/html/elements_test.go b/html/elements_test.go
index e0cab4a..cced400 100644
--- a/html/elements_test.go
+++ b/html/elements_test.go
@@ -6,8 +6,8 @@ import (
 	"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{}
diff --git a/svg/attributes_test.go b/svg/attributes_test.go
index 41935e8..c41fb45 100644
--- a/svg/attributes_test.go
+++ b/svg/attributes_test.go
@@ -5,7 +5,7 @@ import (
 	"testing"
 
 	g "github.com/maragudk/gomponents"
-	"github.com/maragudk/gomponents/assert"
+	"github.com/maragudk/gomponents/internal/assert"
 	. "github.com/maragudk/gomponents/svg"
 )
 
diff --git a/svg/elements_test.go b/svg/elements_test.go
index 1b5e9d8..f1ed47c 100644
--- a/svg/elements_test.go
+++ b/svg/elements_test.go
@@ -5,7 +5,7 @@ import (
 	"testing"
 
 	g "github.com/maragudk/gomponents"
-	"github.com/maragudk/gomponents/assert"
+	"github.com/maragudk/gomponents/internal/assert"
 	. "github.com/maragudk/gomponents/svg"
 )