From d6a49593b7f904f9e05156d0d3fe2254c272448b Mon Sep 17 00:00:00 2001 From: Tim Van Baak Date: Wed, 5 Feb 2025 09:25:33 -0800 Subject: [PATCH] TIL t.Helper() --- core/execute_test.go | 3 +++ core/items_test.go | 1 + core/source_test.go | 3 +++ 3 files changed, 7 insertions(+) diff --git a/core/execute_test.go b/core/execute_test.go index 78df685..483defb 100644 --- a/core/execute_test.go +++ b/core/execute_test.go @@ -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") } diff --git a/core/items_test.go b/core/items_test.go index 7c29618..f0702c0 100644 --- a/core/items_test.go +++ b/core/items_test.go @@ -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, diff --git a/core/source_test.go b/core/source_test.go index b17d8a3..fbd4f79 100644 --- a/core/source_test.go +++ b/core/source_test.go @@ -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)