11import { expect } from "chai" ;
22
33import { IncrementalTableJitContext , SqlActionJitContext , TableJitContext } from "df/core/jit_context" ;
4- import { dataform } from "df/protos/ts" ;
4+ import { dataform , google } from "df/protos/ts" ;
55import { suite , test } from "df/testing" ;
66
77suite ( "jit_context" , ( ) => {
88 suite ( "SqlActionJitContext" , ( ) => {
99 const adapter = { } as dataform . DbAdapter ;
10+ const jitData = google . protobuf . Struct . create ( {
11+ fields : {
12+ key : google . protobuf . Value . create ( {
13+ structValue : google . protobuf . Struct . create ( {
14+ fields : {
15+ number : google . protobuf . Value . create ( { numberValue : 123 } ) ,
16+ string : google . protobuf . Value . create ( { stringValue : "value" } ) ,
17+ boolean : google . protobuf . Value . create ( { boolValue : true } ) ,
18+ struct : google . protobuf . Value . create ( {
19+ structValue : google . protobuf . Struct . create ( {
20+ fields : {
21+ nestedKey : google . protobuf . Value . create ( { stringValue : "nestedValue" } )
22+ }
23+ } )
24+ } ) ,
25+ list : google . protobuf . Value . create ( {
26+ listValue : google . protobuf . ListValue . create ( {
27+ values : [
28+ google . protobuf . Value . create ( { stringValue : "a" } ) ,
29+ google . protobuf . Value . create ( { stringValue : "b" } ) ,
30+ google . protobuf . Value . create ( { stringValue : "c" } )
31+ ]
32+ } )
33+ } ) ,
34+ null : google . protobuf . Value . create ( {
35+ nullValue : google . protobuf . NullValue . NULL_VALUE
36+ } ) ,
37+ undef : google . protobuf . Value . create ( {
38+ nullValue : google . protobuf . NullValue . NULL_VALUE
39+ } ) ,
40+ }
41+ } )
42+ } )
43+ }
44+ } ) ;
1045 const request = dataform . JitCompilationRequest . create ( {
1146 target : dataform . Target . create ( {
1247 database : "db" ,
@@ -21,6 +56,7 @@ suite("jit_context", () => {
2156 } )
2257 ] ,
2358 filePaths : [ ] ,
59+ jitData,
2460 } ) ;
2561 const withoutDependenciesRequest = dataform . JitCompilationRequest . create ( {
2662 target : dataform . Target . create ( {
@@ -76,6 +112,27 @@ suite("jit_context", () => {
76112 const context = new SqlActionJitContext ( adapter , withoutDependenciesRequest ) ;
77113 expect ( context . database ( ) ) . to . equal ( "db" ) ;
78114 } ) ;
115+
116+ test ( "data" , ( ) => {
117+ const context = new SqlActionJitContext ( adapter , request ) ;
118+ expect ( context . data ) . to . deep . equal ( {
119+ "key" : {
120+ "number" : 123 ,
121+ "string" : "value" ,
122+ "boolean" : true ,
123+ "struct" : {
124+ "nestedKey" : "nestedValue"
125+ } ,
126+ "list" : [
127+ "a" ,
128+ "b" ,
129+ "c"
130+ ] ,
131+ "null" : null ,
132+ "undef" : null ,
133+ }
134+ } ) ;
135+ } ) ;
79136 } ) ;
80137
81138 suite ( "TableJitContext" , ( ) => {
0 commit comments