1
0

Mark the assert test helpers as such (#90)

Using `t.Helper()`.

Also move the assert package to be internal.
This commit is contained in:
Markus Wüstenberg 2021-10-06 20:49:43 +02:00 committed by GitHub
parent 33524d6836
commit 4858e5d47d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 14 additions and 11 deletions

View File

@ -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) {

View File

@ -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) {

View File

@ -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) {

View File

@ -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) {

View File

@ -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) {

View File

@ -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{}

View File

@ -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")
}
}

View File

@ -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"
)

View File

@ -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"
)