@@ -15,8 +15,12 @@ let dataset: Dataset;
1515let table : Table ;
1616let randomID : string ;
1717let datasetId : string ;
18+ const describeIfBigQueryIntegration =
19+ process . env . RUN_BIGQUERY_INTEGRATION_TESTS === "true"
20+ ? describe
21+ : describe . skip ;
1822
19- describe ( "processing partitions on a new table" , ( ) => {
23+ describeIfBigQueryIntegration ( "processing partitions on a new table" , ( ) => {
2024 beforeAll ( async ( ) => {
2125 jest . spyOn ( logger , "debug" ) . mockImplementation ( ( ) => { } ) ;
2226 jest . spyOn ( logger , "info" ) . mockImplementation ( ( ) => { } ) ;
@@ -576,7 +580,7 @@ describe("processing partitions on a new table", () => {
576580 } ) ;
577581} ) ;
578582
579- describe ( "updateTableMetadata" , ( ) => {
583+ describeIfBigQueryIntegration ( "updateTableMetadata" , ( ) => {
580584 let testTable : Table ;
581585 let testDataset : Dataset ;
582586
@@ -728,103 +732,106 @@ describe("updateTableMetadata", () => {
728732 } ) ;
729733} ) ;
730734
731- describe ( "getPartitionValue with DELETE operations" , ( ) => {
732- let testTable : Table ;
733- let testDataset : Dataset ;
734-
735- beforeAll ( async ( ) => {
736- const randomID = ( Math . random ( ) + 1 ) . toString ( 36 ) . substring ( 7 ) ;
737- const testDatasetId = `bq_delete_${ randomID } ` ;
738- [ testDataset ] = await bq . createDataset ( testDatasetId , {
739- location : "europe-west2" ,
740- } ) ;
741- [ testTable ] = await testDataset . createTable ( `bq_delete_${ randomID } ` , { } ) ;
742- } ) ;
743-
744- afterAll ( async ( ) => {
745- await deleteTable ( {
746- datasetId : testDataset . id ,
735+ describeIfBigQueryIntegration (
736+ "getPartitionValue with DELETE operations" ,
737+ ( ) => {
738+ let testTable : Table ;
739+ let testDataset : Dataset ;
740+
741+ beforeAll ( async ( ) => {
742+ const randomID = ( Math . random ( ) + 1 ) . toString ( 36 ) . substring ( 7 ) ;
743+ const testDatasetId = `bq_delete_${ randomID } ` ;
744+ [ testDataset ] = await bq . createDataset ( testDatasetId , {
745+ location : "europe-west2" ,
746+ } ) ;
747+ [ testTable ] = await testDataset . createTable ( `bq_delete_${ randomID } ` , { } ) ;
747748 } ) ;
748- } ) ;
749749
750- test ( "uses oldData for DELETE operations" , ( ) => {
751- const partitioningConfig = new PartitioningConfig ( {
752- granularity : "DAY" ,
753- bigqueryColumnName : "end_date" ,
754- bigqueryColumnType : "TIMESTAMP" ,
755- firestoreFieldName : "endDate" ,
750+ afterAll ( async ( ) => {
751+ await deleteTable ( {
752+ datasetId : testDataset . id ,
753+ } ) ;
756754 } ) ;
757755
758- const oldDate = admin . firestore . Timestamp . fromDate (
759- new Date ( "2024-01-15T10:00:00Z" )
760- ) ;
756+ test ( "uses oldData for DELETE operations" , ( ) => {
757+ const partitioningConfig = new PartitioningConfig ( {
758+ granularity : "DAY" ,
759+ bigqueryColumnName : "end_date" ,
760+ bigqueryColumnType : "TIMESTAMP" ,
761+ firestoreFieldName : "endDate" ,
762+ } ) ;
761763
762- const event : FirestoreDocumentChangeEvent = {
763- timestamp : "" ,
764- operation : ChangeType . DELETE ,
765- documentName : "test/doc" ,
766- eventId : "event1" ,
767- documentId : "doc" ,
768- data : null ,
769- oldData : { endDate : oldDate } ,
770- } ;
764+ const oldDate = admin . firestore . Timestamp . fromDate (
765+ new Date ( "2024-01-15T10:00:00Z" )
766+ ) ;
771767
772- const partitioning = new Partitioning ( partitioningConfig , testTable ) ;
773- const value = partitioning . getPartitionValue ( event ) ;
768+ const event : FirestoreDocumentChangeEvent = {
769+ timestamp : "" ,
770+ operation : ChangeType . DELETE ,
771+ documentName : "test/doc" ,
772+ eventId : "event1" ,
773+ documentId : "doc" ,
774+ data : null ,
775+ oldData : { endDate : oldDate } ,
776+ } ;
774777
775- expect ( value . end_date ) . toBeDefined ( ) ;
776- } ) ;
778+ const partitioning = new Partitioning ( partitioningConfig , testTable ) ;
779+ const value = partitioning . getPartitionValue ( event ) ;
777780
778- test ( "returns empty object for DELETE when oldData is null" , ( ) => {
779- const partitioningConfig = new PartitioningConfig ( {
780- granularity : "DAY" ,
781- bigqueryColumnName : "end_date" ,
782- bigqueryColumnType : "TIMESTAMP" ,
783- firestoreFieldName : "endDate" ,
781+ expect ( value . end_date ) . toBeDefined ( ) ;
784782 } ) ;
785783
786- const event : FirestoreDocumentChangeEvent = {
787- timestamp : "" ,
788- operation : ChangeType . DELETE ,
789- documentName : "test/doc" ,
790- eventId : "event1" ,
791- documentId : "doc" ,
792- data : null ,
793- oldData : null ,
794- } ;
784+ test ( "returns empty object for DELETE when oldData is null" , ( ) => {
785+ const partitioningConfig = new PartitioningConfig ( {
786+ granularity : "DAY" ,
787+ bigqueryColumnName : "end_date" ,
788+ bigqueryColumnType : "TIMESTAMP" ,
789+ firestoreFieldName : "endDate" ,
790+ } ) ;
795791
796- const partitioning = new Partitioning ( partitioningConfig , testTable ) ;
797- const value = partitioning . getPartitionValue ( event ) ;
792+ const event : FirestoreDocumentChangeEvent = {
793+ timestamp : "" ,
794+ operation : ChangeType . DELETE ,
795+ documentName : "test/doc" ,
796+ eventId : "event1" ,
797+ documentId : "doc" ,
798+ data : null ,
799+ oldData : null ,
800+ } ;
798801
799- expect ( value ) . toEqual ( { } ) ;
800- } ) ;
802+ const partitioning = new Partitioning ( partitioningConfig , testTable ) ;
803+ const value = partitioning . getPartitionValue ( event ) ;
801804
802- test ( "returns empty object for DELETE when oldData lacks the field" , ( ) => {
803- const partitioningConfig = new PartitioningConfig ( {
804- granularity : "DAY" ,
805- bigqueryColumnName : "end_date" ,
806- bigqueryColumnType : "TIMESTAMP" ,
807- firestoreFieldName : "endDate" ,
805+ expect ( value ) . toEqual ( { } ) ;
808806 } ) ;
809807
810- const event : FirestoreDocumentChangeEvent = {
811- timestamp : "" ,
812- operation : ChangeType . DELETE ,
813- documentName : "test/doc" ,
814- eventId : "event1" ,
815- documentId : "doc" ,
816- data : null ,
817- oldData : { otherField : "value" } ,
818- } ;
808+ test ( "returns empty object for DELETE when oldData lacks the field" , ( ) => {
809+ const partitioningConfig = new PartitioningConfig ( {
810+ granularity : "DAY" ,
811+ bigqueryColumnName : "end_date" ,
812+ bigqueryColumnType : "TIMESTAMP" ,
813+ firestoreFieldName : "endDate" ,
814+ } ) ;
819815
820- const partitioning = new Partitioning ( partitioningConfig , testTable ) ;
821- const value = partitioning . getPartitionValue ( event ) ;
816+ const event : FirestoreDocumentChangeEvent = {
817+ timestamp : "" ,
818+ operation : ChangeType . DELETE ,
819+ documentName : "test/doc" ,
820+ eventId : "event1" ,
821+ documentId : "doc" ,
822+ data : null ,
823+ oldData : { otherField : "value" } ,
824+ } ;
822825
823- expect ( value ) . toEqual ( { } ) ;
824- } ) ;
825- } ) ;
826+ const partitioning = new Partitioning ( partitioningConfig , testTable ) ;
827+ const value = partitioning . getPartitionValue ( event ) ;
828+
829+ expect ( value ) . toEqual ( { } ) ;
830+ } ) ;
831+ }
832+ ) ;
826833
827- describe ( "isValidPartitionForExistingTable" , ( ) => {
834+ describeIfBigQueryIntegration ( "isValidPartitionForExistingTable" , ( ) => {
828835 let testTable : Table ;
829836 let testDataset : Dataset ;
830837 let partitionedTable : Table ;
@@ -886,7 +893,7 @@ describe("isValidPartitionForExistingTable", () => {
886893 } ) ;
887894} ) ;
888895
889- describe ( "addPartitioningToSchema with DATE type" , ( ) => {
896+ describeIfBigQueryIntegration ( "addPartitioningToSchema with DATE type" , ( ) => {
890897 let testTable : Table ;
891898 let testDataset : Dataset ;
892899
0 commit comments