Skip to content

Commit

Permalink
Fix manifest tests (#58)
Browse files Browse the repository at this point in the history
* both manifests

* fixed manifest.test

* timeout-minutes: 15
  • Loading branch information
andiradulescu authored Sep 11, 2024
1 parent e8a76e9 commit d6c822b
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ concurrency:
jobs:
test:
runs-on: ubuntu-latest
timeout-minutes: 9
timeout-minutes: 15
steps:
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v1
Expand Down
2 changes: 1 addition & 1 deletion src/config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const config = {
manifests: {
release: 'https://raw.githubusercontent.com/commaai/openpilot/release3/system/hardware/tici/agnos.json',
// master: 'https://raw.githubusercontent.com/commaai/openpilot/master/system/hardware/tici/agnos.json',
master: 'https://raw.githubusercontent.com/commaai/openpilot/master/system/hardware/tici/agnos.json',
},
}

Expand Down
37 changes: 19 additions & 18 deletions src/utils/manifest.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,31 +14,14 @@ async function getImageWorker() {
imageWorker.init()
})

vi.resetModules() // this makes the import be reevaluated on each call
await import('./../workers/image.worker')

return imageWorker
}

for (const [branch, manifestUrl] of Object.entries(config.manifests)) {
describe(`${branch} manifest`, async () => {
const imageWorkerFileHandler = {
getFile: vi.fn(),
createWritable: vi.fn().mockImplementation(() => ({
write: vi.fn(),
close: vi.fn(),
})),
}

globalThis.navigator = {
storage: {
getDirectory: () => ({
getFileHandle: () => imageWorkerFileHandler,
})
}
}

const imageWorker = await getImageWorker()

const images = await getManifest(manifestUrl)

// Check all images are present
Expand All @@ -60,13 +43,31 @@ for (const [branch, manifestUrl] of Object.entries(config.manifests)) {
}

test('image and checksum', async () => {
const imageWorkerFileHandler = {
getFile: vi.fn(),
createWritable: vi.fn().mockImplementation(() => ({
write: vi.fn(),
close: vi.fn(),
})),
}

globalThis.navigator = {
storage: {
getDirectory: () => ({
getFileHandle: () => imageWorkerFileHandler,
})
}
}

imageWorkerFileHandler.getFile.mockImplementation(async () => {
const response = await fetch(image.archiveUrl)
expect(response.ok, 'to be uploaded').toBe(true)

return response.blob()
})

const imageWorker = await getImageWorker()

await imageWorker.unpackImage(image)
}, 8 * 60 * 1000)
})
Expand Down

0 comments on commit d6c822b

Please sign in to comment.