mirror of
https://github.com/wkulhanek/bonob.git
synced 2025-12-21 17:33:29 +01:00
Catch unhandled io errors in subsonic (#75)
This commit is contained in:
@@ -2756,11 +2756,15 @@ describe("Subsonic", () => {
|
||||
});
|
||||
|
||||
describe("navidrome returns something other than a 200", () => {
|
||||
it("should return the content", async () => {
|
||||
it("should fail", async () => {
|
||||
const trackId = "track123";
|
||||
|
||||
const streamResponse = {
|
||||
status: 400,
|
||||
headers: {
|
||||
'content-type': 'text/html',
|
||||
'content-length': '33'
|
||||
}
|
||||
};
|
||||
|
||||
mockGET
|
||||
@@ -2783,6 +2787,31 @@ describe("Subsonic", () => {
|
||||
).rejects.toEqual(`Subsonic failed with a 400 status`);
|
||||
});
|
||||
});
|
||||
|
||||
describe("io exception occurs", () => {
|
||||
it("should fail", async () => {
|
||||
const trackId = "track123";
|
||||
|
||||
mockGET
|
||||
.mockImplementationOnce(() => Promise.resolve(ok(PING_OK)))
|
||||
.mockImplementationOnce(() =>
|
||||
Promise.resolve(ok(getSongJson(track)))
|
||||
)
|
||||
.mockImplementationOnce(() =>
|
||||
Promise.resolve(ok(getAlbumJson(artist, album, [])))
|
||||
)
|
||||
.mockImplementationOnce(() => Promise.reject("IO error occured"));
|
||||
|
||||
const musicLibrary = await navidrome
|
||||
.generateToken({ username, password })
|
||||
.then((it) => it as AuthSuccess)
|
||||
.then((it) => navidrome.login(it.authToken));
|
||||
|
||||
return expect(
|
||||
musicLibrary.stream({ trackId, range: undefined })
|
||||
).rejects.toEqual(`Subsonic failed with: IO error occured`);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("with range specified", () => {
|
||||
|
||||
Reference in New Issue
Block a user