Skip to content

Commit

Permalink
get rid of ensure.DeepEqual
Browse files Browse the repository at this point in the history
  • Loading branch information
vtopc committed Nov 2, 2024
1 parent caba8e0 commit 2f7fd84
Show file tree
Hide file tree
Showing 20 changed files with 178 additions and 187 deletions.
4 changes: 2 additions & 2 deletions attachments_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ func TestMultipleAttachments(t *testing.T) {
e, err := findAcceptedMessage(mg, id)
ensure.NotNil(t, e)

ensure.DeepEqual(t, e.ID, id)
require.Equal(t, e.ID, id)
require.Len(t, e.Message.Attachments, 2)
for _, f := range e.Message.Attachments {
t.Logf("attachment: %v\n", f)
ensure.DeepEqual(t, f.Size, 100)
require.Equal(t, 100, f.Size)
}
}

Expand Down
2 changes: 1 addition & 1 deletion bounces_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func TestGetSingleBounce(t *testing.T) {

var ure *mailgun.UnexpectedResponseError
require.ErrorAs(t, err, &ure)
ensure.DeepEqual(t, ure.Actual, http.StatusNotFound)
require.Equal(t, http.StatusNotFound, ure.Actual)
}

func TestAddDelBounces(t *testing.T) {
Expand Down
27 changes: 13 additions & 14 deletions domains_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"net/http"
"testing"

"github.com/facebookgo/ensure"
"github.com/mailgun/mailgun-go/v4"
"github.com/stretchr/testify/require"
)
Expand Down Expand Up @@ -67,7 +66,7 @@ func TestGetSingleDomainNotExist(t *testing.T) {
}
var ure *mailgun.UnexpectedResponseError
require.ErrorAs(t, err, &ure)
ensure.DeepEqual(t, ure.Actual, http.StatusNotFound)
require.Equal(t, http.StatusNotFound, ure.Actual)
}

