Skip to content

Commit

Permalink
added nested test case
Browse files Browse the repository at this point in the history
  • Loading branch information
mkatychev committed May 13, 2020
1 parent fd600c9 commit b660ff8
Showing 1 changed file with 27 additions and 10 deletions.
37 changes: 27 additions & 10 deletions format_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,33 @@ import (
)

func TestListFormatFuncSingle(t *testing.T) {
expected := `foo`

errors := []error{
errors.New("foo"),
}

actual := ListFormatFunc(errors)
if actual != expected {
t.Fatalf("bad: %#v", actual)
}
t.Run("Flat", func(t *testing.T) {
expected := `foo`

errors := []error{
errors.New("foo"),
}

actual := ListFormatFunc(errors)
if actual != expected {
t.Fatalf("bad: %#v", actual)
}
})

t.Run("Nested", func(t *testing.T) {
expected := `foo`

nestedErrors := &Error{
Errors: []error{
&Error{Errors: []error{errors.New("foo")}},
},
}

actual := ListFormatFunc(nestedErrors.Errors)
if actual != expected {
t.Fatalf("bad: %#v", actual)
}
})
}

func TestListFormatFuncMultiple(t *testing.T) {
Expand Down

0 comments on commit b660ff8

Please sign in to comment.