添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

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