| 1 | package discord_testscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/testing/integration/discord_test`/ |
| 2 | |
| 3 | import ( |
| 4 | "errorsscip-go gomod github.com/golang/go/src . errors/" |
| 5 | "netscip-go gomod github.com/golang/go/src . net/" |
| 6 | "net/httpscip-go gomod github.com/golang/go/src . `net/http`/" |
| 7 | "net/urlscip-go gomod github.com/golang/go/src . `net/url`/" |
| 8 | "testingscip-go gomod github.com/golang/go/src . testing/" |
| 9 | "testing/synctestscip-go gomod github.com/golang/go/src . `testing/synctest`/" |
| 10 | "timescip-go gomod github.com/golang/go/src . time/" |
| 11 | |
| 12 | "github.com/stretchr/testify/assertscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/assert`/" |
| 13 | "github.com/stretchr/testify/mockscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/mock`/" |
| 14 | "github.com/stretchr/testify/requirescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/" |
| 15 | |
| 16 | "github.com/nicholas-fedor/shoutrrr/pkg/services/chat/discordscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/chat/discord`/" |
| 17 | "github.com/nicholas-fedor/shoutrrr/pkg/typesscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/types`/" |
| 18 | ) |
| 19 | |
| 20 | // noOpSleeper is a sleeper that does nothing, for testing. |
| 21 | type noOpSleeperscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/testing/integration/discord_test`/noOpSleeper# struct{} |
| 22 | |
| 23 | type timeoutErrorscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/testing/integration/discord_test`/timeoutError# struct{} |
| 24 | |
| 25 | var _ netscip-go gomod github.com/golang/go/src . net/.Errorscip-go gomod github.com/golang/go/src . net/Error# = timeoutErrorscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/testing/integration/discord_test`/timeoutError#{} |
| 26 | |
| 27 | func (noOpSleeperscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/testing/integration/discord_test`/noOpSleeper#) Sleepscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/testing/integration/discord_test`/noOpSleeper#Sleep().(_ timescip-go gomod github.com/golang/go/src . time/.Durationscip-go gomod github.com/golang/go/src . time/Duration#) {} |
| 28 | |
| 29 | func (timeoutErrorscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/testing/integration/discord_test`/timeoutError#) Errorscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/testing/integration/discord_test`/timeoutError#Error().() string { return "timeout" } |
| 30 | func (timeoutErrorscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/testing/integration/discord_test`/timeoutError#) Temporaryscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/testing/integration/discord_test`/timeoutError#Temporary().() bool { return false } |
| 31 | func (timeoutErrorscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/testing/integration/discord_test`/timeoutError#) Timeoutscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/testing/integration/discord_test`/timeoutError#Timeout().() bool { return true } |
| 32 | |
| 33 | // computeExpectedBatches computes the number of batches for a message based on Discord limits. |
| 34 | func computeExpectedBatchesscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/testing/integration/discord_test`/computeExpectedBatches().(message string, splitLines bool) int { |
| 35 | const ( |
| 36 | chunkSize = 2000 |
| 37 | totalChunkSize = 6000 |
| 38 | ) |
| 39 | |
| 40 | if splitLines { |
| 41 | // For split lines, each line is a separate item, but simplified for test |
| 42 | return 1 |
| 43 | } |
| 44 | |
| 45 | messageLen := len(message) |
| 46 | if messageLen == 0 { |
| 47 | return 0 |
| 48 | } |
| 49 | |
| 50 | chunks := (messageLen + chunkSize - 1) / chunkSize // Ceiling division |
| 51 | batches := (chunks + (totalChunkSize / chunkSize) - 1) / (totalChunkSize / chunkSize) // Ceiling division |
| 52 | |
| 53 | return batches |
| 54 | } |
| 55 | |
| 56 | func TestSendWithHTTPErrorscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/testing/integration/discord_test`/TestSendWithHTTPError().(t *testingscip-go gomod github.com/golang/go/src . testing/.Tscip-go gomod github.com/golang/go/src . testing/T#) { |
| 57 | t.Parallelscip-go gomod github.com/golang/go/src . testing/T#Parallel().() |
| 58 | synctestscip-go gomod github.com/golang/go/src . `testing/synctest`/.Testscip-go gomod github.com/golang/go/src . `testing/synctest`/Test().(t, func(t *testingscip-go gomod github.com/golang/go/src . testing/.Tscip-go gomod github.com/golang/go/src . testing/T#) { |
| 59 | tests := []struct { |
| 60 | name string |
| 61 | statusCode int |
| 62 | response string |
| 63 | expectedError string |
| 64 | expectedCalls int |
| 65 | expectedHeaders map[string]string |
| 66 | }{ |
| 67 | { |
| 68 | "bad request", |
| 69 | httpscip-go gomod github.com/golang/go/src . `net/http`/.StatusBadRequestscip-go gomod github.com/golang/go/src . `net/http`/StatusBadRequest., |
| 70 | `{"message": "Invalid webhook"}`, |
| 71 | "failed to send discord notification", |
| 72 | 1, |
| 73 | nil, |
| 74 | }, |
| 75 | { |
| 76 | "unauthorized", |
| 77 | httpscip-go gomod github.com/golang/go/src . `net/http`/.StatusUnauthorizedscip-go gomod github.com/golang/go/src . `net/http`/StatusUnauthorized., |
| 78 | `{"message": "Invalid token"}`, |
| 79 | "failed to send discord notification", |
| 80 | 1, |
| 81 | nil, |
| 82 | }, |
| 83 | { |
| 84 | "forbidden", |
| 85 | httpscip-go gomod github.com/golang/go/src . `net/http`/.StatusForbiddenscip-go gomod github.com/golang/go/src . `net/http`/StatusForbidden., |
| 86 | `{"message": "Missing permissions"}`, |
| 87 | "failed to send discord notification", |
| 88 | 1, |
| 89 | nil, |
| 90 | }, |
| 91 | { |
| 92 | "not found", |
| 93 | httpscip-go gomod github.com/golang/go/src . `net/http`/.StatusNotFoundscip-go gomod github.com/golang/go/src . `net/http`/StatusNotFound., |
| 94 | `{"message": "Webhook not found"}`, |
| 95 | "failed to send discord notification", |
| 96 | 1, |
| 97 | nil, |
| 98 | }, |
| 99 | { |
| 100 | "too many requests", |
| 101 | httpscip-go gomod github.com/golang/go/src . `net/http`/.StatusTooManyRequestsscip-go gomod github.com/golang/go/src . `net/http`/StatusTooManyRequests., |
| 102 | `{"message": "Rate limited"}`, |
| 103 | "failed to send discord notification", |
| 104 | 6, |
| 105 | map[string]string{"Retry-After": "0"}, |
| 106 | }, |
| 107 | { |
| 108 | "internal server error", |
| 109 | httpscip-go gomod github.com/golang/go/src . `net/http`/.StatusInternalServerErrorscip-go gomod github.com/golang/go/src . `net/http`/StatusInternalServerError., |
| 110 | `{"message": "Server error"}`, |
| 111 | "failed to send discord notification", |
| 112 | 6, |
| 113 | nil, |
| 114 | }, |
| 115 | } |
| 116 | |
| 117 | for _, tt := range tests { |
| 118 | t.Logfscip-go gomod github.com/golang/go/src . testing/common#Logf().("Running test case: %s", tt.name) |
| 119 | |
| 120 | mockClient := &MockHTTPClientscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/testing/integration/discord_test`/MockHTTPClient#{} |
| 121 | service := createTestServicescip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/testing/integration/discord_test`/createTestService().( |
| 122 | t, |
| 123 | "discord://test-token@test-webhook", |
| 124 | mockClient, |
| 125 | ) |
| 126 | |
| 127 | // Use noOpSleeper to avoid real sleeps in tests |
| 128 | service.Sleeperscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/chat/discord`/Service#Sleeper. = &noOpSleeperscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/testing/integration/discord_test`/noOpSleeper#{} |
| 129 | |
| 130 | resp := createMockResponsescip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/testing/integration/discord_test`/createMockResponse().(tt.statusCode, tt.response, tt.expectedHeaders) |
| 131 | |
| 132 | mockClient.Onscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/mock`/Mock#On().("Do", mockscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/mock`/.Anythingscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/mock`/Anything.). |
| 133 | Returnscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/mock`/Call#Return().(resp, nil). |
| 134 | Timesscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/mock`/Call#Times().(tt.expectedCalls) |
| 135 | |
| 136 | err := service.Sendscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/chat/discord`/Service#Send().("Test message", nil) |
| 137 | |
| 138 | requirescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/.Errorscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/Error().(t, err) |
| 139 | assertscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/assert`/.Containsscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/assert`/Contains().(t, err.Error(), tt.expectedError) |
| 140 | mockClient.AssertExpectationsscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/mock`/Mock#AssertExpectations().(t) |
| 141 | } |
| 142 | }) |
| 143 | } |
| 144 | |
| 145 | func TestSendWithNetworkErrorscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/testing/integration/discord_test`/TestSendWithNetworkError().(t *testingscip-go gomod github.com/golang/go/src . testing/.Tscip-go gomod github.com/golang/go/src . testing/T#) { |
| 146 | t.Parallelscip-go gomod github.com/golang/go/src . testing/T#Parallel().() |
| 147 | synctestscip-go gomod github.com/golang/go/src . `testing/synctest`/.Testscip-go gomod github.com/golang/go/src . `testing/synctest`/Test().(t, func(t *testingscip-go gomod github.com/golang/go/src . testing/.Tscip-go gomod github.com/golang/go/src . testing/T#) { |
| 148 | mockClient := &MockHTTPClientscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/testing/integration/discord_test`/MockHTTPClient#{} |
| 149 | service := createTestServicescip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/testing/integration/discord_test`/createTestService().( |
| 150 | t, |
| 151 | "discord://test-token@test-webhook", |
| 152 | mockClient, |
| 153 | ) |
| 154 | |
| 155 | // Generic errors are not retried; only transient errors (net.Error with Timeout()/Temporary()) trigger retry logic. |
| 156 | networkError := errorsscip-go gomod github.com/golang/go/src . errors/.Newscip-go gomod github.com/golang/go/src . errors/New().("network connection failed") |
| 157 | mockClient.Onscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/mock`/Mock#On().("Do", mockscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/mock`/.Anythingscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/mock`/Anything.).Returnscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/mock`/Call#Return().((*httpscip-go gomod github.com/golang/go/src . `net/http`/.Responsescip-go gomod github.com/golang/go/src . `net/http`/Response#)(nil), networkError).Oncescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/mock`/Call#Once().() |
| 158 | |
| 159 | err := service.Sendscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/chat/discord`/Service#Send().("Test message", nil) |
| 160 | |
| 161 | requirescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/.Errorscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/Error().(t, err) |
| 162 | assertscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/assert`/.Containsscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/assert`/Contains().(t, err.Error(), "failed to send discord notification") |
| 163 | |
| 164 | mockClient.AssertExpectationsscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/mock`/Mock#AssertExpectations().(t) |
| 165 | }) |
| 166 | } |
| 167 | |
| 168 | func TestSendWithMalformedResponsescip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/testing/integration/discord_test`/TestSendWithMalformedResponse().(t *testingscip-go gomod github.com/golang/go/src . testing/.Tscip-go gomod github.com/golang/go/src . testing/T#) { |
| 169 | t.Parallelscip-go gomod github.com/golang/go/src . testing/T#Parallel().() |
| 170 | synctestscip-go gomod github.com/golang/go/src . `testing/synctest`/.Testscip-go gomod github.com/golang/go/src . `testing/synctest`/Test().(t, func(t *testingscip-go gomod github.com/golang/go/src . testing/.Tscip-go gomod github.com/golang/go/src . testing/T#) { |
| 171 | mockClient := &MockHTTPClientscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/testing/integration/discord_test`/MockHTTPClient#{} |
| 172 | service := createTestServicescip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/testing/integration/discord_test`/createTestService().( |
| 173 | t, |
| 174 | "discord://test-token@test-webhook", |
| 175 | mockClient, |
| 176 | ) |
| 177 | |
| 178 | mockClient.Onscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/mock`/Mock#On().("Do", mockscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/mock`/.Anythingscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/mock`/Anything.). |
| 179 | Returnscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/mock`/Call#Return().(createMockResponsescip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/testing/integration/discord_test`/createMockResponse().(httpscip-go gomod github.com/golang/go/src . `net/http`/.StatusOKscip-go gomod github.com/golang/go/src . `net/http`/StatusOK., "invalid json"), nil). |
| 180 | Oncescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/mock`/Call#Once().() |
| 181 | |
| 182 | err := service.Sendscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/chat/discord`/Service#Send().("Test message", nil) |
| 183 | |
| 184 | // Should still succeed since non-error status codes (2xx) are accepted |
| 185 | requirescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/.NoErrorscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/NoError().(t, err) |
| 186 | |
| 187 | mockClient.AssertExpectationsscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/mock`/Mock#AssertExpectations().(t) |
| 188 | }) |
| 189 | } |
| 190 | |
| 191 | func TestSendWithRetryOnRateLimitscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/testing/integration/discord_test`/TestSendWithRetryOnRateLimit().(t *testingscip-go gomod github.com/golang/go/src . testing/.Tscip-go gomod github.com/golang/go/src . testing/T#) { |
| 192 | t.Parallelscip-go gomod github.com/golang/go/src . testing/T#Parallel().() |
| 193 | synctestscip-go gomod github.com/golang/go/src . `testing/synctest`/.Testscip-go gomod github.com/golang/go/src . `testing/synctest`/Test().(t, func(t *testingscip-go gomod github.com/golang/go/src . testing/.Tscip-go gomod github.com/golang/go/src . testing/T#) { |
| 194 | mockClient := &MockHTTPClientscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/testing/integration/discord_test`/MockHTTPClient#{} |
| 195 | service := createTestServicescip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/testing/integration/discord_test`/createTestService().( |
| 196 | t, |
| 197 | "discord://test-token@test-webhook", |
| 198 | mockClient, |
| 199 | ) |
| 200 | |
| 201 | // Use noOpSleeper to avoid real sleeps in tests |
| 202 | service.Sleeperscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/chat/discord`/Service#Sleeper. = &noOpSleeperscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/testing/integration/discord_test`/noOpSleeper#{} |
| 203 | |
| 204 | // First call returns rate limit, second succeeds |
| 205 | mockClient.Onscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/mock`/Mock#On().("Do", mockscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/mock`/.Anythingscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/mock`/Anything.). |
| 206 | Returnscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/mock`/Call#Return().(createMockResponsescip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/testing/integration/discord_test`/createMockResponse().(httpscip-go gomod github.com/golang/go/src . `net/http`/.StatusTooManyRequestsscip-go gomod github.com/golang/go/src . `net/http`/StatusTooManyRequests., `{"retry_after": 1}`), nil). |
| 207 | Oncescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/mock`/Call#Once().() |
| 208 | mockClient.Onscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/mock`/Mock#On().("Do", mockscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/mock`/.Anythingscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/mock`/Anything.). |
| 209 | Returnscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/mock`/Call#Return().(createMockResponsescip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/testing/integration/discord_test`/createMockResponse().(httpscip-go gomod github.com/golang/go/src . `net/http`/.StatusNoContentscip-go gomod github.com/golang/go/src . `net/http`/StatusNoContent., ""), nil). |
| 210 | Oncescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/mock`/Call#Once().() |
| 211 | |
| 212 | err := service.Sendscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/chat/discord`/Service#Send().("Test message", nil) |
| 213 | |
| 214 | requirescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/.NoErrorscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/NoError().(t, err) |
| 215 | mockClient.AssertNumberOfCallsscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/mock`/Mock#AssertNumberOfCalls().(t, "Do", 2) |
| 216 | |
| 217 | mockClient.AssertExpectationsscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/mock`/Mock#AssertExpectations().(t) |
| 218 | }) |
| 219 | } |
| 220 | |
| 221 | func TestSendWithNonExistentWebhookscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/testing/integration/discord_test`/TestSendWithNonExistentWebhook().(t *testingscip-go gomod github.com/golang/go/src . testing/.Tscip-go gomod github.com/golang/go/src . testing/T#) { |
| 222 | t.Parallelscip-go gomod github.com/golang/go/src . testing/T#Parallel().() |
| 223 | synctestscip-go gomod github.com/golang/go/src . `testing/synctest`/.Testscip-go gomod github.com/golang/go/src . `testing/synctest`/Test().(t, func(t *testingscip-go gomod github.com/golang/go/src . testing/.Tscip-go gomod github.com/golang/go/src . testing/T#) { |
| 224 | mockClient := &MockHTTPClientscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/testing/integration/discord_test`/MockHTTPClient#{} |
| 225 | invalidService := createTestServicescip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/testing/integration/discord_test`/createTestService().(t, "discord://token@invalid", mockClient) |
| 226 | |
| 227 | mockClient.Onscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/mock`/Mock#On().("Do", mockscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/mock`/.Anythingscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/mock`/Anything.). |
| 228 | Returnscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/mock`/Call#Return().(createMockResponsescip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/testing/integration/discord_test`/createMockResponse().(httpscip-go gomod github.com/golang/go/src . `net/http`/.StatusNotFoundscip-go gomod github.com/golang/go/src . `net/http`/StatusNotFound., `{"message": "Unknown Webhook"}`), nil). |
| 229 | Oncescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/mock`/Call#Once().() |
| 230 | |
| 231 | err := invalidService.Sendscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/chat/discord`/Service#Send().("Test message", nil) |
| 232 | |
| 233 | requirescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/.Errorscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/Error().(t, err) |
| 234 | assertscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/assert`/.Containsscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/assert`/Contains().(t, err.Error(), "failed to send discord notification") |
| 235 | |
| 236 | mockClient.AssertExpectationsscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/mock`/Mock#AssertExpectations().(t) |
| 237 | }) |
| 238 | } |
| 239 | |
| 240 | func TestSendWithUnknownWebhookscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/testing/integration/discord_test`/TestSendWithUnknownWebhook().(t *testingscip-go gomod github.com/golang/go/src . testing/.Tscip-go gomod github.com/golang/go/src . testing/T#) { |
| 241 | t.Parallelscip-go gomod github.com/golang/go/src . testing/T#Parallel().() |
| 242 | synctestscip-go gomod github.com/golang/go/src . `testing/synctest`/.Testscip-go gomod github.com/golang/go/src . `testing/synctest`/Test().(t, func(t *testingscip-go gomod github.com/golang/go/src . testing/.Tscip-go gomod github.com/golang/go/src . testing/T#) { |
| 243 | mockClient := &MockHTTPClientscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/testing/integration/discord_test`/MockHTTPClient#{} |
| 244 | emptyService := createTestServicescip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/testing/integration/discord_test`/createTestService().(t, "discord://token@empty", mockClient) |
| 245 | |
| 246 | mockClient.Onscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/mock`/Mock#On().("Do", mockscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/mock`/.Anythingscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/mock`/Anything.). |
| 247 | Returnscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/mock`/Call#Return().(createMockResponsescip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/testing/integration/discord_test`/createMockResponse().(httpscip-go gomod github.com/golang/go/src . `net/http`/.StatusNotFoundscip-go gomod github.com/golang/go/src . `net/http`/StatusNotFound., `{"message": "Unknown Webhook"}`), nil). |
| 248 | Oncescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/mock`/Call#Once().() |
| 249 | |
| 250 | err := emptyService.Sendscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/chat/discord`/Service#Send().("Test message", nil) |
| 251 | |
| 252 | requirescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/.Errorscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/Error().(t, err) |
| 253 | assertscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/assert`/.Containsscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/assert`/Contains().(t, err.Error(), "failed to send discord notification") |
| 254 | |
| 255 | mockClient.AssertExpectationsscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/mock`/Mock#AssertExpectations().(t) |
| 256 | }) |
| 257 | } |
| 258 | |
| 259 | func TestSendWithInvalidSchemescip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/testing/integration/discord_test`/TestSendWithInvalidScheme().(t *testingscip-go gomod github.com/golang/go/src . testing/.Tscip-go gomod github.com/golang/go/src . testing/T#) { |
| 260 | t.Parallelscip-go gomod github.com/golang/go/src . testing/T#Parallel().() |
| 261 | synctestscip-go gomod github.com/golang/go/src . `testing/synctest`/.Testscip-go gomod github.com/golang/go/src . `testing/synctest`/Test().(t, func(t *testingscip-go gomod github.com/golang/go/src . testing/.Tscip-go gomod github.com/golang/go/src . testing/T#) { |
| 262 | service := &discordscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/chat/discord`/.Servicescip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/chat/discord`/Service#{} |
| 263 | |
| 264 | parsedURL, _ := urlscip-go gomod github.com/golang/go/src . `net/url`/.Parsescip-go gomod github.com/golang/go/src . `net/url`/Parse().("http://discord.com/api/webhooks/test/test") |
| 265 | |
| 266 | err := service.Initializescip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/chat/discord`/Service#Initialize().(parsedURL, &mockLoggerscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/testing/integration/discord_test`/mockLogger#{}) |
| 267 | |
| 268 | requirescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/.Errorscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/Error().(t, err) |
| 269 | assertscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/assert`/.Containsscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/assert`/Contains().(t, err.Error(), "setting config URL: illegal argument in config URL") |
| 270 | }) |
| 271 | } |
| 272 | |
| 273 | func TestSendWithInvalidHostscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/testing/integration/discord_test`/TestSendWithInvalidHost().(t *testingscip-go gomod github.com/golang/go/src . testing/.Tscip-go gomod github.com/golang/go/src . testing/T#) { |
| 274 | t.Parallelscip-go gomod github.com/golang/go/src . testing/T#Parallel().() |
| 275 | synctestscip-go gomod github.com/golang/go/src . `testing/synctest`/.Testscip-go gomod github.com/golang/go/src . `testing/synctest`/Test().(t, func(t *testingscip-go gomod github.com/golang/go/src . testing/.Tscip-go gomod github.com/golang/go/src . testing/T#) { |
| 276 | service := &discordscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/chat/discord`/.Servicescip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/chat/discord`/Service#{} |
| 277 | |
| 278 | parsedURL, _ := urlscip-go gomod github.com/golang/go/src . `net/url`/.Parsescip-go gomod github.com/golang/go/src . `net/url`/Parse().("discord://[email protected]/webhook") |
| 279 | |
| 280 | err := service.Initializescip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/chat/discord`/Service#Initialize().(parsedURL, &mockLoggerscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/testing/integration/discord_test`/mockLogger#{}) |
| 281 | |
| 282 | requirescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/.Errorscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/Error().(t, err) |
| 283 | assertscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/assert`/.Containsscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/assert`/Contains().(t, err.Error(), "setting config URL: illegal argument in config URL") |
| 284 | }) |
| 285 | } |
| 286 | |
| 287 | func TestSendWithInvalidPathscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/testing/integration/discord_test`/TestSendWithInvalidPath().(t *testingscip-go gomod github.com/golang/go/src . testing/.Tscip-go gomod github.com/golang/go/src . testing/T#) { |
| 288 | t.Parallelscip-go gomod github.com/golang/go/src . testing/T#Parallel().() |
| 289 | synctestscip-go gomod github.com/golang/go/src . `testing/synctest`/.Testscip-go gomod github.com/golang/go/src . `testing/synctest`/Test().(t, func(t *testingscip-go gomod github.com/golang/go/src . testing/.Tscip-go gomod github.com/golang/go/src . testing/T#) { |
| 290 | service := &discordscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/chat/discord`/.Servicescip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/chat/discord`/Service#{} |
| 291 | |
| 292 | parsedURL, _ := urlscip-go gomod github.com/golang/go/src . `net/url`/.Parsescip-go gomod github.com/golang/go/src . `net/url`/Parse().("discord://token@webhook/invalid/path") |
| 293 | |
| 294 | err := service.Initializescip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/chat/discord`/Service#Initialize().(parsedURL, &mockLoggerscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/testing/integration/discord_test`/mockLogger#{}) |
| 295 | |
| 296 | requirescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/.Errorscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/Error().(t, err) |
| 297 | assertscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/assert`/.Containsscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/assert`/Contains().(t, err.Error(), "setting config URL: illegal argument in config URL") |
| 298 | }) |
| 299 | } |
| 300 | |
| 301 | func TestSendItemsWithInvalidPayloadscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/testing/integration/discord_test`/TestSendItemsWithInvalidPayload().(t *testingscip-go gomod github.com/golang/go/src . testing/.Tscip-go gomod github.com/golang/go/src . testing/T#) { |
| 302 | t.Parallelscip-go gomod github.com/golang/go/src . testing/T#Parallel().() |
| 303 | synctestscip-go gomod github.com/golang/go/src . `testing/synctest`/.Testscip-go gomod github.com/golang/go/src . `testing/synctest`/Test().(t, func(t *testingscip-go gomod github.com/golang/go/src . testing/.Tscip-go gomod github.com/golang/go/src . testing/T#) { |
| 304 | mockClient := &MockHTTPClientscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/testing/integration/discord_test`/MockHTTPClient#{} |
| 305 | service := createTestServicescip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/testing/integration/discord_test`/createTestService().( |
| 306 | t, |
| 307 | "discord://test-token@test-webhook", |
| 308 | mockClient, |
| 309 | ) |
| 310 | |
| 311 | // Create an item with invalid UTF-8 that gets sent as invalid JSON |
| 312 | items := []typesscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/types`/.MessageItemscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/types`/MessageItem#{ |
| 313 | { |
| 314 | Textscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/types`/MessageItem#Text.: string([]byte{0xff, 0xfe, 0xfd}), // Invalid UTF-8 bytes |
| 315 | }, |
| 316 | } |
| 317 | |
| 318 | mockClient.Onscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/mock`/Mock#On().("Do", mockscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/mock`/.Anythingscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/mock`/Anything.). |
| 319 | Returnscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/mock`/Call#Return().(createMockResponsescip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/testing/integration/discord_test`/createMockResponse().(httpscip-go gomod github.com/golang/go/src . `net/http`/.StatusBadRequestscip-go gomod github.com/golang/go/src . `net/http`/StatusBadRequest., `{"message": "Invalid JSON"}`), nil). |
| 320 | Oncescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/mock`/Call#Once().() |
| 321 | |
| 322 | err := service.SendItemsscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/chat/discord`/Service#SendItems().(items, nil) |
| 323 | |
| 324 | // Should fail due to invalid JSON payload |
| 325 | requirescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/.Errorscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/Error().(t, err) |
| 326 | assertscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/assert`/.Containsscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/assert`/Contains().(t, err.Error(), "unexpected response status code") |
| 327 | |
| 328 | mockClient.AssertExpectationsscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/mock`/Mock#AssertExpectations().(t) |
| 329 | }) |
| 330 | } |
| 331 | |
| 332 | func TestSendWithTimeoutscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/testing/integration/discord_test`/TestSendWithTimeout().(t *testingscip-go gomod github.com/golang/go/src . testing/.Tscip-go gomod github.com/golang/go/src . testing/T#) { |
| 333 | t.Parallelscip-go gomod github.com/golang/go/src . testing/T#Parallel().() |
| 334 | synctestscip-go gomod github.com/golang/go/src . `testing/synctest`/.Testscip-go gomod github.com/golang/go/src . `testing/synctest`/Test().(t, func(t *testingscip-go gomod github.com/golang/go/src . testing/.Tscip-go gomod github.com/golang/go/src . testing/T#) { |
| 335 | mockClient := &MockHTTPClientscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/testing/integration/discord_test`/MockHTTPClient#{} |
| 336 | service := createTestServicescip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/testing/integration/discord_test`/createTestService().( |
| 337 | t, |
| 338 | "discord://test-token@test-webhook", |
| 339 | mockClient, |
| 340 | ) |
| 341 | |
| 342 | // Use noOpSleeper to avoid real sleeps in tests |
| 343 | service.Sleeperscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/chat/discord`/Service#Sleeper. = &noOpSleeperscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/testing/integration/discord_test`/noOpSleeper#{} |
| 344 | |
| 345 | // Simulate a network timeout by returning a timeout error |
| 346 | // Timeout errors are transient and will be retried up to maxTransportRetries (3) times |
| 347 | mockClient.Onscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/mock`/Mock#On().("Do", mockscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/mock`/.Anythingscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/mock`/Anything.). |
| 348 | Returnscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/mock`/Call#Return().(nil, timeoutErrorscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/testing/integration/discord_test`/timeoutError#{}). |
| 349 | Timesscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/mock`/Call#Times().(4) // Initial attempt + 3 retries |
| 350 | |
| 351 | err := service.Sendscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/chat/discord`/Service#Send().("Test message", nil) |
| 352 | |
| 353 | requirescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/.Errorscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/Error().(t, err) |
| 354 | assertscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/assert`/.Containsscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/assert`/Contains().(t, err.Error(), "failed to send discord notification") |
| 355 | |
| 356 | mockClient.AssertExpectationsscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/mock`/Mock#AssertExpectations().(t) |
| 357 | }) |
| 358 | } |
| 359 | |
| 360 | func TestSendWithLargePayloadscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/testing/integration/discord_test`/TestSendWithLargePayload().(t *testingscip-go gomod github.com/golang/go/src . testing/.Tscip-go gomod github.com/golang/go/src . testing/T#) { |
| 361 | t.Parallelscip-go gomod github.com/golang/go/src . testing/T#Parallel().() |
| 362 | synctestscip-go gomod github.com/golang/go/src . `testing/synctest`/.Testscip-go gomod github.com/golang/go/src . `testing/synctest`/Test().(t, func(t *testingscip-go gomod github.com/golang/go/src . testing/.Tscip-go gomod github.com/golang/go/src . testing/T#) { |
| 363 | mockClient := &MockHTTPClientscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/testing/integration/discord_test`/MockHTTPClient#{} |
| 364 | service := createTestServicescip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/testing/integration/discord_test`/createTestService().( |
| 365 | t, |
| 366 | "discord://test-token@test-webhook?splitLines=false", |
| 367 | mockClient, |
| 368 | ) |
| 369 | |
| 370 | // Create a very large message that might cause issues |
| 371 | largeMessage := make([]byte, 1000000) // 1MB |
| 372 | for i := range largeMessage { |
| 373 | largeMessage[i] = 'a' |
| 374 | } |
| 375 | |
| 376 | // Compute expected number of calls based on message splitting logic |
| 377 | expectedCalls := computeExpectedBatchesscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/testing/integration/discord_test`/computeExpectedBatches().(string(largeMessage), false) |
| 378 | |
| 379 | mockClient.Onscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/mock`/Mock#On().("Do", mockscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/mock`/.Anythingscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/mock`/Anything.). |
| 380 | Returnscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/mock`/Call#Return().(createMockResponsescip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/testing/integration/discord_test`/createMockResponse().(httpscip-go gomod github.com/golang/go/src . `net/http`/.StatusNoContentscip-go gomod github.com/golang/go/src . `net/http`/StatusNoContent., ""), nil). |
| 381 | Timesscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/mock`/Call#Times().(expectedCalls) |
| 382 | |
| 383 | err := service.Sendscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/chat/discord`/Service#Send().(string(largeMessage), nil) |
| 384 | |
| 385 | requirescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/.NoErrorscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/NoError().(t, err) |
| 386 | |
| 387 | mockClient.AssertExpectationsscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/mock`/Mock#AssertExpectations().(t) |
| 388 | }) |
| 389 | } |
| 390 | |
| 391 | func TestSendWithInvalidJSONModescip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/testing/integration/discord_test`/TestSendWithInvalidJSONMode().(t *testingscip-go gomod github.com/golang/go/src . testing/.Tscip-go gomod github.com/golang/go/src . testing/T#) { |
| 392 | t.Parallelscip-go gomod github.com/golang/go/src . testing/T#Parallel().() |
| 393 | synctestscip-go gomod github.com/golang/go/src . `testing/synctest`/.Testscip-go gomod github.com/golang/go/src . `testing/synctest`/Test().(t, func(t *testingscip-go gomod github.com/golang/go/src . testing/.Tscip-go gomod github.com/golang/go/src . testing/T#) { |
| 394 | mockClient := &MockHTTPClientscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/testing/integration/discord_test`/MockHTTPClient#{} |
| 395 | // Create service with JSON mode |
| 396 | service := createTestServicescip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/testing/integration/discord_test`/createTestService().(t, "discord://test-token@test-webhook?json=true", mockClient) |
| 397 | |
| 398 | // Send invalid JSON |
| 399 | mockClient.Onscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/mock`/Mock#On().("Do", mockscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/mock`/.Anythingscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/mock`/Anything.). |
| 400 | Returnscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/mock`/Call#Return().(createMockResponsescip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/testing/integration/discord_test`/createMockResponse().(httpscip-go gomod github.com/golang/go/src . `net/http`/.StatusNoContentscip-go gomod github.com/golang/go/src . `net/http`/StatusNoContent., ""), nil). |
| 401 | Oncescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/mock`/Call#Once().() |
| 402 | |
| 403 | err := service.Sendscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/chat/discord`/Service#Send().(`{"invalid": json}`, nil) |
| 404 | |
| 405 | requirescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/.NoErrorscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/NoError().(t, err) // Should succeed as it's passed through as raw content |
| 406 | |
| 407 | mockClient.AssertExpectationsscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/mock`/Mock#AssertExpectations().(t) |
| 408 | }) |
| 409 | } |
| 410 | |
| 411 | func TestSendWithFileUploadErrorscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/testing/integration/discord_test`/TestSendWithFileUploadError().(t *testingscip-go gomod github.com/golang/go/src . testing/.Tscip-go gomod github.com/golang/go/src . testing/T#) { |
| 412 | t.Parallelscip-go gomod github.com/golang/go/src . testing/T#Parallel().() |
| 413 | synctestscip-go gomod github.com/golang/go/src . `testing/synctest`/.Testscip-go gomod github.com/golang/go/src . `testing/synctest`/Test().(t, func(t *testingscip-go gomod github.com/golang/go/src . testing/.Tscip-go gomod github.com/golang/go/src . testing/T#) { |
| 414 | mockClient := &MockHTTPClientscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/testing/integration/discord_test`/MockHTTPClient#{} |
| 415 | service := createTestServicescip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/testing/integration/discord_test`/createTestService().( |
| 416 | t, |
| 417 | "discord://test-token@test-webhook", |
| 418 | mockClient, |
| 419 | ) |
| 420 | |
| 421 | mockClient.Onscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/mock`/Mock#On().("Do", mockscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/mock`/.Anythingscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/mock`/Anything.). |
| 422 | Returnscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/mock`/Call#Return().(createMockResponsescip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/testing/integration/discord_test`/createMockResponse().(httpscip-go gomod github.com/golang/go/src . `net/http`/.StatusBadRequestscip-go gomod github.com/golang/go/src . `net/http`/StatusBadRequest., `{"message": "File too large"}`), nil). |
| 423 | Oncescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/mock`/Call#Once().() |
| 424 | |
| 425 | items := []typesscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/types`/.MessageItemscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/types`/MessageItem#{ |
| 426 | createTestMessageItemWithFilescip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/testing/integration/discord_test`/createTestMessageItemWithFile().( |
| 427 | "Test", |
| 428 | "large.txt", |
| 429 | make([]byte, 1024), |
| 430 | ), // 1KB file |
| 431 | } |
| 432 | |
| 433 | err := service.SendItemsscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/chat/discord`/Service#SendItems().(items, nil) |
| 434 | |
| 435 | requirescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/.Errorscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/Error().(t, err) |
| 436 | assertscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/assert`/.Containsscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/assert`/Contains().(t, err.Error(), "unexpected response status code") |
| 437 | |
| 438 | mockClient.AssertExpectationsscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/mock`/Mock#AssertExpectations().(t) |
| 439 | }) |
| 440 | } |