-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathdataform.test.js
More file actions
49 lines (41 loc) · 1.63 KB
/
dataform.test.js
File metadata and controls
49 lines (41 loc) · 1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import test from 'node:test'
import assert from 'node:assert'
import { DataformClient } from '@google-cloud/dataform'
import { getCompilationResults, runWorkflow } from './dataform.js'
test('getCompilationResults', async (t) => {
const mockResponse = [{ name: 'mock-compilation-result-name' }]
t.mock.method(DataformClient.prototype, 'createCompilationResult', async () => mockResponse)
const repoURI = 'mock-repo-uri'
const result = await getCompilationResults(repoURI)
assert.strictEqual(result, 'mock-compilation-result-name')
const calls = DataformClient.prototype.createCompilationResult.mock.calls
assert.strictEqual(calls.length, 1)
assert.deepStrictEqual(calls[0].arguments[0], {
parent: repoURI,
compilationResult: {
releaseConfig: `${repoURI}/releaseConfigs/production`
}
})
})
test('runWorkflow', async (t) => {
const mockResponse = [{ name: 'mock-workflow-invocation-name' }]
t.mock.method(DataformClient.prototype, 'createWorkflowInvocation', async () => mockResponse)
const repoURI = 'mock-repo-uri'
const compilationResult = 'mock-compilation-result-name'
const tags = ['tag1', 'tag2']
await runWorkflow(repoURI, compilationResult, tags)
const calls = DataformClient.prototype.createWorkflowInvocation.mock.calls
assert.strictEqual(calls.length, 1)
assert.deepStrictEqual(calls[0].arguments[0], {
parent: repoURI,
workflowInvocation: {
compilationResult,
invocationConfig: {
includedTags: tags,
fullyRefreshIncrementalTablesEnabled: false,
transitiveDependenciesIncluded: false,
transitiveDependentsIncluded: false
}
}
})
})