Skip to content

Commit

Permalink
get rid of ensure.StringContains
Browse files Browse the repository at this point in the history
  • Loading branch information
vtopc committed Nov 2, 2024
1 parent 50ab646 commit 7c08e84
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
3 changes: 1 addition & 2 deletions exports_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"testing"

"github.com/facebookgo/ensure"
"github.com/mailgun/mailgun-go/v4"
"github.com/stretchr/testify/require"
)
Expand Down Expand Up @@ -43,5 +42,5 @@ func TestExportsLink(t *testing.T) {
ctx := context.Background()
url, err := mg.GetExportLink(ctx, "12")
require.NoError(t, err)
ensure.StringContains(t, url, "/some/s3/url")
require.Contains(t, url, "/some/s3/url")
}
12 changes: 6 additions & 6 deletions messages_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"testing"
"time"

"github.com/facebookgo/ensure"
"github.com/mailgun/mailgun-go/v4"
"github.com/stretchr/testify/require"
)
Expand Down Expand Up @@ -492,8 +491,9 @@ func TestSendEOFError(t *testing.T) {
m := mailgun.NewMessage(fromUser, exampleSubject, exampleText, toUser)
_, _, err := mg.Send(context.Background(), m)
require.NotNil(t, err)
ensure.StringContains(t, err.Error(), "remote server prematurely closed connection: Post ")
ensure.StringContains(t, err.Error(), "EOF")
// TODO(vtopc): do not compare strings, use errors.Is or errors.As:
require.Contains(t, err.Error(), "remote server prematurely closed connection: Post ")
require.ErrorIs(t, err, io.EOF)
}

func TestHasRecipient(t *testing.T) {
Expand Down Expand Up @@ -596,7 +596,7 @@ func TestAddOverrideHeader(t *testing.T) {
require.Equal(t, exampleMessage, msg)
require.Equal(t, exampleID, id)

ensure.StringContains(t, mg.GetCurlOutput(), "Host:")
require.Contains(t, mg.GetCurlOutput(), "Host:")
}

func TestOnBehalfOfSubaccount(t *testing.T) {
Expand Down Expand Up @@ -635,7 +635,7 @@ func TestOnBehalfOfSubaccount(t *testing.T) {
require.Equal(t, exampleMessage, msg)
require.Equal(t, exampleID, id)

ensure.StringContains(t, mg.GetCurlOutput(), "Host:")
require.Contains(t, mg.GetCurlOutput(), "Host:")
}

func TestCaptureCurlOutput(t *testing.T) {
Expand Down Expand Up @@ -664,7 +664,7 @@ func TestCaptureCurlOutput(t *testing.T) {
require.Equal(t, exampleMessage, msg)
require.Equal(t, exampleID, id)

ensure.StringContains(t, mg.GetCurlOutput(), "curl")
require.Contains(t, mg.GetCurlOutput(), "curl")
t.Logf("%s", mg.GetCurlOutput())
}

Expand Down
8 changes: 5 additions & 3 deletions parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@ import (
"testing"
"time"

"github.com/facebookgo/ensure"
"github.com/mailgun/mailgun-go/v4/events"
"github.com/stretchr/testify/require"
)

func TestParseErrors(t *testing.T) {
_, err := ParseEvent([]byte(""))
ensure.StringContains(t, err.Error(), "failed to recognize event")
require.NotNil(t, err)
// TODO(vtopc): do not compare strings, use errors.Is or errors.As:
require.Contains(t, err.Error(), "failed to recognize event")

_, err = ParseEvent([]byte(`{"event": "unknown_event"}`))
require.EqualError(t, err, "unsupported event: 'unknown_event'")
Expand All @@ -22,7 +23,8 @@ func TestParseErrors(t *testing.T) {
"event": "accepted",
"timestamp": "1420255392.850187"
}`))
ensure.StringContains(t, err.Error(), "failed to parse event 'accepted'")
// TODO(vtopc): do not compare strings, use errors.Is or errors.As:
require.Contains(t, err.Error(), "failed to parse event 'accepted'")
}

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

0 comments on commit 7c08e84

Please sign in to comment.