Skip to content

Commit

Permalink
fixed integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
vtopc committed Dec 25, 2024
1 parent 33d0d60 commit cdc6ec6
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"context"
"encoding/json"
"net/http"
"os"
"testing"
"time"

Expand Down Expand Up @@ -67,11 +68,14 @@ func TestIntegrationWebhooksCRUD(t *testing.T) {
require.NoError(t, err)
}

domain := os.Getenv("MG_DOMAIN")
require.NotEmpty(t, domain)

const name = "permanent_fail"
ctx := context.Background()
urls := []string{"https://example.com/1", "https://example.com/2"}

err = mg.DeleteWebhook(ctx, name)
err = mg.DeleteWebhook(ctx, domain, name)
if err != nil {
// 200 or 404 is expected
status := mailgun.GetStatusFromErr(err)
Expand All @@ -81,18 +85,18 @@ func TestIntegrationWebhooksCRUD(t *testing.T) {

defer func() {
// Cleanup
_ = mg.DeleteWebhook(ctx, name)
_ = mg.DeleteWebhook(ctx, domain, name)
}()

// Act

err = mg.CreateWebhook(ctx, name, urls)
err = mg.CreateWebhook(ctx, domain, name, urls)
require.NoError(t, err)
time.Sleep(3 * time.Second)

// Assert

gotUrls, err := mg.GetWebhook(ctx, name)
gotUrls, err := mg.GetWebhook(ctx, domain, name)
require.NoError(t, err)
t.Logf("Webhooks: %v", urls)
assert.ElementsMatch(t, urls, gotUrls)
Expand Down

0 comments on commit cdc6ec6

Please sign in to comment.