MCPcopy Index your code
hub / github.com/coder/coder / TestNotifier_FetchLogoURL

Function TestNotifier_FetchLogoURL

coderd/notifications/fetcher_internal_test.go:159–231  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

157}
158
159func TestNotifier_FetchLogoURL(t *testing.T) {
160 t.Parallel()
161
162 t.Run("ok", func(t *testing.T) {
163 t.Parallel()
164
165 ctrl := gomock.NewController(t)
166 dbmock := dbmock.NewMockStore(ctrl)
167
168 n := &notifier{
169 store: dbmock,
170 }
171
172 dbmock.EXPECT().GetLogoURL(gomock.Any()).Return("https://example.com/logo.png", nil)
173
174 ctx := context.Background()
175 logoURL, err := n.fetchLogoURL(ctx)
176 require.NoError(t, err)
177 require.Equal(t, "https://example.com/logo.png", logoURL)
178 })
179
180 t.Run("No rows", func(t *testing.T) {
181 t.Parallel()
182 ctrl := gomock.NewController(t)
183 dbmock := dbmock.NewMockStore(ctrl)
184
185 n := &notifier{
186 store: dbmock,
187 }
188
189 dbmock.EXPECT().GetLogoURL(gomock.Any()).Return("", sql.ErrNoRows)
190
191 ctx := context.Background()
192 logoURL, err := n.fetchLogoURL(ctx)
193 require.NoError(t, err)
194 require.Equal(t, notificationsDefaultLogoURL, logoURL)
195 })
196
197 t.Run("Empty string", func(t *testing.T) {
198 t.Parallel()
199
200 ctrl := gomock.NewController(t)
201 dbmock := dbmock.NewMockStore(ctrl)
202
203 n := &notifier{
204 store: dbmock,
205 }
206
207 dbmock.EXPECT().GetLogoURL(gomock.Any()).Return("", nil)
208
209 ctx := context.Background()
210 logoURL, err := n.fetchLogoURL(ctx)
211 require.NoError(t, err)
212 require.Equal(t, notificationsDefaultLogoURL, logoURL)
213 })
214
215 t.Run("internal error", func(t *testing.T) {
216 t.Parallel()

Callers

nothing calls this directly

Calls 7

EXPECTMethod · 0.95
fetchLogoURLMethod · 0.95
RunMethod · 0.65
GetLogoURLMethod · 0.65
NewMethod · 0.65
EqualMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected