Skip to content
Closed
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
12 changes: 4 additions & 8 deletions packages/app/src/cli/services/bundle.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ import {writeManifestToBundle, compressBundle, uploadToGCS, BUNDLE_EXCLUSION_PAT
import {AppInterface} from '../models/app/app.js'
import {describe, test, expect, vi} from 'vitest'
import {joinPath} from '@shopify/cli-kit/node/path'
import {inTemporaryDirectory, mkdir, writeFile, readFile, fileSize} from '@shopify/cli-kit/node/fs'
import {inTemporaryDirectory, mkdir, writeFile, readFile} from '@shopify/cli-kit/node/fs'
import {brotliCompress, zip} from '@shopify/cli-kit/node/archiver'
import {AbortError} from '@shopify/cli-kit/node/error'
import {fetch} from '@shopify/cli-kit/node/http'
import {truncate} from 'node:fs/promises'

vi.mock('@shopify/cli-kit/node/archiver', () => {
return {
Expand All @@ -19,11 +20,6 @@ vi.mock('@shopify/cli-kit/node/http', async (importActual) => {
return {...actual, fetch: vi.fn()}
})

vi.mock('@shopify/cli-kit/node/fs', async (importActual) => {
const actual: any = await importActual()
return {...actual, fileSize: vi.fn(actual.fileSize)}
})

describe('writeManifestToBundle', () => {
test('writes manifest.json to the specified directory', async () => {
await inTemporaryDirectory(async (tmpDir) => {
Expand Down Expand Up @@ -227,11 +223,11 @@ describe('uploadToGCS', () => {

test('aborts with a helpful error when the bundle exceeds the 100 MB upload limit', async () => {
await inTemporaryDirectory(async (tmpDir) => {
// Given — mock the reported size so CI doesn't have to allocate 101 MB on disk.
// Given — allocate a 101 MB sparse file so we don't actually use disk space but it reports the right size.
const bundlePath = joinPath(tmpDir, 'huge.zip')
await writeFile(bundlePath, 'placeholder')
const oneHundredOneMb = 101 * 1024 * 1024
vi.mocked(fileSize).mockResolvedValueOnce(oneHundredOneMb).mockResolvedValueOnce(oneHundredOneMb)
await truncate(bundlePath, oneHundredOneMb)
vi.mocked(fetch).mockResolvedValue({} as never)

// When / Then
Expand Down
Loading