func TestAddUpdateDeleteDomain(t *testing.T) {
Expand Down Expand Up @@ -97,17 +96,17 @@ func TestDomainConnection(t *testing.T) {
info, err := mg.GetDomainConnection(ctx, testDomain)
require.NoError(t, err)

ensure.DeepEqual(t, info.RequireTLS, true)
ensure.DeepEqual(t, info.SkipVerification, true)
require.True(t, info.RequireTLS)
require.True(t, info.SkipVerification)

info.RequireTLS = false
err = mg.UpdateDomainConnection(ctx, testDomain, info)
require.NoError(t, err)

info, err = mg.GetDomainConnection(ctx, testDomain)
require.NoError(t, err)
ensure.DeepEqual(t, info.RequireTLS, false)
ensure.DeepEqual(t, info.SkipVerification, true)
require.False(t, info.RequireTLS)
require.True(t, info.SkipVerification)
}

func TestDomainTracking(t *testing.T) {
Expand All @@ -118,37 +117,37 @@ func TestDomainTracking(t *testing.T) {
info, err := mg.GetDomainTracking(ctx, testDomain)
require.NoError(t, err)

ensure.DeepEqual(t, info.Unsubscribe.Active, false)
require.False(t, info.Unsubscribe.Active)
require.True(t, len(info.Unsubscribe.HTMLFooter) != 0)
require.True(t, len(info.Unsubscribe.TextFooter) != 0)
ensure.DeepEqual(t, info.Click.Active, true)
ensure.DeepEqual(t, info.Open.Active, true)
require.True(t, info.Click.Active)
require.True(t, info.Open.Active)

// Click Tracking
err = mg.UpdateClickTracking(ctx, testDomain, "no")
require.NoError(t, err)

info, err = mg.GetDomainTracking(ctx, testDomain)
require.NoError(t, err)
ensure.DeepEqual(t, info.Click.Active, false)
require.False(t, info.Click.Active)

// Open Tracking
err = mg.UpdateOpenTracking(ctx, testDomain, "no")
require.NoError(t, err)

info, err = mg.GetDomainTracking(ctx, testDomain)
require.NoError(t, err)
ensure.DeepEqual(t, info.Open.Active, false)
require.False(t, info.Open.Active)

// Unsubscribe
err = mg.UpdateUnsubscribeTracking(ctx, testDomain, "yes", "<h2>Hi</h2>", "Hi")
require.NoError(t, err)

info, err = mg.GetDomainTracking(ctx, testDomain)
require.NoError(t, err)
ensure.DeepEqual(t, info.Unsubscribe.Active, true)
ensure.DeepEqual(t, info.Unsubscribe.HTMLFooter, "<h2>Hi</h2>")
ensure.DeepEqual(t, info.Unsubscribe.TextFooter, "Hi")
require.True(t, info.Unsubscribe.Active, true)
require.Equal(t, "<h2>Hi</h2>", info.Unsubscribe.HTMLFooter)
require.Equal(t, "Hi", info.Unsubscribe.TextFooter)
}

func TestDomainVerify(t *testing.T) {
Expand Down
26 changes: 13 additions & 13 deletions email_validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,19 @@ func TestEmailValidationV4(t *testing.T) {
require.NoError(t, err)

require.True(t, ev.IsValid)
ensure.DeepEqual(t, ev.MailboxVerification, "")
require.Equal(t, "", ev.MailboxVerification)
ensure.False(t, ev.IsDisposableAddress)
ensure.False(t, ev.IsRoleAddress)
require.Equal(t, "", ev.Parts.DisplayName)
ensure.DeepEqual(t, ev.Parts.LocalPart, "foo")
ensure.DeepEqual(t, ev.Parts.Domain, "mailgun.com")
ensure.DeepEqual(t, ev.Reason, "")
require.Equal(t, "foo", ev.Parts.LocalPart)
require.Equal(t, "mailgun.com", ev.Parts.Domain)
require.Equal(t, "", ev.Reason)
require.True(t, len(ev.Reasons) != 0)
ensure.DeepEqual(t, ev.Reasons[0], "no-reason")
ensure.DeepEqual(t, ev.Risk, "unknown")
ensure.DeepEqual(t, ev.Result, "deliverable")
ensure.DeepEqual(t, ev.Engagement.Behavior, "disengaged")
ensure.DeepEqual(t, ev.Engagement.Engaging, false)
require.Equal(t, "no-reason", ev.Reasons[0])
require.Equal(t, "unknown", ev.Risk)
require.Equal(t, "deliverable", ev.Result)
require.Equal(t, "disengaged", ev.Engagement.Behavior)
require.False(t, ev.Engagement.Engaging)
ensure.False(t, ev.Engagement.IsBot)
}

Expand Down Expand Up @@ -77,11 +77,11 @@ func TestUnmarshallResponse(t *testing.T) {
require.NoError(t, err)

require.True(t, ev.IsValid)
ensure.DeepEqual(t, ev.MailboxVerification, "unknown")
require.Equal(t, "unknown", ev.MailboxVerification)
ensure.False(t, ev.IsDisposableAddress)
ensure.False(t, ev.IsRoleAddress)
require.Equal(t, "", ev.Parts.DisplayName)
ensure.DeepEqual(t, ev.Parts.LocalPart, "some_email")
ensure.DeepEqual(t, ev.Parts.Domain, "aol.com")
ensure.DeepEqual(t, ev.Reason, "no-reason")
require.Equal(t, "some_email", ev.Parts.LocalPart)
require.Equal(t, "aol.com", ev.Parts.Domain)
require.Equal(t, "no-reason", ev.Reason)
}
4 changes: 2 additions & 2 deletions events_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func TestEventIteratorGetNext(t *testing.T) {

require.True(t, it.Previous(ctx, &previousPage))
require.True(t, len(previousPage) != 0)
ensure.DeepEqual(t, previousPage[0].GetID(), firstPage[0].GetID())
require.Equal(t, previousPage[0].GetID(), firstPage[0].GetID())

// First()
require.True(t, it.First(ctx, &firstPage))
Expand Down Expand Up @@ -108,7 +108,7 @@ func TestEventPoller(t *testing.T) {
// Ensure we found our email
ensure.NotNil(t, it.Err())
require.NotNil(t, accepted)
ensure.DeepEqual(t, accepted.Recipient, "user@"+testDomain)
require.Equal(t, "user@"+testDomain, accepted.Recipient)
}

func ExampleMailgunImpl_ListEvents() {
Expand Down
12 changes: 6 additions & 6 deletions exports_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ func TestExports(t *testing.T) {
require.NoError(t, err)
require.Len(t, list, 1)

ensure.DeepEqual(t, list[0].ID, "0")
ensure.DeepEqual(t, list[0].URL, "/domains")
ensure.DeepEqual(t, list[0].Status, "complete")
require.Equal(t, "0", list[0].ID)
require.Equal(t, "/domains", list[0].URL)
require.Equal(t, "complete", list[0].Status)

export, err := mg.GetExport(ctx, "0")
require.NoError(t, err)
ensure.DeepEqual(t, export.ID, "0")
ensure.DeepEqual(t, export.URL, "/domains")
ensure.DeepEqual(t, export.Status, "complete")
require.Equal(t, "0", export.ID)
require.Equal(t, "/domains", export.URL)
require.Equal(t, "complete", export.Status)
}

func TestExportsLink(t *testing.T) {
Expand Down
9 changes: 4 additions & 5 deletions ips_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"os"
"testing"

"github.com/facebookgo/ensure"
"github.com/mailgun/mailgun-go/v4"
"github.com/stretchr/testify/require"
)
Expand All @@ -31,9 +30,9 @@ func TestListIPS(t *testing.T) {
ip, err := mg.GetIP(ctx, list[0].IP)
require.NoError(t, err)

ensure.DeepEqual(t, ip.IP, list[0].IP)
ensure.DeepEqual(t, ip.Dedicated, true)
ensure.DeepEqual(t, ip.RDNS, "luna.mailgun.net")
require.Equal(t, list[0].IP, ip.IP)
require.True(t, ip.Dedicated)
require.Equal(t, "luna.mailgun.net", ip.RDNS)
}

func TestDomainIPS(t *testing.T) {
Expand All @@ -48,7 +47,7 @@ func TestDomainIPS(t *testing.T) {
require.NoError(t, err)

require.Len(t, list, 1)
ensure.DeepEqual(t, list[0].IP, "192.172.1.1")
require.Equal(t, list[0].IP, "192.172.1.1")

err = mg.DeleteDomainIP(ctx, "192.172.1.1")
require.NoError(t, err)
Expand Down
5 changes: 2 additions & 3 deletions limits_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 All @@ -17,6 +16,6 @@ func TestLimits(t *testing.T) {
limits, err := mg.GetTagLimits(ctx, testDomain)
require.NoError(t, err)

ensure.DeepEqual(t, limits.Limit, 50000)
ensure.DeepEqual(t, limits.Count, 5000)
require.Equal(t, 50000, limits.Limit)
require.Equal(t, 5000, limits.Count)
}
9 changes: 4 additions & 5 deletions mailgun_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"net/http/httptest"
"testing"

"github.com/facebookgo/ensure"
"github.com/mailgun/mailgun-go/v4"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
Expand All @@ -20,13 +19,13 @@ const apiKey = "valid-mailgun-api-key"
func TestMailgun(t *testing.T) {
m := mailgun.NewMailgun(domain, apiKey)

ensure.DeepEqual(t, m.Domain(), domain)
ensure.DeepEqual(t, m.APIKey(), apiKey)
ensure.DeepEqual(t, m.Client(), http.DefaultClient)
require.Equal(t, domain, m.Domain())
require.Equal(t, apiKey, m.APIKey())
require.Equal(t, http.DefaultClient, m.Client())

client := new(http.Client)
m.SetClient(client)
ensure.DeepEqual(t, client, m.Client())
require.Equal(t, client, m.Client())
}

func TestInvalidBaseAPI(t *testing.T) {
Expand Down
18 changes: 9 additions & 9 deletions mailing_lists_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ func TestMailingListMembers(t *testing.T) {

theMember, err := mg.GetMember(ctx, "[email protected]", address)
require.NoError(t, err)
ensure.DeepEqual(t, theMember.Address, protoJoe.Address)
ensure.DeepEqual(t, theMember.Name, protoJoe.Name)
ensure.DeepEqual(t, theMember.Subscribed, protoJoe.Subscribed)
require.Equal(t, protoJoe.Address, theMember.Address)
require.Equal(t, protoJoe.Name, theMember.Name)
require.Equal(t, protoJoe.Subscribed, theMember.Subscribed)
require.Len(t, theMember.Vars, 0)

_, err = mg.UpdateMember(ctx, "[email protected]", address, mailgun.Member{
Expand All @@ -63,9 +63,9 @@ func TestMailingListMembers(t *testing.T) {

theMember, err = mg.GetMember(ctx, "[email protected]", address)
require.NoError(t, err)
ensure.DeepEqual(t, theMember.Name, "Joe Cool")
require.Equal(t, "Joe Cool", theMember.Name)
require.NoError(t, mg.DeleteMember(ctx, "[email protected]", address))
ensure.DeepEqual(t, countMembers(), startCount)
require.Equal(t, startCount, countMembers())

err = mg.CreateMemberList(ctx, nil, address, []interface{}{
mailgun.Member{
Expand All @@ -89,7 +89,7 @@ func TestMailingListMembers(t *testing.T) {

theMember, err = mg.GetMember(ctx, "[email protected]", address)
require.NoError(t, err)
ensure.DeepEqual(t, theMember.Name, "Joe's Cool Account")
require.Equal(t, "Joe's Cool Account", theMember.Name)
ensure.NotNil(t, theMember.Subscribed)
require.True(t, *theMember.Subscribed)
}
Expand Down Expand Up @@ -135,7 +135,7 @@ func TestMailingLists(t *testing.T) {
require.NoError(t, err)

protoList.CreatedAt = theList.CreatedAt // ignore this field when comparing.
ensure.DeepEqual(t, theList, protoList)
require.Equal(t, theList, protoList)

_, err = mg.UpdateMailingList(ctx, address, mailgun.MailingList{
Description: "A list whose description changed",
Expand All @@ -147,7 +147,7 @@ func TestMailingLists(t *testing.T) {

newList := protoList
newList.Description = "A list whose description changed"
ensure.DeepEqual(t, theList, newList)
require.Equal(t, theList, newList)
}

func TestListMailingListRegression(t *testing.T) {
Expand Down Expand Up @@ -187,6 +187,6 @@ func TestListMailingListRegression(t *testing.T) {
}
}
}
ensure.DeepEqual(t, found, 1)
require.Equal(t, 1, found)
require.NoError(t, err)
}
Loading

0 comments on commit 2f7fd84

Please sign in to comment.