Asset Compute專案定義了一種模式,用於輕鬆建立及執行Asset Compute背景工作
測試
。
背景工作測試的剖析
Asset Compute Worker的測試會分成多個測試套裝,而每個測試套裝中,都會有一或多個測試案例宣告要測試的條件。
Asset Compute專案中的測試結構如下:
/actions/<worker-name>/index.js
/test/
asset-compute/
<worker-name>/ <--- Test suite for the worker, must match the yaml key for this worker in manifest.yml
<test-case-1>/ <--- Specific test case
file.jpg <--- Input file (ie. `source.path` or `source.url`)
params.json <--- Parameters (ie. `rendition.instructions`)
rendition.png <--- Expected output file (ie. `rendition.path`)
<test-case-2>/ <--- Another specific test case for this worker
首先,刪除位於/test/asset-compute/simple-worker
的自動產生simple-worker
測試案例,因為這是無效的,因為我們的背景工作不再只是將來源複製到轉譯。
在/test/asset-compute/worker/success-parameterized
建立新的測試案例資料夾,以測試產生PNG轉譯的背景工作程式是否成功執行。
在success-parameterized
資料夾中,新增此測試案例的測試輸入檔案,並將其命名為file.jpg
。
在success-parameterized
資料夾中,新增名稱為params.json
的新檔案,以定義背景工作程式的輸入引數:
code language-json
在error-contrast
資料夾中,新增此測試案例的測試輸入檔案,並將其命名為file.jpg
。 此檔案的內容對此測試而言並不重要,它只是需要存在才能通過「損毀來源」檢查,以達成此測試案例驗證的rendition.instructions
有效性檢查。
在error-contrast
資料夾中,新增名稱為params.json
的新檔案,以定義具有下列內容之背景工作程式的輸入引數:
code language-json