@@ -3107,142 +3107,6 @@ class PipelineIntegrationTests: FSTIntegrationTestCase {
31073107 }
31083108 }
31093109
3110- func testMapSetAddsNewField( ) async throws {
3111- let collRef = collectionRef ( withDocuments: bookDocs)
3112- let db = collRef. firestore
3113-
3114- let pipeline = db. pipeline ( )
3115- . collection ( collRef. path)
3116- . where ( Field ( " title " ) . equal ( " The Hitchhiker's Guide to the Galaxy " ) )
3117- . select ( [
3118- Field ( " awards " ) . mapSet ( key: " newAward " , value: true ) . as ( " modifiedAwards " ) ,
3119- Field ( " title " ) ,
3120- ] )
3121-
3122- let snapshot = try await pipeline. execute ( )
3123-
3124- XCTAssertEqual ( snapshot. results. count, 1 , " Should retrieve one document " )
3125- if let resultDoc = snapshot. results. first {
3126- let expectedAwards : [ String : Sendable ? ] = [
3127- " hugo " : true ,
3128- " nebula " : false ,
3129- " others " : [ " unknown " : [ " year " : 1980 ] ] ,
3130- " newAward " : true ,
3131- ]
3132- let expectedResult : [ String : Sendable ? ] = [
3133- " title " : " The Hitchhiker's Guide to the Galaxy " ,
3134- " modifiedAwards " : expectedAwards,
3135- ]
3136- TestHelper . compare ( pipelineResult: resultDoc, expected: expectedResult)
3137- } else {
3138- XCTFail ( " No document retrieved for testMapSetAddsNewField " )
3139- }
3140- }
3141-
3142- func testMapSetUpdatesExistingField( ) async throws {
3143- let collRef = collectionRef ( withDocuments: bookDocs)
3144- let db = collRef. firestore
3145-
3146- let pipeline = db. pipeline ( )
3147- . collection ( collRef. path)
3148- . where ( Field ( " title " ) . equal ( " The Hitchhiker's Guide to the Galaxy " ) )
3149- . select ( [
3150- Field ( " awards " ) . mapSet ( key: " hugo " , value: false ) . as ( " modifiedAwards " ) ,
3151- Field ( " title " ) ,
3152- ] )
3153-
3154- let snapshot = try await pipeline. execute ( )
3155-
3156- XCTAssertEqual ( snapshot. results. count, 1 , " Should retrieve one document " )
3157- if let resultDoc = snapshot. results. first {
3158- let expectedAwards : [ String : Sendable ? ] = [
3159- " hugo " : false ,
3160- " nebula " : false ,
3161- " others " : [ " unknown " : [ " year " : 1980 ] ] ,
3162- ]
3163- let expectedResult : [ String : Sendable ? ] = [
3164- " title " : " The Hitchhiker's Guide to the Galaxy " ,
3165- " modifiedAwards " : expectedAwards,
3166- ]
3167- TestHelper . compare ( pipelineResult: resultDoc, expected: expectedResult)
3168- } else {
3169- XCTFail ( " No document retrieved for testMapSetUpdatesExistingField " )
3170- }
3171- }
3172-
3173- func testMapSetWithExpressionValue( ) async throws {
3174- let collRef = collectionRef ( withDocuments: bookDocs)
3175- let db = collRef. firestore
3176-
3177- let pipeline = db. pipeline ( )
3178- . collection ( collRef. path)
3179- . where ( Field ( " title " ) . equal ( " The Hitchhiker's Guide to the Galaxy " ) )
3180- . select (
3181- [
3182- Field ( " awards " )
3183- . mapSet (
3184- key: " ratingCategory " ,
3185- value: Field ( " rating " ) . greaterThan ( 4.0 ) . then ( Constant ( " high " ) , else: Constant ( " low " ) )
3186- )
3187- . as ( " modifiedAwards " ) ,
3188- Field ( " title " ) ,
3189- ]
3190- )
3191-
3192- let snapshot = try await pipeline. execute ( )
3193-
3194- XCTAssertEqual ( snapshot. results. count, 1 , " Should retrieve one document " )
3195- if let resultDoc = snapshot. results. first {
3196- let expectedAwards : [ String : Sendable ? ] = [
3197- " hugo " : true ,
3198- " nebula " : false ,
3199- " others " : [ " unknown " : [ " year " : 1980 ] ] ,
3200- " ratingCategory " : " high " ,
3201- ]
3202- let expectedResult : [ String : Sendable ? ] = [
3203- " title " : " The Hitchhiker's Guide to the Galaxy " ,
3204- " modifiedAwards " : expectedAwards,
3205- ]
3206- TestHelper . compare ( pipelineResult: resultDoc, expected: expectedResult)
3207- } else {
3208- XCTFail ( " No document retrieved for testMapSetWithExpressionValue " )
3209- }
3210- }
3211-
3212- func testMapSetWithExpressionKey( ) async throws {
3213- let collRef = collectionRef ( withDocuments: bookDocs)
3214- let db = collRef. firestore
3215-
3216- let pipeline = db. pipeline ( )
3217- . collection ( collRef. path)
3218- . where ( Field ( " title " ) . equal ( " The Hitchhiker's Guide to the Galaxy " ) )
3219- . select ( [
3220- Field ( " awards " )
3221- . mapSet ( key: Constant ( " dynamicKey " ) , value: " dynamicValue " )
3222- . as ( " modifiedAwards " ) ,
3223- Field ( " title " ) ,
3224- ] )
3225-
3226- let snapshot = try await pipeline. execute ( )
3227-
3228- XCTAssertEqual ( snapshot. results. count, 1 , " Should retrieve one document " )
3229- if let resultDoc = snapshot. results. first {
3230- let expectedAwards : [ String : Sendable ? ] = [
3231- " hugo " : true ,
3232- " nebula " : false ,
3233- " others " : [ " unknown " : [ " year " : 1980 ] ] ,
3234- " dynamicKey " : " dynamicValue " ,
3235- ]
3236- let expectedResult : [ String : Sendable ? ] = [
3237- " title " : " The Hitchhiker's Guide to the Galaxy " ,
3238- " modifiedAwards " : expectedAwards,
3239- ]
3240- TestHelper . compare ( pipelineResult: resultDoc, expected: expectedResult)
3241- } else {
3242- XCTFail ( " No document retrieved for testMapSetWithExpressionKey " )
3243- }
3244- }
3245-
32463110 func testSupportsTimestampConversions( ) async throws {
32473111 let db = firestore ( )
32483112 let randomCol = collectionRef ( ) // Unique collection for this test
0 commit comments