(t *testing.T)
| 157 | } |
| 158 | |
| 159 | func 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 := ¬ifier{ |
| 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 := ¬ifier{ |
| 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 := ¬ifier{ |
| 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() |
nothing calls this directly
no test coverage detected