|
| 1 | +import { existsSync, readFileSync } from 'node:fs'; |
| 2 | +import { join } from 'node:path'; |
| 3 | + |
| 4 | +import { getLocalDatasetPath } from '../../../../../src/lib/utils.js'; |
| 5 | +import { safeLogin, useAuthSetup } from '../../../../__setup__/hooks/useAuthSetup.js'; |
| 6 | +import { useTempPath } from '../../../../__setup__/hooks/useTempPath.js'; |
| 7 | + |
| 8 | +const actorName = 'python-scrapy-template-works'; |
| 9 | + |
| 10 | +const { beforeAllCalls, afterAllCalls, joinPath, toggleCwdBetweenFullAndParentPath } = useTempPath(actorName, { |
| 11 | + create: true, |
| 12 | + remove: true, |
| 13 | + cwd: true, |
| 14 | + cwdParent: true, |
| 15 | +}); |
| 16 | + |
| 17 | +useAuthSetup({ perTest: false }); |
| 18 | + |
| 19 | +const { CreateCommand } = await import('../../../../../src/commands/create.js'); |
| 20 | +const { RunCommand } = await import('../../../../../src/commands/run.js'); |
| 21 | + |
| 22 | +describe('python-scrapy-template-works', () => { |
| 23 | + beforeAll(async () => { |
| 24 | + await beforeAllCalls(); |
| 25 | + |
| 26 | + await safeLogin(); |
| 27 | + |
| 28 | + await CreateCommand.run([actorName, '--template', 'python-scrapy'], import.meta.url); |
| 29 | + toggleCwdBetweenFullAndParentPath(); |
| 30 | + }); |
| 31 | + |
| 32 | + afterAll(async () => { |
| 33 | + await afterAllCalls(); |
| 34 | + }); |
| 35 | + |
| 36 | + it('should run the actor', async () => { |
| 37 | + await RunCommand.run([], import.meta.url); |
| 38 | + |
| 39 | + const datasetDirectory = joinPath(getLocalDatasetPath('default')); |
| 40 | + const datasetMetadataFile = join(datasetDirectory, '__metadata__.json'); |
| 41 | + expect(existsSync(datasetMetadataFile)).toBe(true); |
| 42 | + |
| 43 | + const datasetMetadata = JSON.parse(readFileSync(datasetMetadataFile, 'utf8')); |
| 44 | + expect(datasetMetadata.item_count).toBeGreaterThanOrEqual(4); |
| 45 | + }); |
| 46 | +}); |
0 commit comments