TIL t.Helper()
This commit is contained in:
parent
cb7bd6e3ba
commit
d6a49593b7
@ -7,16 +7,19 @@ import (
|
|||||||
|
|
||||||
func TestExecute(t *testing.T) {
|
func TestExecute(t *testing.T) {
|
||||||
assertLen := func(items []Item, length int) {
|
assertLen := func(items []Item, length int) {
|
||||||
|
t.Helper()
|
||||||
if len(items) != length {
|
if len(items) != length {
|
||||||
t.Fatalf("Expected %d items, got %d", length, len(items))
|
t.Fatalf("Expected %d items, got %d", length, len(items))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
assertNil := func(err error) {
|
assertNil := func(err error) {
|
||||||
|
t.Helper()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
assertNotNil := func(err error) {
|
assertNotNil := func(err error) {
|
||||||
|
t.Helper()
|
||||||
if err == nil {
|
if err == nil {
|
||||||
t.Fatal("expected err")
|
t.Fatal("expected err")
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func AssertItemIs(t *testing.T, item Item, expected string) {
|
func AssertItemIs(t *testing.T, item Item, expected string) {
|
||||||
|
t.Helper()
|
||||||
actual := fmt.Sprintf(
|
actual := fmt.Sprintf(
|
||||||
"%s/%s/%t/%s/%s/%s/%s/%d",
|
"%s/%s/%t/%s/%s/%s/%s/%d",
|
||||||
item.Source,
|
item.Source,
|
||||||
|
@ -142,6 +142,7 @@ func TestOnCreateAction(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
execute := func(argv []string) []Item {
|
execute := func(argv []string) []Item {
|
||||||
|
t.Helper()
|
||||||
items, _, err := Execute("test", argv, nil, nil, "", time.Minute)
|
items, _, err := Execute("test", argv, nil, nil, "", time.Minute)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal("unexpected error executing test fetch")
|
t.Fatal("unexpected error executing test fetch")
|
||||||
@ -153,12 +154,14 @@ func TestOnCreateAction(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onCreate := func(argv []string) {
|
onCreate := func(argv []string) {
|
||||||
|
t.Helper()
|
||||||
if err := UpdateAction(db, "test", "on_create", argv); err != nil {
|
if err := UpdateAction(db, "test", "on_create", argv); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
getItem := func(id string) Item {
|
getItem := func(id string) Item {
|
||||||
|
t.Helper()
|
||||||
item, err := GetItem(db, "test", id)
|
item, err := GetItem(db, "test", id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
|
Loading…
Reference in New Issue
Block a user