TIL t.Helper()

This commit is contained in:
Tim Van Baak 2025-02-05 09:25:33 -08:00
parent cb7bd6e3ba
commit d6a49593b7
3 changed files with 7 additions and 0 deletions

View File

@ -7,16 +7,19 @@ import (
func TestExecute(t *testing.T) {
assertLen := func(items []Item, length int) {
t.Helper()
if len(items) != length {
t.Fatalf("Expected %d items, got %d", length, len(items))
}
}
assertNil := func(err error) {
t.Helper()
if err != nil {
t.Fatal(err)
}
}
assertNotNil := func(err error) {
t.Helper()
if err == nil {
t.Fatal("expected err")
}

View File

@ -8,6 +8,7 @@ import (
)
func AssertItemIs(t *testing.T, item Item, expected string) {
t.Helper()
actual := fmt.Sprintf(
"%s/%s/%t/%s/%s/%s/%s/%d",
item.Source,

View File

@ -142,6 +142,7 @@ func TestOnCreateAction(t *testing.T) {
}
execute := func(argv []string) []Item {
t.Helper()
items, _, err := Execute("test", argv, nil, nil, "", time.Minute)
if err != nil {
t.Fatal("unexpected error executing test fetch")
@ -153,12 +154,14 @@ func TestOnCreateAction(t *testing.T) {
}
onCreate := func(argv []string) {
t.Helper()
if err := UpdateAction(db, "test", "on_create", argv); err != nil {
t.Fatal(err)
}
}
getItem := func(id string) Item {
t.Helper()
item, err := GetItem(db, "test", id)
if err != nil {
t.Fatal(err)