|
| 1 | +// Copyright 2025 Google LLC |
| 2 | +// |
| 3 | +// Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +// you may not use this file except in compliance with the License. |
| 5 | +// You may obtain a copy of the License at |
| 6 | +// |
| 7 | +// https://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +// |
| 9 | +// Unless required by applicable law or agreed to in writing, software |
| 10 | +// distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +// See the License for the specific language governing permissions and |
| 13 | +// limitations under the License. |
| 14 | + |
| 15 | +'use strict'; |
| 16 | + |
| 17 | +const {assert} = require('chai'); |
| 18 | +const {describe, it} = require('mocha'); |
| 19 | +const {Storage} = require('@google-cloud/storage'); |
| 20 | + |
| 21 | +const location = process.env.GOOGLE_CLOUD_LOCATION || 'global'; |
| 22 | +const projectId = process.env.CAIP_PROJECT_ID; |
| 23 | +const sample = require('../videogen-with-txt.js'); |
| 24 | +const {delay} = require('../../test/util'); |
| 25 | + |
| 26 | +const storage = new Storage(); |
| 27 | + |
| 28 | +const GCS_OUTPUT_BUCKET = 'nodejs-docs-samples-tests'; |
| 29 | + |
| 30 | +async function gcs_output_uri() { |
| 31 | + const dt = new Date(); |
| 32 | + const prefix = `text_output/${dt.toISOString()}`; |
| 33 | + const fullUri = `gs://${GCS_OUTPUT_BUCKET}/${prefix}`; |
| 34 | + |
| 35 | + return { |
| 36 | + uri: fullUri, |
| 37 | + async cleanup() { |
| 38 | + const [files] = await storage.bucket(GCS_OUTPUT_BUCKET).getFiles({ |
| 39 | + prefix, |
| 40 | + }); |
| 41 | + for (const file of files) { |
| 42 | + await file.delete(); |
| 43 | + } |
| 44 | + }, |
| 45 | + }; |
| 46 | +} |
| 47 | + |
| 48 | +describe('videogen-with-txt', async () => { |
| 49 | + it('should generate video content from a text prompt', async function () { |
| 50 | + this.timeout(180000); |
| 51 | + this.retries(4); |
| 52 | + await delay(this.test); |
| 53 | + const gscOutput = gcs_output_uri(); |
| 54 | + const gscUri = (await gscOutput).uri; |
| 55 | + const output = await sample.generateVideo(gscUri, projectId, location); |
| 56 | + console.log('output', output); |
| 57 | + assert(output); |
| 58 | + }); |
| 59 | +}); |
0 commit comments