| 1 | package zulip_testscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/testing/integration/zulip_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/assertscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/assert`/" |
| 10 | "github.com/stretchr/testify/mockscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/mock`/" |
| 11 | "github.com/stretchr/testify/requirescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/" |
| 12 | |
| 13 | "github.com/nicholas-fedor/shoutrrr/pkg/services/chat/zulipscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/chat/zulip`/" |
| 14 | "github.com/nicholas-fedor/shoutrrr/pkg/services/chat/zulip/mocksscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/chat/zulip/mocks`/" |
| 15 | ) |
| 16 | |
| 17 | func TestServiceSendWithHTTPErrorscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/testing/integration/zulip_test`/TestServiceSendWithHTTPError().(t *testingscip-go gomod github.com/golang/go/src . testing/.Tscip-go gomod github.com/golang/go/src . testing/T#) { |
| 18 | t.Parallelscip-go gomod github.com/golang/go/src . testing/T#Parallel().() |
| 19 | 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#) { |
| 20 | tests := []struct { |
| 21 | name string |
| 22 | statusCode int |
| 23 | body string |
| 24 | }{ |
| 25 | { |
| 26 | name: "bad request", |
| 27 | statusCode: httpscip-go gomod github.com/golang/go/src . `net/http`/.StatusBadRequestscip-go gomod github.com/golang/go/src . `net/http`/StatusBadRequest., |
| 28 | body: `{"result": "error", "msg": "Invalid request"}`, |
| 29 | }, |
| 30 | { |
| 31 | name: "unauthorized", |
| 32 | statusCode: httpscip-go gomod github.com/golang/go/src . `net/http`/.StatusUnauthorizedscip-go gomod github.com/golang/go/src . `net/http`/StatusUnauthorized., |
| 33 | body: `{"result": "error", "msg": "Invalid API key"}`, |
| 34 | }, |
| 35 | { |
| 36 | name: "forbidden", |
| 37 | statusCode: httpscip-go gomod github.com/golang/go/src . `net/http`/.StatusForbiddenscip-go gomod github.com/golang/go/src . `net/http`/StatusForbidden., |
| 38 | body: `{"result": "error", "msg": "Access denied"}`, |
| 39 | }, |
| 40 | { |
| 41 | name: "not found", |
| 42 | statusCode: httpscip-go gomod github.com/golang/go/src . `net/http`/.StatusNotFoundscip-go gomod github.com/golang/go/src . `net/http`/StatusNotFound., |
| 43 | body: `{"result": "error", "msg": "Not found"}`, |
| 44 | }, |
| 45 | { |
| 46 | name: "server error", |
| 47 | statusCode: httpscip-go gomod github.com/golang/go/src . `net/http`/.StatusInternalServerErrorscip-go gomod github.com/golang/go/src . `net/http`/StatusInternalServerError., |
| 48 | body: `{"result": "error", "msg": "Server error"}`, |
| 49 | }, |
| 50 | { |
| 51 | name: "service unavailable", |
| 52 | statusCode: httpscip-go gomod github.com/golang/go/src . `net/http`/.StatusServiceUnavailablescip-go gomod github.com/golang/go/src . `net/http`/StatusServiceUnavailable., |
| 53 | body: `{"result": "error", "msg": "Service unavailable"}`, |
| 54 | }, |
| 55 | } |
| 56 | |
| 57 | for _, tt := range tests { |
| 58 | mockClient := mocksscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/chat/zulip/mocks`/.NewMockHTTPClientscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/chat/zulip/mocks`/NewMockHTTPClient().(t) |
| 59 | service := createTestServicescip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/testing/integration/zulip_test`/createTestService().( |
| 60 | t, |
| 61 | "zulip://[email protected]:[email protected]?stream=general", |
| 62 | mockClient, |
| 63 | ) |
| 64 | |
| 65 | // each fresh service triggers its own register fetch first |
| 66 | 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`/.AnythingOfTypescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/mock`/AnythingOfType().("*http.Request")). |
| 67 | 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/zulip_test`/createMockResponse().(httpscip-go gomod github.com/golang/go/src . `net/http`/.StatusOKscip-go gomod github.com/golang/go/src . `net/http`/StatusOK., `{"result": "success"}`), nil). |
| 68 | Oncescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/mock`/Call#Once().() |
| 69 | |
| 70 | 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`/.AnythingOfTypescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/mock`/AnythingOfType().("*http.Request")). |
| 71 | 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/zulip_test`/createMockResponse().(tt.statusCode, tt.body), nil). |
| 72 | Oncescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/mock`/Call#Once().() |
| 73 | |
| 74 | err := service.Sendscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/chat/zulip`/Service#Send().("Test message", nil) |
| 75 | |
| 76 | 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 status %d", tt.statusCode) |
| 77 | requirescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/.ErrorIsscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/ErrorIs().(t, err, zulipscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/chat/zulip`/.ErrResponseStatusFailurescip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/chat/zulip`/ErrResponseStatusFailure.) |
| 78 | |
| 79 | mockClient.AssertExpectationsscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/mock`/Mock#AssertExpectations().(t) |
| 80 | } |
| 81 | }) |
| 82 | } |
| 83 | |
| 84 | func TestServiceSendWithNetworkErrorscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/testing/integration/zulip_test`/TestServiceSendWithNetworkError().(t *testingscip-go gomod github.com/golang/go/src . testing/.Tscip-go gomod github.com/golang/go/src . testing/T#) { |
| 85 | t.Parallelscip-go gomod github.com/golang/go/src . testing/T#Parallel().() |
| 86 | 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#) { |
| 87 | mockClient := mocksscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/chat/zulip/mocks`/.NewMockHTTPClientscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/chat/zulip/mocks`/NewMockHTTPClient().(t) |
| 88 | service := createTestServicescip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/testing/integration/zulip_test`/createTestService().( |
| 89 | t, |
| 90 | "zulip://[email protected]:[email protected]?stream=general", |
| 91 | mockClient, |
| 92 | ) |
| 93 | |
| 94 | // register first |
| 95 | 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`/.AnythingOfTypescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/mock`/AnythingOfType().("*http.Request")). |
| 96 | 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/zulip_test`/createMockResponse().(httpscip-go gomod github.com/golang/go/src . `net/http`/.StatusOKscip-go gomod github.com/golang/go/src . `net/http`/StatusOK., `{"result": "success"}`), nil). |
| 97 | Oncescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/mock`/Call#Once().() |
| 98 | |
| 99 | 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`/.AnythingOfTypescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/mock`/AnythingOfType().("*http.Request")). |
| 100 | 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")). |
| 101 | Oncescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/mock`/Call#Once().() |
| 102 | |
| 103 | err := service.Sendscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/chat/zulip`/Service#Send().("Test message", nil) |
| 104 | |
| 105 | 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) |
| 106 | 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(), "making HTTP POST request") |
| 107 | |
| 108 | mockClient.AssertExpectationsscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/mock`/Mock#AssertExpectations().(t) |
| 109 | }) |
| 110 | } |
| 111 | |
| 112 | func TestServiceSendWithTimeoutErrorscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/testing/integration/zulip_test`/TestServiceSendWithTimeoutError().(t *testingscip-go gomod github.com/golang/go/src . testing/.Tscip-go gomod github.com/golang/go/src . testing/T#) { |
| 113 | t.Parallelscip-go gomod github.com/golang/go/src . testing/T#Parallel().() |
| 114 | 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#) { |
| 115 | mockClient := mocksscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/chat/zulip/mocks`/.NewMockHTTPClientscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/chat/zulip/mocks`/NewMockHTTPClient().(t) |
| 116 | service := createTestServicescip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/testing/integration/zulip_test`/createTestService().( |
| 117 | t, |
| 118 | "zulip://[email protected]:[email protected]?stream=general", |
| 119 | mockClient, |
| 120 | ) |
| 121 | |
| 122 | // register |
| 123 | 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`/.AnythingOfTypescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/mock`/AnythingOfType().("*http.Request")). |
| 124 | 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/zulip_test`/createMockResponse().(httpscip-go gomod github.com/golang/go/src . `net/http`/.StatusOKscip-go gomod github.com/golang/go/src . `net/http`/StatusOK., `{"result": "success"}`), nil). |
| 125 | Oncescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/mock`/Call#Once().() |
| 126 | |
| 127 | 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`/.AnythingOfTypescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/mock`/AnythingOfType().("*http.Request")). |
| 128 | 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().("context deadline exceeded")). |
| 129 | Oncescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/mock`/Call#Once().() |
| 130 | |
| 131 | err := service.Sendscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/chat/zulip`/Service#Send().("Test message", nil) |
| 132 | |
| 133 | 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) |
| 134 | |
| 135 | mockClient.AssertExpectationsscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/mock`/Mock#AssertExpectations().(t) |
| 136 | }) |
| 137 | } |
| 138 | |
| 139 | func TestServiceSendWithInvalidHostscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/testing/integration/zulip_test`/TestServiceSendWithInvalidHost().(t *testingscip-go gomod github.com/golang/go/src . testing/.Tscip-go gomod github.com/golang/go/src . testing/T#) { |
| 140 | t.Parallelscip-go gomod github.com/golang/go/src . testing/T#Parallel().() |
| 141 | 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#) { |
| 142 | mockClient := mocksscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/chat/zulip/mocks`/.NewMockHTTPClientscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/chat/zulip/mocks`/NewMockHTTPClient().(t) |
| 143 | service := createTestServicescip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/testing/integration/zulip_test`/createTestService().( |
| 144 | t, |
| 145 | "zulip://[email protected]:[email protected]?stream=general", |
| 146 | mockClient, |
| 147 | ) |
| 148 | |
| 149 | service.Configscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/chat/zulip`/Service#Config..Hostscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/chat/zulip`/Config#Host. = "invalid host with spaces!" |
| 150 | |
| 151 | err := service.Sendscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/chat/zulip`/Service#Send().("Test message", nil) |
| 152 | |
| 153 | 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) |
| 154 | requirescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/.ErrorIsscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/ErrorIs().(t, err, zulipscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/chat/zulip`/.ErrInvalidHostscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/chat/zulip`/ErrInvalidHost.) |
| 155 | // Note: fetch may attempt a register Do with the bad host string (req creation may or may not reach transport); we only care that the final error is InvalidHost. |
| 156 | }) |
| 157 | } |
| 158 | |
| 159 | func TestServiceSendWithEmptyStreamscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/testing/integration/zulip_test`/TestServiceSendWithEmptyStream().(t *testingscip-go gomod github.com/golang/go/src . testing/.Tscip-go gomod github.com/golang/go/src . testing/T#) { |
| 160 | t.Parallelscip-go gomod github.com/golang/go/src . testing/T#Parallel().() |
| 161 | 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#) { |
| 162 | mockClient := mocksscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/chat/zulip/mocks`/.NewMockHTTPClientscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/chat/zulip/mocks`/NewMockHTTPClient().(t) |
| 163 | service := createTestServicescip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/testing/integration/zulip_test`/createTestService().( |
| 164 | t, |
| 165 | "zulip://[email protected]:[email protected]", |
| 166 | mockClient, |
| 167 | ) |
| 168 | |
| 169 | // register fetch happens; channel with no stream now errors before messages call |
| 170 | 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`/.AnythingOfTypescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/mock`/AnythingOfType().("*http.Request")). |
| 171 | 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/zulip_test`/createMockResponse().(httpscip-go gomod github.com/golang/go/src . `net/http`/.StatusOKscip-go gomod github.com/golang/go/src . `net/http`/StatusOK., `{"result": "success"}`), nil). |
| 172 | Oncescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/mock`/Call#Once().() |
| 173 | |
| 174 | err := service.Sendscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/chat/zulip`/Service#Send().("Test message", nil) |
| 175 | |
| 176 | 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) |
| 177 | requirescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/.ErrorIsscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/require`/ErrorIs().(t, err, zulipscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/chat/zulip`/.ErrMissingRecipientscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/chat/zulip`/ErrMissingRecipient.) |
| 178 | |
| 179 | assertNoMessagesAPICallscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/testing/integration/zulip_test`/assertNoMessagesAPICall().(t, mockClient) |
| 180 | }) |
| 181 | } |
| 182 | |
| 183 | func TestServiceSendWithMalformedResponseBodyscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/testing/integration/zulip_test`/TestServiceSendWithMalformedResponseBody().(t *testingscip-go gomod github.com/golang/go/src . testing/.Tscip-go gomod github.com/golang/go/src . testing/T#) { |
| 184 | t.Parallelscip-go gomod github.com/golang/go/src . testing/T#Parallel().() |
| 185 | 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#) { |
| 186 | mockClient := mocksscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/chat/zulip/mocks`/.NewMockHTTPClientscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/chat/zulip/mocks`/NewMockHTTPClient().(t) |
| 187 | service := createTestServicescip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/testing/integration/zulip_test`/createTestService().( |
| 188 | t, |
| 189 | "zulip://[email protected]:[email protected]?stream=general", |
| 190 | mockClient, |
| 191 | ) |
| 192 | |
| 193 | // register with bad body (decode fails -> defaults, still proceeds) |
| 194 | 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`/.AnythingOfTypescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/mock`/AnythingOfType().("*http.Request")). |
| 195 | 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/zulip_test`/createMockResponse().(httpscip-go gomod github.com/golang/go/src . `net/http`/.StatusOKscip-go gomod github.com/golang/go/src . `net/http`/StatusOK., "not valid json"), nil). |
| 196 | Oncescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/mock`/Call#Once().() |
| 197 | |
| 198 | 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`/.AnythingOfTypescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/mock`/AnythingOfType().("*http.Request")). |
| 199 | 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/zulip_test`/createMockResponse().(httpscip-go gomod github.com/golang/go/src . `net/http`/.StatusOKscip-go gomod github.com/golang/go/src . `net/http`/StatusOK., `{"result": "success"}`), nil). |
| 200 | Oncescip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/mock`/Call#Once().() |
| 201 | |
| 202 | err := service.Sendscip-go gomod github.com/nicholas-fedor/shoutrrr . `github.com/nicholas-fedor/shoutrrr/pkg/services/chat/zulip`/Service#Send().("Test message", nil) |
| 203 | |
| 204 | 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) |
| 205 | |
| 206 | mockClient.AssertExpectationsscip-go gomod github.com/stretchr/testify v1.12.1 `github.com/stretchr/testify/mock`/Mock#AssertExpectations().(t) |
| 207 | }) |
| 208 | } |