Skip to content

Commit 1f48a0e

Browse files
bmagyarkutibarna-emarsysEkrekr
authored
Restore ability to unit test views (#1824)
* restore ability to unit test views * apply suggested style changes Co-authored-by: Elias Kassell <eliaskassell@gmail.com> * apply suggested style change: newline * fix bug introduced by style change --------- Co-authored-by: Barna Magyarkuti <barna.magyarkuti@sap.com> Co-authored-by: Elias Kassell <eliaskassell@gmail.com>
1 parent b309aa0 commit 1f48a0e

3 files changed

Lines changed: 14 additions & 2 deletions

File tree

core/actions/test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { StringifiedMap } from "df/common/strings/stringifier";
33
import { ActionBuilder } from "df/core/actions";
44
import * as table from "df/core/actions/table";
55
import { ITableContext } from "df/core/actions/table";
6+
import { View } from "df/core/actions/view";
67
import { Contextable, ICommonContext, INamedConfig, Resolvable } from "df/core/common";
78
import { Session } from "df/core/session";
89
import { targetStringifier } from "df/core/targets";
@@ -107,7 +108,7 @@ export class Test extends ActionBuilder<dataform.Test> {
107108
);
108109
}
109110
const dataset = allResolved.length > 0 ? allResolved[0] : undefined;
110-
if (!(dataset && dataset instanceof table.Table)) {
111+
if (!(dataset && (dataset instanceof table.Table || dataset instanceof View))) {
111112
this.session.compileError(
112113
new Error(`Dataset ${stringifyResolvable(this.datasetToTest)} could not be found.`),
113114
this.proto.fileName

tests/integration/bigquery.spec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,8 @@ suite("@dataform/integration/bigquery", { parallel: true }, ({ before, after })
245245
'For row 1 and column "col3": expected "6.5", but saw "12".',
246246
'For row 2 and column "col1": expected "sup?", but saw "WRONG".'
247247
]
248-
}
248+
},
249+
{ name: "test a view", successful: true },
249250
]);
250251
});
251252

tests/integration/bigquery_project/definitions/test.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,3 +86,13 @@ test("wrong row contents")
8686
select 'sup?' as col3, 3 as col2, 9.5 as col3, true as col4
8787
`
8888
);
89+
90+
test("test a view")
91+
.dataset("example_view")
92+
.input(
93+
"sample_data",
94+
"select 'hi' as col1, 1 as col2, 3.5 as col3, true as col4, date '2020-07-23' as col5"
95+
)
96+
.expect(
97+
"select 'hi' as col1, 1 as col2, 3.5 as col3, true as col4, date '2020-07-23' as col5"
98+
);

0 commit comments

Comments
 (0)