Skip to content

Commit

Permalink
test: checking ErrorList conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
adamdecaf committed Dec 13, 2023
1 parent cf13e69 commit 0987d2c
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions error_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import (
"errors"
"strings"
"testing"

"github.com/stretchr/testify/require"
)

func TestParseError_Error(t *testing.T) {
Expand Down Expand Up @@ -117,6 +119,18 @@ func TestErrorList_Empty(t *testing.T) {
buf.Reset()
}

func TestErrorList__EmptyThenNot(t *testing.T) {
var el ErrorList
require.NoError(t, el.Err())
require.Equal(t, "<nil>", el.Error())
require.True(t, el.Empty())

el.Add(errors.New("bad thing"))
require.Error(t, el.Err())
require.Equal(t, "bad thing", el.Error())
require.False(t, el.Empty())
}

func TestErrorList_MarshalJSON(t *testing.T) {
errorList := ErrorList{}
errorList.Add(errors.New("testing"))
Expand Down

0 comments on commit 0987d2c

Please sign in to comment.