Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ describe("RemoteDataSourceFactory", () => {
jest.clearAllMocks();
factory = new RemoteDataSourceFactory();
});
it("should initialize and return a player", () => {
it("should initialize and return a player with a single remote .mcap file", () => {
const mockArgs = setupArgs({
url: "https://example.com/test.mcap",
});
Expand All @@ -78,7 +78,7 @@ describe("RemoteDataSourceFactory", () => {

expect(WorkerSerializedIterableSource).toHaveBeenCalledWith({
initWorker: expect.any(Function),
initArgs: { urls: ["https://example.com/test.mcap"] },
initArgs: { url: "https://example.com/test.mcap" },
});

expect(IterablePlayer).toHaveBeenCalledWith({
Expand All @@ -93,6 +93,30 @@ describe("RemoteDataSourceFactory", () => {
expect(result).toBe(mockPlayer);
});

it("should initialize and return a player with a single remote .bag file", () => {
const mockArgs = setupArgs({
url: "https://example.com/test.bag",
});

const result = factory.initialize(mockArgs);

expect(WorkerSerializedIterableSource).toHaveBeenCalledWith({
initWorker: expect.any(Function),
initArgs: { url: "https://example.com/test.bag" },
});

expect(IterablePlayer).toHaveBeenCalledWith({
source: mockSource,
name: "https://example.com/test.bag",
metricsCollector: mockArgs.metricsCollector,
urlParams: { urls: ["https://example.com/test.bag"] },
sourceId: "remote-file",
readAheadDuration: { sec: 10, nsec: 0 },
});

expect(result).toBe(mockPlayer);
});

it("should initialize and return a player with multiple files", () => {
const mockArgs = setupArgs({
url: "https://example.com/test1.mcap,https://example.com/test2.mcap",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ class RemoteDataSourceFactory implements IDataSourceFactory {

const initWorker = initWorkers[extension]!;

const source = new WorkerSerializedIterableSource({ initWorker, initArgs: { urls } });
const initArgs = urls.length === 1 ? { url: urls[0] } : { urls };
const source = new WorkerSerializedIterableSource({ initWorker, initArgs });

return new IterablePlayer({
source,
Expand Down
Loading