Disable unavailable subreddits after Reddit 404
This commit is contained in:
1 parent
664aa5c098
commit
dcf57273e2
13 files changed
+153
-12
No files matched your search
@@ -480,14 +480,29 @@ describe('RedditApiClient', () => {
|
||||
});
|
||||
|
||||
describe('getNewPosts', () => {
|
||||
it('returns empty array for 404 subreddit', async () => {
|
||||
it('throws a permanent-disable signal for a plain 404 subreddit', async () => {
|
||||
const error = { isAxiosError: true, response: { status: 404 } };
|
||||
const mockAxios = { get: vi.fn().mockRejectedValue(error) };
|
||||
vi.mocked(axios.create).mockReturnValue(mockAxios as any);
|
||||
|
||||
const client2 = new RedditApiClient(getTestConfig(), logger);
|
||||
const result = await client2.getNewPosts('nonexistent');
|
||||
expect(result).toEqual([]);
|
||||
await expect(client2.getNewPosts('nonexistent')).rejects.toMatchObject({
|
||||
name: 'RedditSubredditUnavailableError', subreddit: 'nonexistent',
|
||||
});
|
||||
});
|
||||
|
||||
it('throws the same permanent-disable signal for Reddit banned responses', async () => {
|
||||
const error = {
|
||||
isAxiosError: true,
|
||||
response: { status: 404, data: { reason: 'banned', message: 'Not Found', error: 404 } },
|
||||
};
|
||||
const mockAxios = { get: vi.fn().mockRejectedValue(error) };
|
||||
vi.mocked(axios.create).mockReturnValue(mockAxios as unknown as AxiosInstance);
|
||||
|
||||
const client2 = new RedditApiClient(getTestConfig(), logger);
|
||||
await expect(client2.getNewPosts('banned-sub')).rejects.toMatchObject({
|
||||
name: 'RedditSubredditUnavailableError', subreddit: 'banned-sub',
|
||||
});
|
||||
});
|
||||
|
||||
it('returns empty array and explains an initial 403 access denial', async () => {
|
||||
|
||||
Reference in new issue
Block a user