| 1 | package signalgrid_testscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/testing/integration/signalgrid_test`/ |
| 2 | |
| 3 | import ( |
| 4 | "errorsscip-go gomod github.com/golang/go/src . errors/" |
| 5 | "net/httpscip-go gomod github.com/golang/go/src . `net/http`/" |
| 6 | "testingscip-go gomod github.com/golang/go/src . testing/" |
| 7 | "testing/synctestscip-go gomod github.com/golang/go/src . `testing/synctest`/" |
| 8 | |
| 9 | "github.com/stretchr/testify/mockscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/mock`/" |
| 10 | "github.com/stretchr/testify/requirescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/" |
| 11 | ) |
| 12 | |
| 13 | func TestSendWithHTTPErrorscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/testing/integration/signalgrid_test`/TestSendWithHTTPError().(t *testingscip-go gomod github.com/golang/go/src . testing/.Tscip-go gomod github.com/golang/go/src . testing/T#) { |
| 14 | t.Parallelscip-go gomod github.com/golang/go/src . testing/T#Parallel().() |
| 15 | 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#) { |
| 16 | tests := []struct { |
| 17 | name string |
| 18 | statusCode int |
| 19 | response string |
| 20 | }{ |
| 21 | {"bad request", httpscip-go gomod github.com/golang/go/src . `net/http`/.StatusBadRequestscip-go gomod github.com/golang/go/src . `net/http`/StatusBadRequest., "invalid"}, |
| 22 | {"unauthorized", httpscip-go gomod github.com/golang/go/src . `net/http`/.StatusUnauthorizedscip-go gomod github.com/golang/go/src . `net/http`/StatusUnauthorized., "denied"}, |
| 23 | {"forbidden", httpscip-go gomod github.com/golang/go/src . `net/http`/.StatusForbiddenscip-go gomod github.com/golang/go/src . `net/http`/StatusForbidden., "forbidden"}, |
| 24 | {"not found", httpscip-go gomod github.com/golang/go/src . `net/http`/.StatusNotFoundscip-go gomod github.com/golang/go/src . `net/http`/StatusNotFound., "missing"}, |
| 25 | {"internal server error", httpscip-go gomod github.com/golang/go/src . `net/http`/.StatusInternalServerErrorscip-go gomod github.com/golang/go/src . `net/http`/StatusInternalServerError., "boom"}, |
| 26 | } |
| 27 | |
| 28 | for _, tt := range tests { |
| 29 | mockClient := &MockHTTPClientscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/testing/integration/signalgrid_test`/MockHTTPClient#{} |
| 30 | service := createTestServicescip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/testing/integration/signalgrid_test`/createTestService().(t, validSignalgridURLscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/testing/integration/signalgrid_test`/validSignalgridURL., mockClient) |
| 31 | |
| 32 | 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.). |
| 33 | 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/signalgrid_test`/createMockResponse().(tt.statusCode, tt.response), nil). |
| 34 | Oncescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/mock`/Call#Once().() |
| 35 | |
| 36 | err := service.Sendscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/signalgrid`/Service#Send().("Test message", nil) |
| 37 | 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, "Expected error for %s", tt.name) |
| 38 | |
| 39 | mockClient.AssertExpectationsscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/mock`/Mock#AssertExpectations().(t) |
| 40 | } |
| 41 | }) |
| 42 | } |
| 43 | |
| 44 | func TestSendWithNetworkErrorscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/testing/integration/signalgrid_test`/TestSendWithNetworkError().(t *testingscip-go gomod github.com/golang/go/src . testing/.Tscip-go gomod github.com/golang/go/src . testing/T#) { |
| 45 | t.Parallelscip-go gomod github.com/golang/go/src . testing/T#Parallel().() |
| 46 | 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#) { |
| 47 | mockClient := &MockHTTPClientscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/testing/integration/signalgrid_test`/MockHTTPClient#{} |
| 48 | service := createTestServicescip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/testing/integration/signalgrid_test`/createTestService().(t, validSignalgridURLscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/testing/integration/signalgrid_test`/validSignalgridURL., mockClient) |
| 49 | |
| 50 | 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.). |
| 51 | Returnscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/mock`/Call#Return().(nil, errorsscip-go gomod github.com/golang/go/src . errors/.Newscip-go gomod github.com/golang/go/src . errors/New().("connection refused")). |
| 52 | Oncescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/mock`/Call#Once().() |
| 53 | |
| 54 | err := service.Sendscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/push/signalgrid`/Service#Send().("Test message", nil) |
| 55 | 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) |
| 56 | |
| 57 | mockClient.AssertExpectationsscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/mock`/Mock#AssertExpectations().(t) |
| 58 | }) |
| 59 | } |