diff --git a/.pubnub.yml b/.pubnub.yml index 552952f9..25401336 100644 --- a/.pubnub.yml +++ b/.pubnub.yml @@ -1,9 +1,14 @@ --- name: swift scm: github.com/pubnub/swift -version: "7.3.1" +version: "7.3.2" schema: 1 changelog: + - date: 2024-07-22 + version: 7.3.2 + changes: + - type: bug + text: "Add missing public initializers for `EncryptedData` and `EncryptedStreamData`." - date: 2024-06-18 version: 7.3.1 changes: @@ -559,7 +564,7 @@ sdks: - distribution-type: source distribution-repository: GitHub release package-name: PubNub - location: https://github.com/pubnub/swift/archive/refs/tags/7.3.1.zip + location: https://github.com/pubnub/swift/archive/refs/tags/7.3.2.zip supported-platforms: supported-operating-systems: macOS: diff --git a/Examples/Examples.xcodeproj/project.pbxproj b/Examples/Examples.xcodeproj/project.pbxproj index 7403ce8c..03937b6a 100644 --- a/Examples/Examples.xcodeproj/project.pbxproj +++ b/Examples/Examples.xcodeproj/project.pbxproj @@ -16,8 +16,8 @@ 359F779F22B7FEF700B6B46F /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 359F779E22B7FEF700B6B46F /* Assets.xcassets */; }; 359F77A222B7FEF700B6B46F /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 359F77A022B7FEF700B6B46F /* LaunchScreen.storyboard */; }; 35F0258F22BAC6C9007BD7D3 /* ConfigDetailTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 35F0258E22BAC6C9007BD7D3 /* ConfigDetailTableViewController.swift */; }; + 3D26A6152C6BB68A007B4539 /* PubNubSDK in Frameworks */ = {isa = PBXBuildFile; productRef = 3D26A6142C6BB68A007B4539 /* PubNubSDK */; }; 3D34160D2BB5CE20008558A0 /* DetailTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3D34160C2BB5CE20008558A0 /* DetailTableViewController.swift */; }; - 792CF27228C4FBB300C83408 /* PubNub in Frameworks */ = {isa = PBXBuildFile; productRef = 792CF27128C4FBB300C83408 /* PubNub */; }; 792CF27428C4FBB300C83408 /* PubNubMembership in Frameworks */ = {isa = PBXBuildFile; productRef = 792CF27328C4FBB300C83408 /* PubNubMembership */; }; 792CF27628C4FBB300C83408 /* PubNubSpace in Frameworks */ = {isa = PBXBuildFile; productRef = 792CF27528C4FBB300C83408 /* PubNubSpace */; }; 792CF27828C4FBB300C83408 /* PubNubUser in Frameworks */ = {isa = PBXBuildFile; productRef = 792CF27728C4FBB300C83408 /* PubNubUser */; }; @@ -70,9 +70,9 @@ buildActionMask = 2147483647; files = ( 792CF27428C4FBB300C83408 /* PubNubMembership in Frameworks */, + 3D26A6152C6BB68A007B4539 /* PubNubSDK in Frameworks */, 792CF27828C4FBB300C83408 /* PubNubUser in Frameworks */, 792CF27628C4FBB300C83408 /* PubNubSpace in Frameworks */, - 792CF27228C4FBB300C83408 /* PubNub in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -176,10 +176,10 @@ ); name = "iOS Example"; packageProductDependencies = ( - 792CF27128C4FBB300C83408 /* PubNub */, 792CF27328C4FBB300C83408 /* PubNubMembership */, 792CF27528C4FBB300C83408 /* PubNubSpace */, 792CF27728C4FBB300C83408 /* PubNubUser */, + 3D26A6142C6BB68A007B4539 /* PubNubSDK */, ); productName = swiftSdkiOS; productReference = 359F779422B7FEF600B6B46F /* iOS Example.app */; @@ -464,9 +464,9 @@ /* End XCConfigurationList section */ /* Begin XCSwiftPackageProductDependency section */ - 792CF27128C4FBB300C83408 /* PubNub */ = { + 3D26A6142C6BB68A007B4539 /* PubNubSDK */ = { isa = XCSwiftPackageProductDependency; - productName = PubNub; + productName = PubNubSDK; }; 792CF27328C4FBB300C83408 /* PubNubMembership */ = { isa = XCSwiftPackageProductDependency; diff --git a/Examples/Sources/AppDelegate.swift b/Examples/Sources/AppDelegate.swift index 4801535e..c4820140 100644 --- a/Examples/Sources/AppDelegate.swift +++ b/Examples/Sources/AppDelegate.swift @@ -9,8 +9,7 @@ // import UIKit - -import PubNub +import PubNubSDK @UIApplicationMain class AppDelegate: UIResponder, UIApplicationDelegate { diff --git a/Examples/Sources/ConfigDetailTableViewController.swift b/Examples/Sources/ConfigDetailTableViewController.swift index d1ac789e..0f084323 100644 --- a/Examples/Sources/ConfigDetailTableViewController.swift +++ b/Examples/Sources/ConfigDetailTableViewController.swift @@ -9,8 +9,7 @@ // import UIKit - -import PubNub +import PubNubSDK class ConfigDetailTableViewController: UITableViewController { diff --git a/Examples/Sources/DetailTableViewController.swift b/Examples/Sources/DetailTableViewController.swift index 94682640..371deed3 100644 --- a/Examples/Sources/DetailTableViewController.swift +++ b/Examples/Sources/DetailTableViewController.swift @@ -11,7 +11,7 @@ import Foundation import UIKit -import PubNub +import PubNubSDK import PubNubMembership import PubNubSpace import PubNubUser @@ -249,12 +249,10 @@ class DetailTableViewController: UITableViewController { print("The signal is \(signal.payload) and was sent by \(signal.publisher ?? "")") case let .connectionStatusChanged(connectionChange): switch connectionChange { - case .connecting: - print("Status connecting...") case .connected: print("Status connected!") - case .reconnecting: - print("Status reconnecting...") + case .subscriptionChanged: + print("Subscription changed") case .disconnected: print("Status disconnected") case .disconnectedUnexpectedly: diff --git a/Examples/Sources/File/FileAPIViewController.swift b/Examples/Sources/File/FileAPIViewController.swift index 88c06f6c..adf18521 100644 --- a/Examples/Sources/File/FileAPIViewController.swift +++ b/Examples/Sources/File/FileAPIViewController.swift @@ -9,8 +9,7 @@ // import UIKit - -import PubNub +import PubNubSDK enum AlertMessageDirection: String { case upload = "Uploading" diff --git a/Examples/Sources/File/LocalFileExample.swift b/Examples/Sources/File/LocalFileExample.swift index 52930cef..add59ff0 100644 --- a/Examples/Sources/File/LocalFileExample.swift +++ b/Examples/Sources/File/LocalFileExample.swift @@ -9,8 +9,7 @@ // import Foundation - -import PubNub +import PubNubSDK enum FileError: Error { case fileNameError diff --git a/Package.swift b/Package.swift index a7d0f711..c5227bbf 100644 --- a/Package.swift +++ b/Package.swift @@ -22,8 +22,8 @@ let package = Package( products: [ // Products define the executables and libraries produced by a package, and make them visible to other packages. .library( - name: "PubNub", - targets: ["PubNub"] + name: "PubNubSDK", + targets: ["PubNubSDK"] ), .library( name: "PubNubUser", @@ -45,28 +45,28 @@ let package = Package( // Targets are the basic building blocks of a package. A target can define a module or a test suite. // Targets can depend on other targets in this package, and on products in packages which this package depends on. .target( - name: "PubNub", + name: "PubNubSDK", path: "Sources/PubNub", resources: [.copy("PrivacyInfo.xcprivacy")] ), .target( name: "PubNubUser", - dependencies: ["PubNub"], + dependencies: ["PubNubSDK"], path: "PubNubUser/Sources" ), .target( name: "PubNubSpace", - dependencies: ["PubNub"], + dependencies: ["PubNubSDK"], path: "PubNubSpace/Sources" ), .target( name: "PubNubMembership", - dependencies: ["PubNub", "PubNubUser", "PubNubSpace"], + dependencies: ["PubNubSDK", "PubNubUser", "PubNubSpace"], path: "PubNubMembership/Sources" ), .testTarget( name: "PubNubTests", - dependencies: ["PubNub"] + dependencies: ["PubNubSDK"] ) ], swiftLanguageVersions: [.v5] diff --git a/PubNub.xcodeproj/project.pbxproj b/PubNub.xcodeproj/project.pbxproj index c6e9265e..df062087 100644 --- a/PubNub.xcodeproj/project.pbxproj +++ b/PubNub.xcodeproj/project.pbxproj @@ -129,7 +129,7 @@ 35580682230F3A34005CDD92 /* RequestIdOperator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 35580681230F3A34005CDD92 /* RequestIdOperator.swift */; }; 35580686230F47EA005CDD92 /* RequestIdOperatorTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 35580684230F4771005CDD92 /* RequestIdOperatorTests.swift */; }; 3558069C231303D9005CDD92 /* AutomaticRetryTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3558069B231303D9005CDD92 /* AutomaticRetryTests.swift */; }; - 355806DB23145749005CDD92 /* PubNub.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = "PubNub::PubNub::Product" /* PubNub.framework */; }; + 355806DB23145749005CDD92 /* PubNubSDK.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = "PubNub::PubNub::Product" /* PubNubSDK.framework */; }; 3559977B23073D53000BCFD1 /* WeakBoxTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3559977A23073D53000BCFD1 /* WeakBoxTests.swift */; }; 3559977F23078A7C000BCFD1 /* message_counts_error_invalid_arguments.json in Resources */ = {isa = PBXBuildFile; fileRef = 3559977E230787E7000BCFD1 /* message_counts_error_invalid_arguments.json */; }; 3559978223079070000BCFD1 /* forbidden_Message.json in Resources */ = {isa = PBXBuildFile; fileRef = 3559978023078F85000BCFD1 /* forbidden_Message.json */; }; @@ -451,6 +451,7 @@ 3DA24A412C2AAB23005B959B /* PubNubObjC+ChannelGroups.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3DA24A402C2AAB23005B959B /* PubNubObjC+ChannelGroups.swift */; }; 3DA24A432C2AAB54005B959B /* PubNubObjC+AppContext.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3DA24A422C2AAB54005B959B /* PubNubObjC+AppContext.swift */; }; 3DA24A452C2AABC0005B959B /* PubNubObjC+Files.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3DA24A442C2AABC0005B959B /* PubNubObjC+Files.swift */; }; + 3DA0C7D02BFE59AC000FFE6C /* SubscriptionListenersContainer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3DA0C7CF2BFE59AC000FFE6C /* SubscriptionListenersContainer.swift */; }; 3DACC7F72AB88F8E00210B14 /* Data+CommonCrypto.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3DACC7F62AB88F8E00210B14 /* Data+CommonCrypto.swift */; }; 3DB2C4872C0F4B250060B8CF /* PubNubStatusListenerObjC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3DB2C4862C0F4B250060B8CF /* PubNubStatusListenerObjC.swift */; }; 3DB9255C2B7A2B89001B7E90 /* SubscriptionStreamTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3DB925592B7A2B89001B7E90 /* SubscriptionStreamTests.swift */; }; @@ -502,10 +503,11 @@ 79407BE5271D4CFA0032076C /* PubNubFilesContractTestSteps.swift in Sources */ = {isa = PBXBuildFile; fileRef = 79407BD1271D4CFA0032076C /* PubNubFilesContractTestSteps.swift */; }; 79407C00271D519F0032076C /* Features in Resources */ = {isa = PBXBuildFile; fileRef = 79407BFF271D519F0032076C /* Features */; }; 79407C01271D519F0032076C /* Features in Resources */ = {isa = PBXBuildFile; fileRef = 79407BFF271D519F0032076C /* Features */; }; - 7941EEA9270E433F0054D9EF /* PubNub.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = "PubNub::PubNub::Product" /* PubNub.framework */; platformFilter = ios; }; + 7941EEA9270E433F0054D9EF /* PubNubSDK.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = "PubNub::PubNub::Product" /* PubNubSDK.framework */; platformFilter = ios; }; 7951954E26C955CE001E308C /* PAMToken.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7951954D26C955CE001E308C /* PAMToken.swift */; }; 79657AA3271A13F700BACEC5 /* PubNub.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = "PubNub::PubNub::Product" /* PubNub.framework */; platformFilter = ios; }; 84AE887E2C0D9CFA009FB148 /* AnyJSONObjC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84AE887D2C0D9CFA009FB148 /* AnyJSONObjC.swift */; }; + 79657AA3271A13F700BACEC5 /* PubNubSDK.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = "PubNub::PubNub::Product" /* PubNubSDK.framework */; platformFilter = ios; }; A5115F2529195AF400F6ADA1 /* PubNubObjectsMembersContractTestSteps.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5115F2429195AF400F6ADA1 /* PubNubObjectsMembersContractTestSteps.swift */; }; A5115F2629195AF400F6ADA1 /* PubNubObjectsMembersContractTestSteps.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5115F2429195AF400F6ADA1 /* PubNubObjectsMembersContractTestSteps.swift */; }; A5115F28291D54F500F6ADA1 /* PubNubObjectsMembershipsContractTestSteps.swift in Sources */ = {isa = PBXBuildFile; fileRef = A5115F27291D54F500F6ADA1 /* PubNubObjectsMembershipsContractTestSteps.swift */; }; @@ -522,7 +524,7 @@ D2635DFB22FCCF080097CF64 /* message_counts_success.json in Resources */ = {isa = PBXBuildFile; fileRef = D2635DFA22FCCF080097CF64 /* message_counts_success.json */; }; OBJ_31 /* PubNub.swift in Sources */ = {isa = PBXBuildFile; fileRef = OBJ_11 /* PubNub.swift */; }; OBJ_49 /* PubNubTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = OBJ_15 /* PubNubTests.swift */; }; - OBJ_51 /* PubNub.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = "PubNub::PubNub::Product" /* PubNub.framework */; }; + OBJ_51 /* PubNubSDK.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = "PubNub::PubNub::Product" /* PubNubSDK.framework */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -1072,6 +1074,7 @@ 3DA24A402C2AAB23005B959B /* PubNubObjC+ChannelGroups.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "PubNubObjC+ChannelGroups.swift"; sourceTree = ""; }; 3DA24A422C2AAB54005B959B /* PubNubObjC+AppContext.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "PubNubObjC+AppContext.swift"; sourceTree = ""; }; 3DA24A442C2AABC0005B959B /* PubNubObjC+Files.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "PubNubObjC+Files.swift"; sourceTree = ""; }; + 3DA0C7CF2BFE59AC000FFE6C /* SubscriptionListenersContainer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SubscriptionListenersContainer.swift; sourceTree = ""; }; 3DACC7F62AB88F8E00210B14 /* Data+CommonCrypto.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Data+CommonCrypto.swift"; sourceTree = ""; }; 3DB2C4862C0F4B250060B8CF /* PubNubStatusListenerObjC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PubNubStatusListenerObjC.swift; sourceTree = ""; }; 3DB925592B7A2B89001B7E90 /* SubscriptionStreamTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SubscriptionStreamTests.swift; sourceTree = ""; }; @@ -1138,7 +1141,7 @@ OBJ_24 /* PubNubSwift.podspec */ = {isa = PBXFileReference; explicitFileType = text.script.ruby; path = PubNubSwift.podspec; sourceTree = ""; }; OBJ_6 /* Package.swift */ = {isa = PBXFileReference; explicitFileType = sourcecode.swift; path = Package.swift; sourceTree = ""; }; OBJ_9 /* PubNub.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PubNub.h; sourceTree = ""; }; - "PubNub::PubNub::Product" /* PubNub.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = PubNub.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + "PubNub::PubNub::Product" /* PubNubSDK.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = PubNubSDK.framework; sourceTree = BUILT_PRODUCTS_DIR; }; "PubNub::PubNubTests::Product" /* PubNubTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; path = PubNubTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; /* End PBXFileReference section */ @@ -1147,7 +1150,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 0; files = ( - 355806DB23145749005CDD92 /* PubNub.framework in Frameworks */, + 355806DB23145749005CDD92 /* PubNubSDK.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1224,7 +1227,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 0; files = ( - 7941EEA9270E433F0054D9EF /* PubNub.framework in Frameworks */, + 7941EEA9270E433F0054D9EF /* PubNubSDK.framework in Frameworks */, 4C2A8D84BCD39B07A66FD9B4 /* Pods_PubNubContractTests.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; @@ -1233,7 +1236,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 0; files = ( - 79657AA3271A13F700BACEC5 /* PubNub.framework in Frameworks */, + 79657AA3271A13F700BACEC5 /* PubNubSDK.framework in Frameworks */, 0162B986DE5A8773D6F8C8A0 /* Pods_PubNubContractTestsBeta.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; @@ -1249,7 +1252,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 0; files = ( - OBJ_51 /* PubNub.framework in Frameworks */, + OBJ_51 /* PubNubSDK.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -2586,7 +2589,7 @@ isa = PBXGroup; children = ( "PubNub::PubNubTests::Product" /* PubNubTests.xctest */, - "PubNub::PubNub::Product" /* PubNub.framework */, + "PubNub::PubNub::Product" /* PubNubSDK.framework */, 3558073723145749005CDD92 /* PubNubIntTests.xctest */, 7941EF40270E433F0054D9EF /* PubNubContractTests.xctest */, 79657AAB271A13F700BACEC5 /* PubNubContractTestsBeta.xctest */, @@ -2896,9 +2899,9 @@ productReference = 79657AAB271A13F700BACEC5 /* PubNubContractTestsBeta.xctest */; productType = "com.apple.product-type.bundle.unit-test"; }; - "PubNub::PubNub" /* PubNub */ = { + "PubNub::PubNub" /* PubNubSDK */ = { isa = PBXNativeTarget; - buildConfigurationList = OBJ_27 /* Build configuration list for PBXNativeTarget "PubNub" */; + buildConfigurationList = OBJ_27 /* Build configuration list for PBXNativeTarget "PubNubSDK" */; buildPhases = ( 3D5BE9AD2BCEA5AC0091ACA7 /* Resources */, OBJ_30 /* Sources */, @@ -2908,9 +2911,9 @@ ); dependencies = ( ); - name = PubNub; + name = PubNubSDK; productName = PubNub; - productReference = "PubNub::PubNub::Product" /* PubNub.framework */; + productReference = "PubNub::PubNub::Product" /* PubNubSDK.framework */; productType = "com.apple.product-type.framework"; }; "PubNub::PubNubTests" /* PubNubTests */ = { @@ -2981,7 +2984,7 @@ projectDirPath = ""; projectRoot = ""; targets = ( - "PubNub::PubNub" /* PubNub */, + "PubNub::PubNub" /* PubNubSDK */, "PubNub::PubNubTests" /* PubNubTests */, 7941EE6B270E433F0054D9EF /* PubNubContractTests */, 79657A93271A13F700BACEC5 /* PubNubContractTestsBeta */, @@ -3811,7 +3814,7 @@ /* Begin PBXTargetDependency section */ 3558069E23145749005CDD92 /* PBXTargetDependency */ = { isa = PBXTargetDependency; - target = "PubNub::PubNub" /* PubNub */; + target = "PubNub::PubNub" /* PubNubSDK */; targetProxy = 3558069F23145749005CDD92 /* PBXContainerItemProxy */; }; 358B8917284D206B00DB0F3D /* PBXTargetDependency */ = { @@ -3831,17 +3834,17 @@ }; 358B8962284D22B100DB0F3D /* PBXTargetDependency */ = { isa = PBXTargetDependency; - target = "PubNub::PubNub" /* PubNub */; + target = "PubNub::PubNub" /* PubNubSDK */; targetProxy = 358B8961284D22B100DB0F3D /* PBXContainerItemProxy */; }; 358B8966284D22D800DB0F3D /* PBXTargetDependency */ = { isa = PBXTargetDependency; - target = "PubNub::PubNub" /* PubNub */; + target = "PubNub::PubNub" /* PubNubSDK */; targetProxy = 358B8965284D22D800DB0F3D /* PBXContainerItemProxy */; }; 358B8968284D22E200DB0F3D /* PBXTargetDependency */ = { isa = PBXTargetDependency; - target = "PubNub::PubNub" /* PubNub */; + target = "PubNub::PubNub" /* PubNubSDK */; targetProxy = 358B8967284D22E200DB0F3D /* PBXContainerItemProxy */; }; 358B896A284D22E200DB0F3D /* PBXTargetDependency */ = { @@ -3872,18 +3875,18 @@ 7941EE6C270E433F0054D9EF /* PBXTargetDependency */ = { isa = PBXTargetDependency; platformFilter = ios; - target = "PubNub::PubNub" /* PubNub */; + target = "PubNub::PubNub" /* PubNubSDK */; targetProxy = 7941EE6D270E433F0054D9EF /* PBXContainerItemProxy */; }; 79657A94271A13F700BACEC5 /* PBXTargetDependency */ = { isa = PBXTargetDependency; platformFilter = ios; - target = "PubNub::PubNub" /* PubNub */; + target = "PubNub::PubNub" /* PubNubSDK */; targetProxy = 79657A95271A13F700BACEC5 /* PBXContainerItemProxy */; }; OBJ_52 /* PBXTargetDependency */ = { isa = PBXTargetDependency; - target = "PubNub::PubNub" /* PubNub */; + target = "PubNub::PubNub" /* PubNubSDK */; targetProxy = 35EA73F422B1916100D97BF0 /* PBXContainerItemProxy */; }; /* End PBXTargetDependency section */ @@ -3995,7 +3998,7 @@ "@loader_path/Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 10.15; - MARKETING_VERSION = 7.3.1; + MARKETING_VERSION = 7.3.2; MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu11 gnu++17"; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; @@ -4046,7 +4049,7 @@ "@loader_path/Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 10.15; - MARKETING_VERSION = 7.3.1; + MARKETING_VERSION = 7.3.2; MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu11 gnu++17"; MTL_ENABLE_DEBUG_INFO = NO; MTL_FAST_MATH = YES; @@ -4154,7 +4157,7 @@ "@loader_path/Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 10.15; - MARKETING_VERSION = 7.3.1; + MARKETING_VERSION = 7.3.2; MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu11 gnu++17"; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; @@ -4207,7 +4210,7 @@ "@loader_path/Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 10.15; - MARKETING_VERSION = 7.3.1; + MARKETING_VERSION = 7.3.2; MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu11 gnu++17"; MTL_ENABLE_DEBUG_INFO = NO; MTL_FAST_MATH = YES; @@ -4328,7 +4331,7 @@ "@loader_path/Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 10.15; - MARKETING_VERSION = 7.3.1; + MARKETING_VERSION = 7.3.2; MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu11 gnu++17"; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; @@ -4380,7 +4383,7 @@ "@loader_path/Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 10.15; - MARKETING_VERSION = 7.3.1; + MARKETING_VERSION = 7.3.2; MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu11 gnu++17"; MTL_ENABLE_DEBUG_INFO = NO; MTL_FAST_MATH = YES; @@ -4860,7 +4863,7 @@ "$(TOOLCHAIN_DIR)/usr/lib/swift/macosx", ); MACOSX_DEPLOYMENT_TARGET = 10.15; - MARKETING_VERSION = 7.3.1; + MARKETING_VERSION = 7.3.2; MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu17 gnu++14"; OTHER_CFLAGS = "$(inherited)"; OTHER_LDFLAGS = "$(inherited)"; @@ -4873,7 +4876,7 @@ SUPPORTS_MACCATALYST = NO; SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO; SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$(inherited)"; - TARGET_NAME = PubNub; + TARGET_NAME = PubNubSDK; TVOS_DEPLOYMENT_TARGET = 12.0; WATCHOS_DEPLOYMENT_TARGET = 4.0; }; @@ -4902,7 +4905,7 @@ "$(TOOLCHAIN_DIR)/usr/lib/swift/macosx", ); MACOSX_DEPLOYMENT_TARGET = 10.15; - MARKETING_VERSION = 7.3.1; + MARKETING_VERSION = 7.3.2; MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu17 gnu++14"; OTHER_CFLAGS = "$(inherited)"; OTHER_LDFLAGS = "$(inherited)"; @@ -4915,7 +4918,7 @@ SUPPORTS_MACCATALYST = NO; SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO; SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$(inherited)"; - TARGET_NAME = PubNub; + TARGET_NAME = PubNubSDK; TVOS_DEPLOYMENT_TARGET = 12.0; WATCHOS_DEPLOYMENT_TARGET = 4.0; }; @@ -5235,7 +5238,7 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; - OBJ_27 /* Build configuration list for PBXNativeTarget "PubNub" */ = { + OBJ_27 /* Build configuration list for PBXNativeTarget "PubNubSDK" */ = { isa = XCConfigurationList; buildConfigurations = ( OBJ_28 /* Debug */, diff --git a/PubNub.xcodeproj/xcshareddata/xcschemes/PubNub.xcscheme b/PubNub.xcodeproj/xcshareddata/xcschemes/PubNub.xcscheme index 43cdf6d9..ddd6763d 100644 --- a/PubNub.xcodeproj/xcshareddata/xcschemes/PubNub.xcscheme +++ b/PubNub.xcodeproj/xcshareddata/xcschemes/PubNub.xcscheme @@ -15,8 +15,8 @@ @@ -34,8 +34,8 @@ @@ -80,8 +80,8 @@ @@ -96,8 +96,8 @@ diff --git a/PubNubMembership/Sources/Membership+PubNub.swift b/PubNubMembership/Sources/Membership+PubNub.swift index b3005f74..31aece05 100644 --- a/PubNubMembership/Sources/Membership+PubNub.swift +++ b/PubNubMembership/Sources/Membership+PubNub.swift @@ -9,8 +9,7 @@ // import Foundation - -import PubNub +import PubNubSDK import PubNubSpace import PubNubUser diff --git a/PubNubMembership/Sources/Patcher+PubNubMembership.swift b/PubNubMembership/Sources/Patcher+PubNubMembership.swift index 969e2112..52a9e44d 100644 --- a/PubNubMembership/Sources/Patcher+PubNubMembership.swift +++ b/PubNubMembership/Sources/Patcher+PubNubMembership.swift @@ -9,8 +9,7 @@ // import Foundation - -import PubNub +import PubNubSDK import PubNubSpace import PubNubUser diff --git a/PubNubMembership/Sources/PubNubMembership.swift b/PubNubMembership/Sources/PubNubMembership.swift index 5eb25066..c30b78be 100644 --- a/PubNubMembership/Sources/PubNubMembership.swift +++ b/PubNubMembership/Sources/PubNubMembership.swift @@ -9,8 +9,7 @@ // import Foundation - -import PubNub +import PubNubSDK import PubNubSpace import PubNubUser diff --git a/PubNubMembership/Sources/PubNubMembershipEvent.swift b/PubNubMembership/Sources/PubNubMembershipEvent.swift index 911d9cd7..90de0d8b 100644 --- a/PubNubMembership/Sources/PubNubMembershipEvent.swift +++ b/PubNubMembership/Sources/PubNubMembershipEvent.swift @@ -9,8 +9,7 @@ // import Foundation - -import PubNub +import PubNubSDK /// All the changes that can be received for Membership entities public enum PubNubMembershipEvent { diff --git a/PubNubMembership/Tests/Integration/SmokeTest+PubNubMembership.swift b/PubNubMembership/Tests/Integration/SmokeTest+PubNubMembership.swift index 001e6007..49a16b4c 100644 --- a/PubNubMembership/Tests/Integration/SmokeTest+PubNubMembership.swift +++ b/PubNubMembership/Tests/Integration/SmokeTest+PubNubMembership.swift @@ -8,7 +8,7 @@ // LICENSE file in the root directory of this source tree. // -import PubNub +import PubNubSDK import PubNubMembership import PubNubSpace import PubNubUser diff --git a/PubNubMembership/Tests/MembershipTestHelpers.swift b/PubNubMembership/Tests/MembershipTestHelpers.swift index cca7ab77..4abf7f7a 100644 --- a/PubNubMembership/Tests/MembershipTestHelpers.swift +++ b/PubNubMembership/Tests/MembershipTestHelpers.swift @@ -9,8 +9,7 @@ // import Foundation - -import PubNub +import PubNubSDK struct MembershipCustom: FlatJSONCodable, Hashable { var value: String? diff --git a/PubNubMembership/Tests/Test+PubNubMembership.swift b/PubNubMembership/Tests/Test+PubNubMembership.swift index 26c572a0..7ce70d63 100644 --- a/PubNubMembership/Tests/Test+PubNubMembership.swift +++ b/PubNubMembership/Tests/Test+PubNubMembership.swift @@ -8,13 +8,13 @@ // LICENSE file in the root directory of this source tree. // -import PubNub -@testable import PubNubMembership +import PubNubSDK import PubNubSpace import PubNubUser - import XCTest +@testable import PubNubMembership + class PubNubMembershipModelTests: XCTestCase { let testMembership = PubNubMembership( user: PubNubUser(id: "TestUserId"), diff --git a/PubNubMembership/Tests/Test+PubNubMembershipEvent.swift b/PubNubMembership/Tests/Test+PubNubMembershipEvent.swift index 55113b8e..11f1162f 100644 --- a/PubNubMembership/Tests/Test+PubNubMembershipEvent.swift +++ b/PubNubMembership/Tests/Test+PubNubMembershipEvent.swift @@ -8,13 +8,13 @@ // LICENSE file in the root directory of this source tree. // -import PubNub -@testable import PubNubMembership +import PubNubSDK import PubNubSpace import PubNubUser - import XCTest +@testable import PubNubMembership + class PubNubMembershipEventTests: XCTestCase { let testMembership = PubNubMembership( user: PubNubUser(id: "TestUserId"), diff --git a/PubNubMembership/Tests/Test+PubNubMembershipInterface.swift b/PubNubMembership/Tests/Test+PubNubMembershipInterface.swift index c21c469f..9722e067 100644 --- a/PubNubMembership/Tests/Test+PubNubMembershipInterface.swift +++ b/PubNubMembership/Tests/Test+PubNubMembershipInterface.swift @@ -8,13 +8,13 @@ // LICENSE file in the root directory of this source tree. // -import PubNub -@testable import PubNubMembership +import PubNubSDK import PubNubSpace import PubNubUser - import XCTest +@testable import PubNubMembership + // swiftlint:disable:next type_body_length class PubNubMembershipInterfaceTests: XCTestCase { let testMembership = PubNubMembership( diff --git a/PubNubMembership/Tests/Test+PubNubMembershipPatcher.swift b/PubNubMembership/Tests/Test+PubNubMembershipPatcher.swift index 9ad76ae0..8a506743 100644 --- a/PubNubMembership/Tests/Test+PubNubMembershipPatcher.swift +++ b/PubNubMembership/Tests/Test+PubNubMembershipPatcher.swift @@ -8,13 +8,13 @@ // LICENSE file in the root directory of this source tree. // -import PubNub -@testable import PubNubMembership +import PubNubSDK import PubNubSpace import PubNubUser - import XCTest +@testable import PubNubMembership + class PubNubMembershipPatcherTests: XCTestCase { var testMembership = PubNubMembership( user: PubNubUser(id: "TestUserId"), diff --git a/PubNubSpace/Sources/Patcher+PubNubSpace.swift b/PubNubSpace/Sources/Patcher+PubNubSpace.swift index 2e203fb8..f72448d4 100644 --- a/PubNubSpace/Sources/Patcher+PubNubSpace.swift +++ b/PubNubSpace/Sources/Patcher+PubNubSpace.swift @@ -9,8 +9,7 @@ // import Foundation - -import PubNub +import PubNubSDK public extension PubNubSpace { /// Object that can be used to apply an update to another Space diff --git a/PubNubSpace/Sources/PubNubSpace.swift b/PubNubSpace/Sources/PubNubSpace.swift index e7572003..d88107dd 100644 --- a/PubNubSpace/Sources/PubNubSpace.swift +++ b/PubNubSpace/Sources/PubNubSpace.swift @@ -9,8 +9,7 @@ // import Foundation - -import PubNub +import PubNubSDK /// A concrete representation of a Space entity in PubNub public struct PubNubSpace { diff --git a/PubNubSpace/Sources/PubNubSpaceEvent.swift b/PubNubSpace/Sources/PubNubSpaceEvent.swift index d3b731c9..8e1ca31d 100644 --- a/PubNubSpace/Sources/PubNubSpaceEvent.swift +++ b/PubNubSpace/Sources/PubNubSpaceEvent.swift @@ -9,8 +9,7 @@ // import Foundation - -import PubNub +import PubNubSDK public enum PubNubSpaceEvent { /// The changeset for the Space entity that changed diff --git a/PubNubSpace/Sources/Space+PubNub.swift b/PubNubSpace/Sources/Space+PubNub.swift index 7eed572e..13669b12 100644 --- a/PubNubSpace/Sources/Space+PubNub.swift +++ b/PubNubSpace/Sources/Space+PubNub.swift @@ -9,8 +9,7 @@ // import Foundation - -import PubNub +import PubNubSDK /// Protocol interface to manage `PubNubSpace` entities using closures public protocol PubNubSpaceInterface { diff --git a/PubNubSpace/Tests/Integration/SmokeTest+PubNubSpace.swift b/PubNubSpace/Tests/Integration/SmokeTest+PubNubSpace.swift index 3d561ec7..7bd3ebff 100644 --- a/PubNubSpace/Tests/Integration/SmokeTest+PubNubSpace.swift +++ b/PubNubSpace/Tests/Integration/SmokeTest+PubNubSpace.swift @@ -8,11 +8,11 @@ // LICENSE file in the root directory of this source tree. // -import PubNub -@testable import PubNubSpace - +import PubNubSDK import XCTest +@testable import PubNubSpace + class PubNubSpaceInterfaceITests: XCTestCase { let testSpace = PubNubSpace( id: "TestSpaceId", diff --git a/PubNubSpace/Tests/SpaceTestHelpers.swift b/PubNubSpace/Tests/SpaceTestHelpers.swift index 6052aa96..2cfb8f86 100644 --- a/PubNubSpace/Tests/SpaceTestHelpers.swift +++ b/PubNubSpace/Tests/SpaceTestHelpers.swift @@ -9,8 +9,7 @@ // import Foundation - -import PubNub +import PubNubSDK struct SpaceCustom: FlatJSONCodable, Hashable { var value: String? diff --git a/PubNubSpace/Tests/Test+PubNubSpace.swift b/PubNubSpace/Tests/Test+PubNubSpace.swift index 49d1dccd..22001903 100644 --- a/PubNubSpace/Tests/Test+PubNubSpace.swift +++ b/PubNubSpace/Tests/Test+PubNubSpace.swift @@ -8,11 +8,11 @@ // LICENSE file in the root directory of this source tree. // -import PubNub -@testable import PubNubSpace - +import PubNubSDK import XCTest +@testable import PubNubSpace + class PubNubSpaceModelTests: XCTestCase { let testSpace = PubNubSpace( id: "TestSpaceId", diff --git a/PubNubSpace/Tests/Test+PubNubSpaceEvent.swift b/PubNubSpace/Tests/Test+PubNubSpaceEvent.swift index 7d8b03fd..7ef68742 100644 --- a/PubNubSpace/Tests/Test+PubNubSpaceEvent.swift +++ b/PubNubSpace/Tests/Test+PubNubSpaceEvent.swift @@ -8,11 +8,11 @@ // LICENSE file in the root directory of this source tree. // -import PubNub -@testable import PubNubSpace - +import PubNubSDK import XCTest +@testable import PubNubSpace + class PubNubSpaceEventTests: XCTestCase { let testSpace = PubNubSpace( id: "TestSpaceId", diff --git a/PubNubSpace/Tests/Test+PubNubSpaceInterface.swift b/PubNubSpace/Tests/Test+PubNubSpaceInterface.swift index b4464b07..b007fd1b 100644 --- a/PubNubSpace/Tests/Test+PubNubSpaceInterface.swift +++ b/PubNubSpace/Tests/Test+PubNubSpaceInterface.swift @@ -8,11 +8,11 @@ // LICENSE file in the root directory of this source tree. // -import PubNub -@testable import PubNubSpace - +import PubNubSDK import XCTest +@testable import PubNubSpace + class PubNubSpaceInterfaceTests: XCTestCase { let testSpace = PubNubSpace( id: "TestSpaceId", diff --git a/PubNubSpace/Tests/Test+PubNubSpacePatcher.swift b/PubNubSpace/Tests/Test+PubNubSpacePatcher.swift index 0660125e..0f0aec46 100644 --- a/PubNubSpace/Tests/Test+PubNubSpacePatcher.swift +++ b/PubNubSpace/Tests/Test+PubNubSpacePatcher.swift @@ -8,11 +8,11 @@ // LICENSE file in the root directory of this source tree. // -import PubNub -@testable import PubNubSpace - +import PubNubSDK import XCTest +@testable import PubNubSpace + class PubNubSpacePatcherTests: XCTestCase { var testSpace = PubNubSpace( id: "TestSpaceId", diff --git a/PubNubSwift.podspec b/PubNubSwift.podspec index 8a190c9b..e3cdf549 100644 --- a/PubNubSwift.podspec +++ b/PubNubSwift.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'PubNubSwift' - s.version = '7.3.1' + s.version = '7.3.2' s.homepage = 'https://github.com/pubnub/swift' s.documentation_url = 'https://www.pubnub.com/docs/swift-native/pubnub-swift-sdk' s.authors = { 'PubNub, Inc.' => 'support@pubnub.com' } @@ -21,7 +21,7 @@ The PubNub Real-Time Network. Build real-time apps quickly and scale them global s.swift_version = '5.0' - s.module_name = 'PubNub' + s.module_name = 'PubNubSDK' s.source_files = 'Sources/**/*.swift' s.resource_bundles = { "PubNubSwift" => ["Sources/PubNub/PrivacyInfo.xcprivacy"]} diff --git a/PubNubUser/Sources/Patcher+PubNubUser.swift b/PubNubUser/Sources/Patcher+PubNubUser.swift index 2c8fa32d..6d2cbbca 100644 --- a/PubNubUser/Sources/Patcher+PubNubUser.swift +++ b/PubNubUser/Sources/Patcher+PubNubUser.swift @@ -9,8 +9,7 @@ // import Foundation - -import PubNub +import PubNubSDK public extension PubNubUser { /// Object that can be used to apply an update to another User diff --git a/PubNubUser/Sources/PubNubUser.swift b/PubNubUser/Sources/PubNubUser.swift index 40bceade..7054f7a3 100644 --- a/PubNubUser/Sources/PubNubUser.swift +++ b/PubNubUser/Sources/PubNubUser.swift @@ -9,8 +9,7 @@ // import Foundation - -import PubNub +import PubNubSDK /// A concrete representation of a User entity in PubNub public struct PubNubUser { diff --git a/PubNubUser/Sources/PubNubUserEvent.swift b/PubNubUser/Sources/PubNubUserEvent.swift index 871ce3f1..445b03ec 100644 --- a/PubNubUser/Sources/PubNubUserEvent.swift +++ b/PubNubUser/Sources/PubNubUserEvent.swift @@ -9,8 +9,7 @@ // import Foundation - -import PubNub +import PubNubSDK /// All the changes that can be received for User entities public enum PubNubUserEvent { diff --git a/PubNubUser/Sources/User+PubNub.swift b/PubNubUser/Sources/User+PubNub.swift index e14f8762..bb6da9ba 100644 --- a/PubNubUser/Sources/User+PubNub.swift +++ b/PubNubUser/Sources/User+PubNub.swift @@ -9,7 +9,7 @@ // import Foundation -import PubNub +import PubNubSDK /// Protocol interface to manage `PubNubUser` entities using closures public protocol PubNubUserInterface { diff --git a/PubNubUser/Tests/Integration/SmokeTest+PubNubUser.swift b/PubNubUser/Tests/Integration/SmokeTest+PubNubUser.swift index c45e0768..cd6dae07 100644 --- a/PubNubUser/Tests/Integration/SmokeTest+PubNubUser.swift +++ b/PubNubUser/Tests/Integration/SmokeTest+PubNubUser.swift @@ -8,11 +8,11 @@ // LICENSE file in the root directory of this source tree. // -import PubNub -@testable import PubNubUser - +import PubNubSDK import XCTest +@testable import PubNubUser + class PubNubUserInterfaceITests: XCTestCase { let testUser = PubNubUser( id: "TestUserId", diff --git a/PubNubUser/Tests/Test+PubNubUser.swift b/PubNubUser/Tests/Test+PubNubUser.swift index 33fd6dab..340ee4cc 100644 --- a/PubNubUser/Tests/Test+PubNubUser.swift +++ b/PubNubUser/Tests/Test+PubNubUser.swift @@ -8,11 +8,11 @@ // LICENSE file in the root directory of this source tree. // -import PubNub -@testable import PubNubUser - +import PubNubSDK import XCTest +@testable import PubNubUser + class PubNubUserModelTests: XCTestCase { let testUser = PubNubUser( id: "TestUserId", diff --git a/PubNubUser/Tests/Test+PubNubUserEvent.swift b/PubNubUser/Tests/Test+PubNubUserEvent.swift index 12d33c22..70801260 100644 --- a/PubNubUser/Tests/Test+PubNubUserEvent.swift +++ b/PubNubUser/Tests/Test+PubNubUserEvent.swift @@ -8,11 +8,11 @@ // LICENSE file in the root directory of this source tree. // -import PubNub -@testable import PubNubUser - +import PubNubSDK import XCTest +@testable import PubNubUser + class PubNubUserEventTests: XCTestCase { let testUser = PubNubUser( id: "TestUserId", diff --git a/PubNubUser/Tests/Test+PubNubUserInterface.swift b/PubNubUser/Tests/Test+PubNubUserInterface.swift index 34857e23..c6161327 100644 --- a/PubNubUser/Tests/Test+PubNubUserInterface.swift +++ b/PubNubUser/Tests/Test+PubNubUserInterface.swift @@ -8,11 +8,11 @@ // LICENSE file in the root directory of this source tree. // -import PubNub -@testable import PubNubUser - +import PubNubSDK import XCTest +@testable import PubNubUser + class PubNubUserInterfaceTests: XCTestCase { let testUser = PubNubUser( id: "TestUserId", diff --git a/PubNubUser/Tests/Test+PubNubUserPatcher.swift b/PubNubUser/Tests/Test+PubNubUserPatcher.swift index 24081c11..150efe21 100644 --- a/PubNubUser/Tests/Test+PubNubUserPatcher.swift +++ b/PubNubUser/Tests/Test+PubNubUserPatcher.swift @@ -8,11 +8,11 @@ // LICENSE file in the root directory of this source tree. // -import PubNub -@testable import PubNubUser - +import PubNubSDK import XCTest +@testable import PubNubUser + class PubNubUserPatcherTests: XCTestCase { var testUser = PubNubUser( id: "TestUserId", diff --git a/PubNubUser/Tests/UserTestHelpers.swift b/PubNubUser/Tests/UserTestHelpers.swift index e84e81c6..b8d0d931 100644 --- a/PubNubUser/Tests/UserTestHelpers.swift +++ b/PubNubUser/Tests/UserTestHelpers.swift @@ -9,7 +9,7 @@ // import Foundation -import PubNub +import PubNubSDK struct UserCustom: FlatJSONCodable, Hashable { var value: String? diff --git a/README.md b/README.md index 32123bb4..9d0b802f 100644 --- a/README.md +++ b/README.md @@ -87,7 +87,7 @@ carthage update --use-xcframeworks ```swift import UIKit - import PubNub // <- Here is our PubNub module import. + import PubNubSDK // <- Here is our PubNub module import. ``` 1. Create and configure a PubNub object: diff --git a/Sources/PubNub/EventEngine/Subscribe/Effects/EmitMessagesEffect.swift b/Sources/PubNub/EventEngine/Subscribe/Effects/EmitMessagesEffect.swift index a64a1faa..0a8246f8 100644 --- a/Sources/PubNub/EventEngine/Subscribe/Effects/EmitMessagesEffect.swift +++ b/Sources/PubNub/EventEngine/Subscribe/Effects/EmitMessagesEffect.swift @@ -37,14 +37,14 @@ class MessageCache { struct EmitMessagesEffect: EffectHandler { let messages: [SubscribeMessagePayload] let cursor: SubscribeCursor - let listeners: [BaseSubscriptionListener] + let listeners: WeakSet let messageCache: MessageCache func performTask(completionBlock: @escaping ([Subscribe.Event]) -> Void) { // Attempt to detect missed messages due to queue overflow if messages.count >= 100 { listeners.forEach { - $0.emit(subscribe: .errorReceived( + $0?.emit(subscribe: .errorReceived( PubNubError( .messageCountExceededMaximum, router: nil, @@ -68,7 +68,7 @@ struct EmitMessagesEffect: EffectHandler { } listeners.forEach { - $0.emit(batch: filteredMessages) + $0?.emit(batch: filteredMessages) } completionBlock([]) diff --git a/Sources/PubNub/EventEngine/Subscribe/Effects/EmitStatusEffect.swift b/Sources/PubNub/EventEngine/Subscribe/Effects/EmitStatusEffect.swift index bcb2df5d..92fd10e1 100644 --- a/Sources/PubNub/EventEngine/Subscribe/Effects/EmitStatusEffect.swift +++ b/Sources/PubNub/EventEngine/Subscribe/Effects/EmitStatusEffect.swift @@ -11,16 +11,16 @@ import Foundation struct EmitStatusEffect: EffectHandler { let statusChange: Subscribe.ConnectionStatusChange - let listeners: [BaseSubscriptionListener] + let listeners: WeakSet func performTask(completionBlock: @escaping ([Subscribe.Event]) -> Void) { if let error = statusChange.error { listeners.forEach { - $0.emit(subscribe: .errorReceived(error)) + $0?.emit(subscribe: .errorReceived(error)) } } listeners.forEach { - $0.emit(subscribe: .connectionChanged(statusChange.newStatus)) + $0?.emit(subscribe: .connectionChanged(statusChange.newStatus)) } completionBlock([]) } diff --git a/Sources/PubNub/EventEngine/Subscribe/Effects/SubscribeEffects.swift b/Sources/PubNub/EventEngine/Subscribe/Effects/SubscribeEffects.swift index 02035957..049c65cb 100644 --- a/Sources/PubNub/EventEngine/Subscribe/Effects/SubscribeEffects.swift +++ b/Sources/PubNub/EventEngine/Subscribe/Effects/SubscribeEffects.swift @@ -15,7 +15,7 @@ import Foundation class HandshakeEffect: EffectHandler { private let subscribeEffect: SubscribeEffect - init(request: SubscribeRequest, listeners: [BaseSubscriptionListener]) { + init(request: SubscribeRequest, listeners: WeakSet) { self.subscribeEffect = SubscribeEffect( request: request, listeners: listeners, @@ -25,7 +25,6 @@ class HandshakeEffect: EffectHandler { } func performTask(completionBlock: @escaping ([Subscribe.Event]) -> Void) { - subscribeEffect.listeners.forEach { $0.emit(subscribe: .connectionChanged(.connecting)) } subscribeEffect.performTask(completionBlock: completionBlock) } @@ -43,7 +42,7 @@ class HandshakeEffect: EffectHandler { class ReceivingEffect: EffectHandler { private let subscribeEffect: SubscribeEffect - init(request: SubscribeRequest, listeners: [BaseSubscriptionListener]) { + init(request: SubscribeRequest, listeners: WeakSet) { self.subscribeEffect = SubscribeEffect( request: request, listeners: listeners, @@ -69,13 +68,13 @@ class ReceivingEffect: EffectHandler { private class SubscribeEffect: EffectHandler { let request: SubscribeRequest - let listeners: [BaseSubscriptionListener] + let listeners: WeakSet let onResponseReceived: (SubscribeResponse) -> Subscribe.Event let onErrorReceived: (PubNubError) -> Subscribe.Event init( request: SubscribeRequest, - listeners: [BaseSubscriptionListener], + listeners: WeakSet, onResponseReceived: @escaping ((SubscribeResponse) -> Subscribe.Event), onErrorReceived: @escaping ((PubNubError) -> Subscribe.Event) ) { @@ -91,7 +90,7 @@ private class SubscribeEffect: EffectHandler { switch $0 { case .success(let response): selfRef.listeners.forEach { - $0.emit(subscribe: .responseReceived( + $0?.emit(subscribe: .responseReceived( SubscribeResponseHeader( channels: selfRef.request.channels.map { PubNubChannel(channel: $0) }, groups: selfRef.request.groups.map { PubNubChannel(channel: $0) }, diff --git a/Sources/PubNub/EventEngine/Subscribe/Subscribe.swift b/Sources/PubNub/EventEngine/Subscribe/Subscribe.swift index e3063dd5..e9b7d64f 100644 --- a/Sources/PubNub/EventEngine/Subscribe/Subscribe.swift +++ b/Sources/PubNub/EventEngine/Subscribe/Subscribe.swift @@ -35,7 +35,7 @@ extension Subscribe { struct HandshakingState: SubscribeState { let input: SubscribeInput let cursor: SubscribeCursor - let connectionStatus = ConnectionStatus.connecting + let connectionStatus = ConnectionStatus.disconnected } struct HandshakeStoppedState: SubscribeState { @@ -61,7 +61,7 @@ extension Subscribe { struct ReceivingState: SubscribeState { let input: SubscribeInput let cursor: SubscribeCursor - let connectionStatus = ConnectionStatus.connected + let connectionStatus: ConnectionStatus } struct ReceiveStoppedState: SubscribeState { @@ -119,9 +119,12 @@ extension Subscribe { extension Subscribe { struct Dependencies { let configuration: PubNubConfiguration - let listeners: [BaseSubscriptionListener] + let listeners: WeakSet - init(configuration: PubNubConfiguration, listeners: [BaseSubscriptionListener] = []) { + init( + configuration: PubNubConfiguration, + listeners: WeakSet = WeakSet([]) + ) { self.configuration = configuration self.listeners = listeners } diff --git a/Sources/PubNub/EventEngine/Subscribe/SubscribeTransition.swift b/Sources/PubNub/EventEngine/Subscribe/SubscribeTransition.swift index ef076916..70747648 100644 --- a/Sources/PubNub/EventEngine/Subscribe/SubscribeTransition.swift +++ b/Sources/PubNub/EventEngine/Subscribe/SubscribeTransition.swift @@ -140,25 +140,64 @@ fileprivate extension SubscribeTransition { if newInput.isEmpty { return setUnsubscribedState(from: state) - } else { - switch state { - case is Subscribe.HandshakingState: - return TransitionResult(state: Subscribe.HandshakingState(input: newInput, cursor: cursor)) - case is Subscribe.HandshakeStoppedState: - return TransitionResult(state: Subscribe.HandshakeStoppedState(input: newInput, cursor: cursor)) - case is Subscribe.HandshakeFailedState: - return TransitionResult(state: Subscribe.HandshakingState(input: newInput, cursor: cursor)) - case is Subscribe.ReceivingState: - return TransitionResult(state: Subscribe.ReceivingState(input: newInput, cursor: cursor)) - case is Subscribe.ReceiveStoppedState: - return TransitionResult(state: Subscribe.ReceiveStoppedState(input: newInput, cursor: cursor)) - case is Subscribe.ReceiveFailedState: - return TransitionResult(state: Subscribe.HandshakingState(input: newInput, cursor: cursor)) - case is Subscribe.UnsubscribedState: - return TransitionResult(state: Subscribe.HandshakingState(input: newInput, cursor: cursor)) - default: - return TransitionResult(state: state) - } + } + + let invocations: [EffectInvocation] = state is Subscribe.ReceivingState ? [ + .regular(.emitStatus(change: Subscribe.ConnectionStatusChange( + oldStatus: state.connectionStatus, + newStatus: .subscriptionChanged( + channels: newInput.subscribedChannelNames, + groups: newInput.subscribedGroupNames + ), + error: nil + ))) + ] : [] + + switch state { + case is Subscribe.HandshakingState: + return TransitionResult( + state: Subscribe.HandshakingState(input: newInput, cursor: cursor), + invocations: invocations + ) + case is Subscribe.HandshakeStoppedState: + return TransitionResult( + state: Subscribe.HandshakeStoppedState(input: newInput, cursor: cursor), + invocations: invocations + ) + case is Subscribe.HandshakeFailedState: + return TransitionResult( + state: Subscribe.HandshakingState(input: newInput, cursor: cursor), + invocations: invocations + ) + case is Subscribe.ReceivingState: + let newStatus: ConnectionStatus = .subscriptionChanged( + channels: newInput.subscribedChannelNames, + groups: newInput.subscribedGroupNames + ) + return TransitionResult( + state: Subscribe.ReceivingState(input: newInput, cursor: cursor, connectionStatus: newStatus), + invocations: invocations + ) + case is Subscribe.ReceiveStoppedState: + return TransitionResult( + state: Subscribe.ReceiveStoppedState(input: newInput, cursor: cursor), + invocations: invocations + ) + case is Subscribe.ReceiveFailedState: + return TransitionResult( + state: Subscribe.HandshakingState(input: newInput, cursor: cursor), + invocations: invocations + ) + case is Subscribe.UnsubscribedState: + return TransitionResult( + state: Subscribe.HandshakingState(input: newInput, cursor: cursor), + invocations: invocations + ) + default: + return TransitionResult( + state: state, + invocations: invocations + ) } } } @@ -202,27 +241,30 @@ fileprivate extension SubscribeTransition { messages: [SubscribeMessagePayload] = [] ) -> TransitionResult { let emitMessagesInvocation = EffectInvocation.managed( - Subscribe.Invocation.emitMessages(events: messages, forCursor: cursor) - ) - let emitStatusInvocation = EffectInvocation.regular( - Subscribe.Invocation.emitStatus(change: Subscribe.ConnectionStatusChange( - oldStatus: state.connectionStatus, - newStatus: .connected, - error: nil - )) + Subscribe.Invocation.emitMessages( + events: messages, + forCursor: cursor + ) ) if state is Subscribe.HandshakingState { - return TransitionResult( - state: Subscribe.ReceivingState(input: state.input, cursor: cursor), - invocations: [messages.isEmpty ? nil : emitMessagesInvocation, emitStatusInvocation].compactMap { $0 } + let emitStatusInvocation = EffectInvocation.regular( + Subscribe.Invocation.emitStatus(change: Subscribe.ConnectionStatusChange( + oldStatus: state.connectionStatus, + newStatus: .connected, + error: nil + )) ) - } else { return TransitionResult( - state: Subscribe.ReceivingState(input: state.input, cursor: cursor), - invocations: [messages.isEmpty ? nil : emitMessagesInvocation].compactMap { $0 } + state: Subscribe.ReceivingState(input: state.input, cursor: cursor, connectionStatus: .connected), + invocations: [messages.isEmpty ? nil : emitMessagesInvocation, emitStatusInvocation].compactMap { $0 } ) } + + return TransitionResult( + state: Subscribe.ReceivingState(input: state.input, cursor: cursor, connectionStatus: state.connectionStatus), + invocations: [messages.isEmpty ? nil : emitMessagesInvocation].compactMap { $0 } + ) } } diff --git a/Sources/PubNub/Events/New/Subscription.swift b/Sources/PubNub/Events/New/Subscription.swift index 878649c7..885bc3e2 100644 --- a/Sources/PubNub/Events/New/Subscription.swift +++ b/Sources/PubNub/Events/New/Subscription.swift @@ -142,7 +142,6 @@ extension Subscription: SubscribeCapable { let channels = subscriptionType == .channel ? [self] : [] let channelGroups = subscriptionType == .channelGroup ? [self] : [] - pubnub.registerAdapter(adapter) pubnub.internalSubscribe(with: channels, and: channelGroups, at: timetoken) } diff --git a/Sources/PubNub/Events/New/SubscriptionSet.swift b/Sources/PubNub/Events/New/SubscriptionSet.swift index 749f37fe..36d2dd20 100644 --- a/Sources/PubNub/Events/New/SubscriptionSet.swift +++ b/Sources/PubNub/Events/New/SubscriptionSet.swift @@ -173,7 +173,6 @@ extension SubscriptionSet: SubscribeCapable { return } pubnub.registerAdapter(adapter) - currentSubscriptions.forEach { pubnub.registerAdapter($0.adapter) } let channels = currentSubscriptions.filter { $0.subscriptionType == .channel @@ -200,6 +199,7 @@ extension SubscriptionSet: SubscribeCapable { guard let pubnub = currentSubscriptions.first?.pubnub, !isDisposed else { return } + pubnub.subscription.remove(adapter) pubnub.internalUnsubscribe( from: currentSubscriptions.filter { $0.subscriptionType == .channel }, and: currentSubscriptions.filter { $0.subscriptionType == .channelGroup }, diff --git a/Sources/PubNub/Helpers/Constants.swift b/Sources/PubNub/Helpers/Constants.swift index 512ff8ed..a34ef409 100644 --- a/Sources/PubNub/Helpers/Constants.swift +++ b/Sources/PubNub/Helpers/Constants.swift @@ -57,7 +57,7 @@ public enum Constant { static let pubnubSwiftSDKName: String = "PubNubSwift" - static let pubnubSwiftSDKVersion: String = "7.3.1" + static let pubnubSwiftSDKVersion: String = "7.3.2" static let appBundleId: String = { if let info = Bundle.main.infoDictionary, diff --git a/Sources/PubNub/Helpers/Crypto/Cryptors/Cryptor.swift b/Sources/PubNub/Helpers/Crypto/Cryptors/Cryptor.swift index edd95574..6d266fb5 100644 --- a/Sources/PubNub/Helpers/Crypto/Cryptors/Cryptor.swift +++ b/Sources/PubNub/Helpers/Crypto/Cryptors/Cryptor.swift @@ -14,19 +14,30 @@ import Foundation /// Represents the result of encrypted `Data` public struct EncryptedData { /// Metadata (if any) used while encrypting - let metadata: Data + public let metadata: Data /// Resulting encrypted `Data` - let data: Data + public let data: Data + + public init(metadata: Data, data: Data) { + self.metadata = metadata + self.data = data + } } /// Represents the result of encrypted `InputStream` public struct EncryptedStreamData { /// Encrypted stream you can read from - let stream: InputStream + public let stream: InputStream /// Content length of encrypted stream - let contentLength: Int + public let contentLength: Int /// Metadata (if any) used while encrypting - let metadata: Data + public let metadata: Data + + public init(stream: InputStream, contentLength: Int, metadata: Data) { + self.stream = stream + self.contentLength = contentLength + self.metadata = metadata + } } /// Typealias for uniquely identifying applied encryption diff --git a/Sources/PubNub/Subscription/ConnectionStatus.swift b/Sources/PubNub/Subscription/ConnectionStatus.swift index 4ddb5d56..55f43b29 100644 --- a/Sources/PubNub/Subscription/ConnectionStatus.swift +++ b/Sources/PubNub/Subscription/ConnectionStatus.swift @@ -12,25 +12,22 @@ import Foundation /// Status of a connection to a remote system public enum ConnectionStatus: Equatable { - /// Attempting to connect to a remote system - @available(*, deprecated, message: "This case will be removed in future versions") - case connecting /// Successfully connected to a remote system case connected /// Explicit disconnect from a remote system case disconnected - /// Attempting to reconnect to a remote system - @available(*, deprecated, message: "This case will be removed in future versions") - case reconnecting /// Unexpected disconnect from a remote system case disconnectedUnexpectedly(PubNubError) /// Unable to establish initial connection. Applies if `enableEventEngine` in `PubNubConfiguration` is true. case connectionError(PubNubError) + /// SDK subscribed with a new mix of channels (fired every time the channel/channel group mix changed) + /// since the initial connection + case subscriptionChanged(channels: [String], groups: [String]) /// If the connection is connected or attempting to connect public var isActive: Bool { switch self { - case .connecting, .connected, .reconnecting: + case .connected, .subscriptionChanged: return true default: return false @@ -41,37 +38,52 @@ public enum ConnectionStatus: Equatable { public var isConnected: Bool { if case .connected = self { return true + } else if case .subscriptionChanged = self { + return true } else { return false } } + public static func == (lhs: ConnectionStatus, rhs: ConnectionStatus) -> Bool { + switch (lhs, rhs) { + case (.connected, .connected): + return true + case (.disconnected, .disconnected): + return true + case let (.disconnectedUnexpectedly(lhsError), .disconnectedUnexpectedly(rhsError)): + return lhsError == rhsError + case let (.connectionError(lhsError), .connectionError(rhsError)): + return lhsError == rhsError + case let (.subscriptionChanged(lhsChannels, lhsGroups), .subscriptionChanged(rhsChannels, rhsGroups)): + return Set(lhsChannels) == Set(rhsChannels) && Set(lhsGroups) == Set(rhsGroups) + default: + return false + } + } + // swiftlint:disable:next cyclomatic_complexity func canTransition(to state: ConnectionStatus) -> Bool { switch (self, state) { - case (.connecting, .connected): - return true - case (.connecting, .disconnected): + case (.disconnected, .connected): return true - case (.connecting, .disconnectedUnexpectedly): + case (.disconnected, .connectionError): return true - case (.connecting, .connectionError): + case (.disconnected, .disconnectedUnexpectedly): return true - case (.connected, .disconnected): - return true - case (.reconnecting, .connected): + case (.disconnectedUnexpectedly, .connected): return true - case (.reconnecting, .disconnected): + case (.disconnectedUnexpectedly, .disconnected): return true - case (.reconnecting, .disconnectedUnexpectedly): + case (.connected, .subscriptionChanged): return true - case (.reconnecting, .connectionError): + case (.connected, .disconnected): return true - case (.disconnected, .connecting): + case (.connected, .disconnectedUnexpectedly): return true - case (.disconnectedUnexpectedly, .connecting): + case (.subscriptionChanged, .disconnectedUnexpectedly): return true - case (.connectionError, .connecting): + case (.subscriptionChanged, .disconnected): return true default: return false diff --git a/Sources/PubNub/Subscription/Strategy/EventEngineSubscriptionSessionStrategy.swift b/Sources/PubNub/Subscription/Strategy/EventEngineSubscriptionSessionStrategy.swift index abe084d5..89ccd1dc 100644 --- a/Sources/PubNub/Subscription/Strategy/EventEngineSubscriptionSessionStrategy.swift +++ b/Sources/PubNub/Subscription/Strategy/EventEngineSubscriptionSessionStrategy.swift @@ -76,7 +76,7 @@ class EventEngineSubscriptionSessionStrategy: SubscriptionSessionStrategy { subscribeEngine.dependencies = EventEngineDependencies( value: Subscribe.Dependencies( configuration: configuration, - listeners: listeners.allObjects + listeners: listeners ) ) } diff --git a/Sources/PubNub/Subscription/Strategy/LegacySubscriptionSessionStrategy.swift b/Sources/PubNub/Subscription/Strategy/LegacySubscriptionSessionStrategy.swift index a33384f0..a55b86b2 100644 --- a/Sources/PubNub/Subscription/Strategy/LegacySubscriptionSessionStrategy.swift +++ b/Sources/PubNub/Subscription/Strategy/LegacySubscriptionSessionStrategy.swift @@ -73,7 +73,6 @@ class LegacySubscriptionSessionStrategy: SubscriptionSessionStrategy { presenceSession: SessionReplaceable ) { self.configuration = configuration - var mutableSession = subscribeSession filterExpression = configuration.filterExpression nonSubscribeSession = presenceSession @@ -82,21 +81,9 @@ class LegacySubscriptionSessionStrategy: SubscriptionSessionStrategy { sessionStream = SessionListener(queue: responseQueue) // Add listener to session + var mutableSession = subscribeSession mutableSession.sessionStream = sessionStream longPollingSession = mutableSession - - sessionStream.didRetryRequest = { [weak self] _ in - self?.connectionStatus = .reconnecting - } - - sessionStream.sessionDidReceiveChallenge = { [weak self] _, _ in - if self?.connectionStatus == .reconnecting { - // Delay time for server to process connection after TLS handshake - DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 0.05) { - self?.connectionStatus = .connected - } - } - } } deinit { @@ -130,7 +117,6 @@ class LegacySubscriptionSessionStrategy: SubscriptionSessionStrategy { /// - parameter timetoken: The timetoken to subscribe with func reconnect(at cursor: SubscribeCursor? = nil) { if !connectionStatus.isActive { - connectionStatus = .connecting // Start subscribe loop performSubscribeLoop(at: cursor) // Start presence heartbeat diff --git a/Sources/PubNub/Subscription/SubscriptionSession.swift b/Sources/PubNub/Subscription/SubscriptionSession.swift index d174f162..39acdee1 100644 --- a/Sources/PubNub/Subscription/SubscriptionSession.swift +++ b/Sources/PubNub/Subscription/SubscriptionSession.swift @@ -116,13 +116,13 @@ class SubscriptionSession: EventListenerInterface, StatusListenerInterface { withPresence: Bool = false, using pubnub: PubNub ) { - let channelSubscriptions = channels.compactMap { + let channelSubscriptions = Set(channels).compactMap { pubnub.channel($0).subscription( queue: queue, options: withPresence ? ReceivePresenceEvents() : SubscriptionOptions.empty() ) } - let channelGroupSubscriptions = groups.compactMap { + let channelGroupSubscriptions = Set(groups).compactMap { pubnub.channelGroup($0).subscription( queue: queue, options: withPresence ? ReceivePresenceEvents() : SubscriptionOptions.empty() @@ -299,7 +299,8 @@ extension SubscriptionSession { ) } - // Returns an array of subscriptions that subscribe to at least one name in common with the given Subscription + // Returns an array of subscriptions, excluding the given subscription and the global listener, + // that subscribe to at least one name in common with the given subscription func matchingSubscriptions(for subscription: Subscription, presenceOnly: Bool) -> [SubscribeMessagesReceiver] { let allSubscriptions = strategy.listeners.compactMap { $0 as? BaseSubscriptionListenerAdapter @@ -307,15 +308,14 @@ extension SubscriptionSession { let namesToFind = subscription.subscriptionNames.filter { presenceOnly ? $0.isPresenceChannelName : true } - - return allSubscriptions.filter { - $0.uuid != subscription.uuid && $0.uuid != globalEventsListener.uuid - }.compactMap { - $0.receiver - }.filter { - ($0.subscriptionTopology[subscription.subscriptionType] ?? [String]()).contains { - namesToFind.contains($0) + return allSubscriptions.compactMap { + if $0.uuid != subscription.uuid && $0.uuid != globalEventsListener.uuid { + return $0.receiver + } else { + return nil } + }.filter { + !(Set($0.subscriptionTopology[subscription.subscriptionType] ?? []).intersection(namesToFind).isEmpty) } } @@ -342,14 +342,7 @@ extension SubscriptionSession { } let channels = presenceItemsOnly ? [] : Set(subscriptions.filter { - matchingSubscriptions( - for: $0, - presenceOnly: false - ).isEmpty && - matchingSubscriptions( - for: $0, - presenceOnly: true - ).isEmpty + matchingSubscriptions(for: $0, presenceOnly: false).isEmpty && matchingSubscriptions(for: $0, presenceOnly: true).isEmpty }.flatMap { $0.subscriptionNames }).symmetricDifference(presenceItems.map { diff --git a/Tests/PubNubContractTest/PubNubContractTestCase.swift b/Tests/PubNubContractTest/PubNubContractTestCase.swift index f0883b3d..bec9fba2 100644 --- a/Tests/PubNubContractTest/PubNubContractTestCase.swift +++ b/Tests/PubNubContractTest/PubNubContractTestCase.swift @@ -10,7 +10,7 @@ import Cucumberish import Foundation -import PubNub +import PubNubSDK // Origin which should be used to reach mock server for contract testing. let mockServerAddress = "localhost:8090" diff --git a/Tests/PubNubContractTest/Steps/Access/PubNubAccessContractTestSteps.swift b/Tests/PubNubContractTest/Steps/Access/PubNubAccessContractTestSteps.swift index ce4035b1..7d14a3b5 100644 --- a/Tests/PubNubContractTest/Steps/Access/PubNubAccessContractTestSteps.swift +++ b/Tests/PubNubContractTest/Steps/Access/PubNubAccessContractTestSteps.swift @@ -10,7 +10,7 @@ import Cucumberish import Foundation -import PubNub +import PubNubSDK import XCTest public class PubNubAccessContractTestSteps: PubNubContractTestCase { diff --git a/Tests/PubNubContractTest/Steps/CryptorModule/PubNubCryptoModuleContractTestSteps.swift b/Tests/PubNubContractTest/Steps/CryptorModule/PubNubCryptoModuleContractTestSteps.swift index 7d45ad30..c15f2bc6 100644 --- a/Tests/PubNubContractTest/Steps/CryptorModule/PubNubCryptoModuleContractTestSteps.swift +++ b/Tests/PubNubContractTest/Steps/CryptorModule/PubNubCryptoModuleContractTestSteps.swift @@ -13,7 +13,7 @@ import Foundation import XCTest import CommonCrypto -@testable import PubNub +@testable import PubNubSDK public class PubNubCryptoModuleContractTestSteps: PubNubContractTestCase { var cryptorKind: String! diff --git a/Tests/PubNubContractTest/Steps/EventEngine/PubNubEventEngineContractTestSteps.swift b/Tests/PubNubContractTest/Steps/EventEngine/PubNubEventEngineContractTestSteps.swift index 05ead904..62e038e1 100644 --- a/Tests/PubNubContractTest/Steps/EventEngine/PubNubEventEngineContractTestSteps.swift +++ b/Tests/PubNubContractTest/Steps/EventEngine/PubNubEventEngineContractTestSteps.swift @@ -11,7 +11,7 @@ import Foundation import Cucumberish -@testable import PubNub +@testable import PubNubSDK class PubNubEventEngineContractTestsSteps: PubNubContractTestCase { func extractExpectedResults(from: [AnyHashable: Any]?) -> (events: [String], invocations: [String]) { diff --git a/Tests/PubNubContractTest/Steps/EventEngine/PubNubEventEngineTestsHelpers.swift b/Tests/PubNubContractTest/Steps/EventEngine/PubNubEventEngineTestsHelpers.swift index 321266aa..838231b5 100644 --- a/Tests/PubNubContractTest/Steps/EventEngine/PubNubEventEngineTestsHelpers.swift +++ b/Tests/PubNubContractTest/Steps/EventEngine/PubNubEventEngineTestsHelpers.swift @@ -10,7 +10,7 @@ import Foundation -@testable import PubNub +@testable import PubNubSDK protocol ContractTestIdentifiable { var contractTestIdentifier: String { get } diff --git a/Tests/PubNubContractTest/Steps/EventEngine/PubNubPresenceEngineContractTestSteps.swift b/Tests/PubNubContractTest/Steps/EventEngine/PubNubPresenceEngineContractTestSteps.swift index 490ef513..a28e73a8 100644 --- a/Tests/PubNubContractTest/Steps/EventEngine/PubNubPresenceEngineContractTestSteps.swift +++ b/Tests/PubNubContractTest/Steps/EventEngine/PubNubPresenceEngineContractTestSteps.swift @@ -11,7 +11,7 @@ import Cucumberish import Foundation -@testable import PubNub +@testable import PubNubSDK extension Presence.Invocation: ContractTestIdentifiable { var contractTestIdentifier: String { diff --git a/Tests/PubNubContractTest/Steps/EventEngine/PubNubSubscribeEngineContractTestsSteps.swift b/Tests/PubNubContractTest/Steps/EventEngine/PubNubSubscribeEngineContractTestsSteps.swift index 8e219622..5b65bb57 100644 --- a/Tests/PubNubContractTest/Steps/EventEngine/PubNubSubscribeEngineContractTestsSteps.swift +++ b/Tests/PubNubContractTest/Steps/EventEngine/PubNubSubscribeEngineContractTestsSteps.swift @@ -11,7 +11,7 @@ import Cucumberish import Foundation -@testable import PubNub +@testable import PubNubSDK extension Subscribe.Invocation: ContractTestIdentifiable { var contractTestIdentifier: String { diff --git a/Tests/PubNubContractTest/Steps/Files/PubNubFilesContractTestSteps.swift b/Tests/PubNubContractTest/Steps/Files/PubNubFilesContractTestSteps.swift index 0f907a32..8de81dfe 100644 --- a/Tests/PubNubContractTest/Steps/Files/PubNubFilesContractTestSteps.swift +++ b/Tests/PubNubContractTest/Steps/Files/PubNubFilesContractTestSteps.swift @@ -10,7 +10,7 @@ import Cucumberish import Foundation -import PubNub +import PubNubSDK public class PubNubFilesContractTestSteps: PubNubContractTestCase { override public func setup() { diff --git a/Tests/PubNubContractTest/Steps/History/PubNubHistoryContractTestSteps.swift b/Tests/PubNubContractTest/Steps/History/PubNubHistoryContractTestSteps.swift index 3c1cc2e3..e0721ee4 100644 --- a/Tests/PubNubContractTest/Steps/History/PubNubHistoryContractTestSteps.swift +++ b/Tests/PubNubContractTest/Steps/History/PubNubHistoryContractTestSteps.swift @@ -10,7 +10,7 @@ import Cucumberish import Foundation -import PubNub +import PubNubSDK public class PubNubHistoryContractTestSteps: PubNubContractTestCase { override public func setup() { diff --git a/Tests/PubNubContractTest/Steps/Message Actions/PubNubMessageActionsContractTestSteps.swift b/Tests/PubNubContractTest/Steps/Message Actions/PubNubMessageActionsContractTestSteps.swift index 41ea0f10..deffd1cf 100644 --- a/Tests/PubNubContractTest/Steps/Message Actions/PubNubMessageActionsContractTestSteps.swift +++ b/Tests/PubNubContractTest/Steps/Message Actions/PubNubMessageActionsContractTestSteps.swift @@ -10,7 +10,7 @@ import Cucumberish import Foundation -import PubNub +import PubNubSDK public class PubNubMessageActionsContractTestSteps: PubNubContractTestCase { override public func setup() { diff --git a/Tests/PubNubContractTest/Steps/Objects/PubNubObjectsChannelMetadataContractTestSteps.swift b/Tests/PubNubContractTest/Steps/Objects/PubNubObjectsChannelMetadataContractTestSteps.swift index f23e0565..552992d7 100644 --- a/Tests/PubNubContractTest/Steps/Objects/PubNubObjectsChannelMetadataContractTestSteps.swift +++ b/Tests/PubNubContractTest/Steps/Objects/PubNubObjectsChannelMetadataContractTestSteps.swift @@ -10,7 +10,7 @@ import Cucumberish import Foundation -import PubNub +import PubNubSDK import XCTest public class PubNubObjectsChannelMetadataContractTestSteps: PubNubObjectsContractTests { diff --git a/Tests/PubNubContractTest/Steps/Objects/PubNubObjectsContractTests.swift b/Tests/PubNubContractTest/Steps/Objects/PubNubObjectsContractTests.swift index f79e6697..831b413d 100644 --- a/Tests/PubNubContractTest/Steps/Objects/PubNubObjectsContractTests.swift +++ b/Tests/PubNubContractTest/Steps/Objects/PubNubObjectsContractTests.swift @@ -10,7 +10,7 @@ import Cucumberish import Foundation -import PubNub +import PubNubSDK @objc public class PubNubObjectsContractTests: PubNubContractTestCase { public static var membershipMetadata: [String: PubNubTestMembershipForAction?] = [:] diff --git a/Tests/PubNubContractTest/Steps/Objects/PubNubObjectsMembersContractTestSteps.swift b/Tests/PubNubContractTest/Steps/Objects/PubNubObjectsMembersContractTestSteps.swift index 81099775..9f774825 100644 --- a/Tests/PubNubContractTest/Steps/Objects/PubNubObjectsMembersContractTestSteps.swift +++ b/Tests/PubNubContractTest/Steps/Objects/PubNubObjectsMembersContractTestSteps.swift @@ -10,7 +10,7 @@ import Cucumberish import Foundation -import PubNub +import PubNubSDK import XCTest public class PubNubObjectsMembersContractTestSteps: PubNubObjectsContractTests { diff --git a/Tests/PubNubContractTest/Steps/Objects/PubNubObjectsMembershipsContractTestSteps.swift b/Tests/PubNubContractTest/Steps/Objects/PubNubObjectsMembershipsContractTestSteps.swift index f9e793ef..882fa2a6 100644 --- a/Tests/PubNubContractTest/Steps/Objects/PubNubObjectsMembershipsContractTestSteps.swift +++ b/Tests/PubNubContractTest/Steps/Objects/PubNubObjectsMembershipsContractTestSteps.swift @@ -10,7 +10,7 @@ import Cucumberish import Foundation -import PubNub +import PubNubSDK import XCTest public class PubNubObjectsMembershipsContractTestSteps: PubNubObjectsContractTests { diff --git a/Tests/PubNubContractTest/Steps/Objects/PubNubObjectsTestHelpers.swift b/Tests/PubNubContractTest/Steps/Objects/PubNubObjectsTestHelpers.swift index 9b5a3249..adbd75e6 100644 --- a/Tests/PubNubContractTest/Steps/Objects/PubNubObjectsTestHelpers.swift +++ b/Tests/PubNubContractTest/Steps/Objects/PubNubObjectsTestHelpers.swift @@ -9,7 +9,7 @@ // import Foundation -import PubNub +import PubNubSDK extension PubNubContractTestCase { /// Use entity name to compose path on JSON with it's representation. diff --git a/Tests/PubNubContractTest/Steps/Objects/PubNubObjectsUUIDMetadataContractTestSteps.swift b/Tests/PubNubContractTest/Steps/Objects/PubNubObjectsUUIDMetadataContractTestSteps.swift index 5ce0fbee..cbce935b 100644 --- a/Tests/PubNubContractTest/Steps/Objects/PubNubObjectsUUIDMetadataContractTestSteps.swift +++ b/Tests/PubNubContractTest/Steps/Objects/PubNubObjectsUUIDMetadataContractTestSteps.swift @@ -10,7 +10,7 @@ import Cucumberish import Foundation -import PubNub +import PubNubSDK import XCTest public class PubNubObjectsUUIDMetadataContractTestSteps: PubNubObjectsContractTests { diff --git a/Tests/PubNubContractTest/Steps/Publish/PubNubPublishContractTestSteps.swift b/Tests/PubNubContractTest/Steps/Publish/PubNubPublishContractTestSteps.swift index 115876d3..633171a9 100644 --- a/Tests/PubNubContractTest/Steps/Publish/PubNubPublishContractTestSteps.swift +++ b/Tests/PubNubContractTest/Steps/Publish/PubNubPublishContractTestSteps.swift @@ -10,7 +10,7 @@ import Cucumberish import Foundation -import PubNub +import PubNubSDK public class PubNubPublishContractTestSteps: PubNubContractTestCase { override public func setup() { diff --git a/Tests/PubNubContractTest/Steps/Push/PubNubPushContractTestSteps.swift b/Tests/PubNubContractTest/Steps/Push/PubNubPushContractTestSteps.swift index e5d1709c..61c7af80 100644 --- a/Tests/PubNubContractTest/Steps/Push/PubNubPushContractTestSteps.swift +++ b/Tests/PubNubContractTest/Steps/Push/PubNubPushContractTestSteps.swift @@ -10,7 +10,7 @@ import Cucumberish import Foundation -import PubNub +import PubNubSDK public class PubNubPushContractTestSteps: PubNubContractTestCase { override public func setup() { diff --git a/Tests/PubNubContractTest/Steps/Subscribe/PubNubSubscribeContractTestSteps.swift b/Tests/PubNubContractTest/Steps/Subscribe/PubNubSubscribeContractTestSteps.swift index 6f019fb2..0713ebe9 100644 --- a/Tests/PubNubContractTest/Steps/Subscribe/PubNubSubscribeContractTestSteps.swift +++ b/Tests/PubNubContractTest/Steps/Subscribe/PubNubSubscribeContractTestSteps.swift @@ -10,7 +10,7 @@ import Cucumberish import Foundation -import PubNub +import PubNubSDK public class PubNubSubscribeContractTestSteps: PubNubContractTestCase { fileprivate var cryptoModule: CryptoModule? diff --git a/Tests/PubNubContractTest/Steps/Utilities/PubNubTimeContractTestSteps.swift b/Tests/PubNubContractTest/Steps/Utilities/PubNubTimeContractTestSteps.swift index ebcd2ce3..1fccee13 100644 --- a/Tests/PubNubContractTest/Steps/Utilities/PubNubTimeContractTestSteps.swift +++ b/Tests/PubNubContractTest/Steps/Utilities/PubNubTimeContractTestSteps.swift @@ -10,7 +10,7 @@ import Cucumberish import Foundation -import PubNub +import PubNubSDK public class PubNubTimeContractTestSteps: PubNubContractTestCase { override public func setup() { diff --git a/Tests/PubNubTests/EventEngine/DispatcherTests.swift b/Tests/PubNubTests/EventEngine/DispatcherTests.swift index c1989c5d..a595347f 100644 --- a/Tests/PubNubTests/EventEngine/DispatcherTests.swift +++ b/Tests/PubNubTests/EventEngine/DispatcherTests.swift @@ -11,7 +11,7 @@ import Foundation import XCTest -@testable import PubNub +@testable import PubNubSDK class DispatcherTests: XCTestCase { func testDispatcher_FinishingAnyInvocationNotifiesListener() { diff --git a/Tests/PubNubTests/EventEngine/EventEngineTests.swift b/Tests/PubNubTests/EventEngine/EventEngineTests.swift index fb5311f1..ba626a55 100644 --- a/Tests/PubNubTests/EventEngine/EventEngineTests.swift +++ b/Tests/PubNubTests/EventEngine/EventEngineTests.swift @@ -11,7 +11,7 @@ import Foundation import XCTest -@testable import PubNub +@testable import PubNubSDK fileprivate var initialState: ExampleState { ExampleState( diff --git a/Tests/PubNubTests/EventEngine/Helpers/EffectInvocation+Equatable.swift b/Tests/PubNubTests/EventEngine/Helpers/EffectInvocation+Equatable.swift index d62cad9b..6a32c585 100644 --- a/Tests/PubNubTests/EventEngine/Helpers/EffectInvocation+Equatable.swift +++ b/Tests/PubNubTests/EventEngine/Helpers/EffectInvocation+Equatable.swift @@ -10,7 +10,7 @@ import Foundation -@testable import PubNub +@testable import PubNubSDK extension EffectInvocation: Equatable where Invocation: Equatable { public static func ==(lhs: EffectInvocation, rhs: EffectInvocation) -> Bool { diff --git a/Tests/PubNubTests/EventEngine/Presence/HeartbeatEffectTests.swift b/Tests/PubNubTests/EventEngine/Presence/HeartbeatEffectTests.swift index 4d78ef8f..af51cdc3 100644 --- a/Tests/PubNubTests/EventEngine/Presence/HeartbeatEffectTests.swift +++ b/Tests/PubNubTests/EventEngine/Presence/HeartbeatEffectTests.swift @@ -11,7 +11,7 @@ import Foundation import XCTest -@testable import PubNub +@testable import PubNubSDK class HeartbeatEffectTests: XCTestCase { private var mockUrlSession: MockURLSession! diff --git a/Tests/PubNubTests/EventEngine/Presence/LeaveEffectTests.swift b/Tests/PubNubTests/EventEngine/Presence/LeaveEffectTests.swift index 00d6cefc..332bb9b3 100644 --- a/Tests/PubNubTests/EventEngine/Presence/LeaveEffectTests.swift +++ b/Tests/PubNubTests/EventEngine/Presence/LeaveEffectTests.swift @@ -11,7 +11,7 @@ import Foundation import XCTest -@testable import PubNub +@testable import PubNubSDK class LeaveEffectTests: XCTestCase { private var mockUrlSession: MockURLSession! diff --git a/Tests/PubNubTests/EventEngine/Presence/PresenceTransitionTests.swift b/Tests/PubNubTests/EventEngine/Presence/PresenceTransitionTests.swift index fbf3b8f1..209540a2 100644 --- a/Tests/PubNubTests/EventEngine/Presence/PresenceTransitionTests.swift +++ b/Tests/PubNubTests/EventEngine/Presence/PresenceTransitionTests.swift @@ -11,7 +11,7 @@ import Foundation import XCTest -@testable import PubNub +@testable import PubNubSDK extension Presence.Invocation: Equatable { public static func ==(lhs: Presence.Invocation, rhs: Presence.Invocation) -> Bool { diff --git a/Tests/PubNubTests/EventEngine/Presence/WaitEffectTests.swift b/Tests/PubNubTests/EventEngine/Presence/WaitEffectTests.swift index 92a54d30..d43d8e5a 100644 --- a/Tests/PubNubTests/EventEngine/Presence/WaitEffectTests.swift +++ b/Tests/PubNubTests/EventEngine/Presence/WaitEffectTests.swift @@ -11,7 +11,7 @@ import Foundation import XCTest -@testable import PubNub +@testable import PubNubSDK class WaitEffectTests: XCTestCase { private var mockUrlSession: MockURLSession! diff --git a/Tests/PubNubTests/EventEngine/Subscribe/EmitMessagesTests.swift b/Tests/PubNubTests/EventEngine/Subscribe/EmitMessagesTests.swift index 9ff29869..c6d5f44c 100644 --- a/Tests/PubNubTests/EventEngine/Subscribe/EmitMessagesTests.swift +++ b/Tests/PubNubTests/EventEngine/Subscribe/EmitMessagesTests.swift @@ -11,7 +11,7 @@ import Foundation import XCTest -@testable import PubNub +@testable import PubNubSDK fileprivate class MockListener: BaseSubscriptionListener { var onEmitMessagesCalled: ([SubscribeMessagePayload]) -> Void = { _ in } @@ -54,7 +54,7 @@ class EmitMessagesTests: XCTestCase { let effect = EmitMessagesEffect( messages: messages, cursor: SubscribeCursor(timetoken: 12345, region: 11), - listeners: listeners, + listeners: WeakSet(listeners), messageCache: MessageCache() ) @@ -77,15 +77,16 @@ class EmitMessagesTests: XCTestCase { expectation.assertForOverFulfill = true expectation.expectedFulfillmentCount = listeners.count + let generatedMessages = (1...100).map { + generateMessage( + with: .message, + payload: AnyJSON("Hello, it's message number \($0)") + ) + } let effect = EmitMessagesEffect( - messages: (1...100).map { - generateMessage( - with: .message, - payload: AnyJSON("Hello, it's message number \($0)") - ) - }, + messages: generatedMessages, cursor: SubscribeCursor(timetoken: 12345, region: 11), - listeners: listeners, + listeners: WeakSet(listeners), messageCache: MessageCache() ) @@ -110,15 +111,16 @@ class EmitMessagesTests: XCTestCase { expectation.assertForOverFulfill = true expectation.expectedFulfillmentCount = listeners.count + let generatedMessages = (1...50).map { _ in + generateMessage( + with: .message, + payload: AnyJSON("Hello, it's a message") + ) + } let effect = EmitMessagesEffect( - messages: (1...50).map { _ in - generateMessage( - with: .message, - payload: AnyJSON("Hello, it's a message") - ) - }, + messages: generatedMessages, cursor: SubscribeCursor(timetoken: 12345, region: 11), - listeners: listeners, + listeners: WeakSet(listeners), messageCache: MessageCache() ) @@ -156,7 +158,7 @@ class EmitMessagesTests: XCTestCase { let effect = EmitMessagesEffect( messages: newMessages, cursor: SubscribeCursor(timetoken: 12345, region: 11), - listeners: listeners, + listeners: WeakSet(listeners), messageCache: cache ) diff --git a/Tests/PubNubTests/EventEngine/Subscribe/EmitStatusTests.swift b/Tests/PubNubTests/EventEngine/Subscribe/EmitStatusTests.swift index 07b4b0c5..6a5b7414 100644 --- a/Tests/PubNubTests/EventEngine/Subscribe/EmitStatusTests.swift +++ b/Tests/PubNubTests/EventEngine/Subscribe/EmitStatusTests.swift @@ -11,7 +11,7 @@ import Foundation import XCTest -@testable import PubNub +@testable import PubNubSDK fileprivate class MockListener: BaseSubscriptionListener { var onEmitSubscribeEventCalled: ((PubNubSubscribeEvent) -> Void) = { _ in } @@ -39,14 +39,16 @@ class EmitStatusTests: XCTestCase { expectation.expectedFulfillmentCount = listeners.count expectation.assertForOverFulfill = true + let testedStatusChange = Subscribe.ConnectionStatusChange( + oldStatus: .disconnected, + newStatus: .connected, + error: nil + ) let effect = EmitStatusEffect( - statusChange: Subscribe.ConnectionStatusChange( - oldStatus: .disconnected, - newStatus: .connected, - error: nil - ), - listeners: listeners + statusChange: testedStatusChange, + listeners: WeakSet(listeners) ) + listeners.forEach { $0.onEmitSubscribeEventCalled = { event in if case let .connectionChanged(status) = event { @@ -74,14 +76,16 @@ class EmitStatusTests: XCTestCase { errorExpectation.expectedFulfillmentCount = listeners.count errorExpectation.assertForOverFulfill = true + let testedStatusChange = Subscribe.ConnectionStatusChange( + oldStatus: .disconnected, + newStatus: .connected, + error: PubNubError(.unknown) + ) let effect = EmitStatusEffect( - statusChange: Subscribe.ConnectionStatusChange( - oldStatus: .disconnected, - newStatus: .connected, - error: PubNubError(.unknown) - ), - listeners: listeners + statusChange: testedStatusChange, + listeners: WeakSet(listeners) ) + listeners.forEach { $0.onEmitSubscribeEventCalled = { event in if case let .connectionChanged(status) = event { diff --git a/Tests/PubNubTests/EventEngine/Subscribe/SubscribeEffectsTests.swift b/Tests/PubNubTests/EventEngine/Subscribe/SubscribeEffectsTests.swift index 18a7edea..9649cfbf 100644 --- a/Tests/PubNubTests/EventEngine/Subscribe/SubscribeEffectsTests.swift +++ b/Tests/PubNubTests/EventEngine/Subscribe/SubscribeEffectsTests.swift @@ -11,7 +11,7 @@ import Foundation import XCTest -@testable import PubNub +@testable import PubNubSDK class SubscribeEffectsTests: XCTestCase { private var mockUrlSession: MockURLSession! diff --git a/Tests/PubNubTests/EventEngine/Subscribe/SubscribeInputTests.swift b/Tests/PubNubTests/EventEngine/Subscribe/SubscribeInputTests.swift index 1f196567..42951785 100644 --- a/Tests/PubNubTests/EventEngine/Subscribe/SubscribeInputTests.swift +++ b/Tests/PubNubTests/EventEngine/Subscribe/SubscribeInputTests.swift @@ -10,7 +10,7 @@ import Foundation import XCTest -@testable import PubNub +@testable import PubNubSDK class SubscribeInputTests: XCTestCase { func test_ChannelsWithoutPresence() { diff --git a/Tests/PubNubTests/EventEngine/Subscribe/SubscribeTransitionTests.swift b/Tests/PubNubTests/EventEngine/Subscribe/SubscribeTransitionTests.swift index 86b5e664..d7dddef2 100644 --- a/Tests/PubNubTests/EventEngine/Subscribe/SubscribeTransitionTests.swift +++ b/Tests/PubNubTests/EventEngine/Subscribe/SubscribeTransitionTests.swift @@ -11,7 +11,7 @@ import Foundation import XCTest -@testable import PubNub +@testable import PubNubSDK extension SubscribeState { func isEqual(to otherState: some SubscribeState) -> Bool { @@ -77,25 +77,25 @@ class SubscribeTransitionTests: XCTestCase { groups: ["g1", "g1-pnpres", "g2", "g2", "g2-pnpres", "g3"] ) ) - let expectedInvocations: [EffectInvocation] = [ - .managed(.handshakeRequest( - channels: ["c1", "c1-pnpres", "c2"], - groups: ["g1", "g1-pnpres", "g2", "g2-pnpres", "g3"] - )) - ] - let expectedChannels = [ + let expChannels = [ PubNubChannel(id: "c1", withPresence: true), PubNubChannel(id: "c2", withPresence: false) ] - let expectedGroups = [ + let expGroups = [ PubNubChannel(id: "g1", withPresence: true), PubNubChannel(id: "g2", withPresence: true), PubNubChannel(id: "g3", withPresence: false) ] - let expectedState = Subscribe.HandshakingState(input: SubscribeInput( - channels: expectedChannels, - groups: expectedGroups - ), cursor: SubscribeCursor(timetoken: 0)!) + let expectedInvocations: [EffectInvocation] = [ + .managed(.handshakeRequest( + channels: ["c1", "c1-pnpres", "c2"], + groups: ["g1", "g1-pnpres", "g2", "g2-pnpres", "g3"] + )) + ] + let expectedState = Subscribe.HandshakingState( + input: SubscribeInput(channels: expChannels, groups: expGroups), + cursor: SubscribeCursor(timetoken: 0)! + ) XCTAssertTrue(results.state.isEqual(to: expectedState)) XCTAssertTrue(results.invocations.elementsEqual(expectedInvocations)) @@ -113,25 +113,26 @@ class SubscribeTransitionTests: XCTestCase { groups: ["g1", "g1-pnpres", "g2", "g2", "g2-pnpres", "g3"] ) ) - let expectedInvocations: [EffectInvocation] = [ - .managed(.handshakeRequest( - channels: ["c1", "c1-pnpres", "c2"], - groups: ["g1", "g1-pnpres", "g2", "g2-pnpres", "g3"] - )) - ] - let expectedChannels = [ + let expChannels = [ PubNubChannel(id: "c1", withPresence: true), PubNubChannel(id: "c2", withPresence: false) ] - let expectedGroups = [ + let expGroups = [ PubNubChannel(id: "g1", withPresence: true), PubNubChannel(id: "g2", withPresence: true), PubNubChannel(id: "g3", withPresence: false) ] - let expectedState = Subscribe.HandshakingState(input: SubscribeInput( - channels: expectedChannels, - groups: expectedGroups - ), cursor: SubscribeCursor(timetoken: 0, region: 0)) + let expectedInvocations: [EffectInvocation] = [ + .managed(.handshakeRequest( + channels: ["c1", "c1-pnpres", "c2"], + groups: ["g1", "g1-pnpres", "g2", "g2-pnpres", "g3"] + )) + ] + + let expectedState = Subscribe.HandshakingState( + input: SubscribeInput(channels: expChannels, groups: expGroups), + cursor: SubscribeCursor(timetoken: 0, region: 0) + ) XCTAssertTrue(results.state.isEqual(to: expectedState)) XCTAssertTrue(results.invocations.elementsEqual(expectedInvocations)) @@ -154,10 +155,11 @@ class SubscribeTransitionTests: XCTestCase { PubNubChannel(id: "g2", withPresence: true), PubNubChannel(id: "g3", withPresence: false) ] - let expectedState = Subscribe.HandshakeStoppedState(input: SubscribeInput( - channels: expectedChannels, - groups: expectedGroups - ), cursor: SubscribeCursor(timetoken: 0, region: 0)) + + let expectedState = Subscribe.HandshakeStoppedState( + input: SubscribeInput(channels: expectedChannels,groups: expectedGroups), + cursor: SubscribeCursor(timetoken: 0, region: 0) + ) XCTAssertTrue(results.state.isEqual(to: expectedState)) XCTAssertTrue(results.invocations.isEmpty) @@ -171,13 +173,6 @@ class SubscribeTransitionTests: XCTestCase { groups: ["g1", "g1-pnpres", "g2", "g2", "g2-pnpres", "g3"] ) ) - let expectedInvocations: [EffectInvocation] = [ - .cancel(.handshakeRequest), - .managed(.handshakeRequest( - channels: ["c1", "c1-pnpres", "c2"], - groups: ["g1", "g1-pnpres", "g2", "g2-pnpres", "g3"] - )) - ] let expectedChannels = [ PubNubChannel(id: "c1", withPresence: true), PubNubChannel(id: "c2", withPresence: false) @@ -187,48 +182,74 @@ class SubscribeTransitionTests: XCTestCase { PubNubChannel(id: "g2", withPresence: true), PubNubChannel(id: "g3", withPresence: false) ] - let expectedState = Subscribe.HandshakingState(input: SubscribeInput( - channels: expectedChannels, - groups: expectedGroups - ), cursor: SubscribeCursor(timetoken: 0, region: 0)) + let expectedNewStatus: ConnectionStatus = .subscriptionChanged( + channels: expectedChannels.map { $0.id }, + groups: expectedGroups.map { $0.id } + ) + let expectedInvocations: [EffectInvocation] = [ + .cancel(.handshakeRequest), + .managed(.handshakeRequest( + channels: ["c1", "c1-pnpres", "c2"], + groups: ["g1", "g1-pnpres", "g2", "g2-pnpres", "g3"] + )) + ] + + let expectedState = Subscribe.HandshakingState( + input: SubscribeInput(channels: expectedChannels, groups: expectedGroups), + cursor: SubscribeCursor(timetoken: 0, region: 0) + ) XCTAssertTrue(results.state.isEqual(to: expectedState)) XCTAssertTrue(results.invocations.elementsEqual(expectedInvocations)) } func test_SubscriptionChangedForReceivingState() throws { + let status: ConnectionStatus = .subscriptionChanged( + channels: input.subscribedChannelNames, + groups: input.subscribedGroupNames + ) let results = transition.transition( - from: Subscribe.ReceivingState(input: input, cursor: SubscribeCursor(timetoken: 5001000, region: 22)), + from: Subscribe.ReceivingState( + input: input, cursor: SubscribeCursor(timetoken: 5001000, region: 22), + connectionStatus: status + ), event: .subscriptionChanged( channels: ["c1", "c1", "c1-pnpres", "c2"], groups: ["g1", "g1-pnpres", "g2", "g2", "g2-pnpres", "g3"] ) ) + let expChannels = [ + PubNubChannel(id: "c1", withPresence: true), + PubNubChannel(id: "c2", withPresence: false) + ] + let expGroups = [ + PubNubChannel(id: "g1", withPresence: true), + PubNubChannel(id: "g2", withPresence: true), + PubNubChannel(id: "g3", withPresence: false) + ] + + let expectedNewStatus: ConnectionStatus = .subscriptionChanged( + channels: expChannels.map { $0.id }, + groups: expGroups.map { $0.id } + ) let expectedInvocations: [EffectInvocation] = [ .cancel(.receiveMessages), + .regular(.emitStatus(change: Subscribe.ConnectionStatusChange( + oldStatus: status, + newStatus: expectedNewStatus, + error: nil + ))), .managed(.receiveMessages( channels: ["c1", "c1-pnpres", "c2"], groups: ["g1", "g1-pnpres", "g2", "g2-pnpres", "g3"], cursor: SubscribeCursor(timetoken: 5001000, region: 22) )) ] - let expectedChannels = [ - PubNubChannel(id: "c1", withPresence: true), - PubNubChannel(id: "c2", withPresence: false) - ] - let expectedGroups = [ - PubNubChannel(id: "g1", withPresence: true), - PubNubChannel(id: "g2", withPresence: true), - PubNubChannel(id: "g3", withPresence: false) - ] + let expectedState = Subscribe.ReceivingState( - input: SubscribeInput( - channels: expectedChannels, - groups: expectedGroups - ), cursor: SubscribeCursor( - timetoken: 5001000, - region: 22 - ) + input: SubscribeInput(channels: expChannels, groups: expGroups), + cursor: SubscribeCursor(timetoken: 5001000, region: 22), + connectionStatus: .subscriptionChanged(channels: expChannels.map { $0.id }, groups: expGroups.map { $0.id }) ) XCTAssertTrue(results.state.isEqual(to: expectedState)) @@ -247,27 +268,24 @@ class SubscribeTransitionTests: XCTestCase { groups: ["g1", "g1-pnpres", "g2", "g2", "g2-pnpres", "g3"] ) ) - - let expectedInvocations: [EffectInvocation] = [ - .managed(.handshakeRequest( - channels: ["c1", "c1-pnpres", "c2"], - groups: ["g1", "g1-pnpres", "g2", "g2-pnpres", "g3"] - )) - ] - let expectedChannels = [ + let expChannels = [ PubNubChannel(id: "c1", withPresence: true), PubNubChannel(id: "c2", withPresence: false) ] - let expectedGroups = [ + let expGroups = [ PubNubChannel(id: "g1", withPresence: true), PubNubChannel(id: "g2", withPresence: true), PubNubChannel(id: "g3", withPresence: false) ] + let expectedInvocations: [EffectInvocation] = [ + .managed(.handshakeRequest( + channels: ["c1", "c1-pnpres", "c2"], + groups: ["g1", "g1-pnpres", "g2", "g2-pnpres", "g3"] + )) + ] let expectedState = Subscribe.HandshakingState( - input: SubscribeInput( - channels: expectedChannels, - groups: expectedGroups - ), cursor: SubscribeCursor(timetoken: 500100900, region: 11) + input: SubscribeInput(channels: expChannels, groups: expGroups), + cursor: SubscribeCursor(timetoken: 500100900, region: 11) ) XCTAssertTrue(results.state.isEqual(to: expectedState)) @@ -282,23 +300,18 @@ class SubscribeTransitionTests: XCTestCase { groups: ["g1", "g1-pnpres", "g2", "g2", "g2-pnpres", "g3"] ) ) - let expectedChannels = [ + let expChannels = [ PubNubChannel(id: "c1", withPresence: true), PubNubChannel(id: "c2", withPresence: false) ] - let expectedGroups = [ + let expGroups = [ PubNubChannel(id: "g1", withPresence: true), PubNubChannel(id: "g2", withPresence: true), PubNubChannel(id: "g3", withPresence: false) ] let expectedState = Subscribe.ReceiveStoppedState( - input: SubscribeInput( - channels: expectedChannels, - groups: expectedGroups - ), cursor: SubscribeCursor( - timetoken: 500100900, - region: 11 - ) + input: SubscribeInput(channels: expChannels, groups: expGroups), + cursor: SubscribeCursor(timetoken: 500100900, region: 11) ) XCTAssertTrue(results.state.isEqual(to: expectedState)) @@ -308,40 +321,58 @@ class SubscribeTransitionTests: XCTestCase { // MARK: - Subscription Restored func test_SubscriptionRestoredForReceivingState() throws { + let status: ConnectionStatus = .subscriptionChanged( + channels: input.subscribedChannelNames, + groups: input.subscribedGroupNames + ) let results = transition.transition( - from: Subscribe.ReceivingState(input: input, cursor: SubscribeCursor(timetoken: 1500100900, region: 41)), + from: Subscribe.ReceivingState( + input: input, cursor: SubscribeCursor(timetoken: 1500100900, region: 41), + connectionStatus: status + ), event: .subscriptionRestored( channels: ["c1", "c1-pnpres", "c2", "c2", "c2-pnpres", "c3", "c3-pnpres", "c4"], groups: ["g1", "g1-pnpres", "g2", "g2-pnpres", "g3", "g3-pnpres", "g4", "g4"], cursor: SubscribeCursor(timetoken: 100, region: 55) ) ) - let expectedInvocations: [EffectInvocation] = [ - .cancel(.receiveMessages), - .managed(.receiveMessages( - channels: ["c1", "c1-pnpres", "c2", "c2-pnpres", "c3", "c3-pnpres", "c4"], - groups: ["g1", "g1-pnpres", "g2", "g2-pnpres", "g3", "g3-pnpres", "g4"], - cursor: SubscribeCursor(timetoken: 100, region: 55) - )) - ] - let expectedChannels = [ + let expChannels = [ PubNubChannel(id: "c1", withPresence: true), PubNubChannel(id: "c2", withPresence: true), PubNubChannel(id: "c3", withPresence: true), PubNubChannel(id: "c4", withPresence: false) ] - let expectedGroups = [ + let expGroups = [ PubNubChannel(id: "g1", withPresence: true), PubNubChannel(id: "g2", withPresence: true), PubNubChannel(id: "g3", withPresence: true), PubNubChannel(id: "g4", withPresence: false) ] + let expectedNewStatus: ConnectionStatus = .subscriptionChanged( + channels: expChannels.map { $0.id }, + groups: expGroups.map { $0.id } + ) + let expectedInvocations: [EffectInvocation] = [ + .cancel(.receiveMessages), + .regular(.emitStatus(change: Subscribe.ConnectionStatusChange( + oldStatus: status, + newStatus: expectedNewStatus, + error: nil + ))), + .managed(.receiveMessages( + channels: ["c1", "c1-pnpres", "c2", "c2-pnpres", "c3", "c3-pnpres", "c4"], + groups: ["g1", "g1-pnpres", "g2", "g2-pnpres", "g3", "g3-pnpres", "g4"], + cursor: SubscribeCursor(timetoken: 100, region: 55) + )) + ] + let expectedState = Subscribe.ReceivingState( - input: SubscribeInput( - channels: expectedChannels, - groups: expectedGroups - ), - cursor: SubscribeCursor(timetoken: 100, region: 55) + input: SubscribeInput(channels: expChannels, groups: expGroups), + cursor: SubscribeCursor(timetoken: 100, region: 55), + connectionStatus: .subscriptionChanged( + channels: expChannels.map { $0.id }, + groups: expGroups.map { $0.id } + ) ) XCTAssertTrue(results.state.isEqual(to: expectedState)) @@ -361,29 +392,28 @@ class SubscribeTransitionTests: XCTestCase { cursor: SubscribeCursor(timetoken: 100, region: 55) ) ) - let expectedInvocations: [EffectInvocation] = [ - .managed(.handshakeRequest( - channels: ["c1", "c1-pnpres", "c2", "c2-pnpres", "c3", "c3-pnpres", "c4"], - groups: ["g1", "g1-pnpres", "g2", "g2-pnpres", "g3", "g3-pnpres", "g4"] - )) - ] - let expectedChannels = [ + let expChannels = [ PubNubChannel(id: "c1", withPresence: true), PubNubChannel(id: "c2", withPresence: true), PubNubChannel(id: "c3", withPresence: true), PubNubChannel(id: "c4", withPresence: false) ] - let expectedGroups = [ + let expGroups = [ PubNubChannel(id: "g1", withPresence: true), PubNubChannel(id: "g2", withPresence: true), PubNubChannel(id: "g3", withPresence: true), PubNubChannel(id: "g4", withPresence: false) ] + + let expectedInvocations: [EffectInvocation] = [ + .managed(.handshakeRequest( + channels: ["c1", "c1-pnpres", "c2", "c2-pnpres", "c3", "c3-pnpres", "c4"], + groups: ["g1", "g1-pnpres", "g2", "g2-pnpres", "g3", "g3-pnpres", "g4"] + )) + ] let expectedState = Subscribe.HandshakingState( - input: SubscribeInput( - channels: expectedChannels, - groups: expectedGroups - ), cursor: SubscribeCursor(timetoken: 100, region: 55) + input: SubscribeInput(channels: expChannels, groups: expGroups), + cursor: SubscribeCursor(timetoken: 100, region: 55) ) XCTAssertTrue(results.state.isEqual(to: expectedState)) @@ -402,23 +432,20 @@ class SubscribeTransitionTests: XCTestCase { cursor: SubscribeCursor(timetoken: 100, region: 55) ) ) - let expectedChannels = [ + let expChannels = [ PubNubChannel(id: "c1", withPresence: true), PubNubChannel(id: "c2", withPresence: true), PubNubChannel(id: "c3", withPresence: true), PubNubChannel(id: "c4", withPresence: false) ] - let expectedGroups = [ + let expGroups = [ PubNubChannel(id: "g1", withPresence: true), PubNubChannel(id: "g2", withPresence: true), PubNubChannel(id: "g3", withPresence: true), PubNubChannel(id: "g4", withPresence: false) ] let expectedState = Subscribe.ReceiveStoppedState( - input: SubscribeInput( - channels: expectedChannels, - groups: expectedGroups - ), + input: SubscribeInput(channels: expChannels, groups: expGroups), cursor: SubscribeCursor(timetoken: 100, region: 55) ) @@ -435,30 +462,27 @@ class SubscribeTransitionTests: XCTestCase { cursor: SubscribeCursor(timetoken: 100, region: 55) ) ) - let expectedInvocations: [EffectInvocation] = [ - .cancel(.handshakeRequest), - .managed(.handshakeRequest( - channels: ["c1", "c1-pnpres", "c2", "c2-pnpres", "c3", "c3-pnpres", "c4"], - groups: ["g1", "g1-pnpres", "g2", "g2-pnpres", "g3", "g3-pnpres", "g4"] - )) - ] - let expectedChannels = [ + let expChannels = [ PubNubChannel(id: "c1", withPresence: true), PubNubChannel(id: "c2", withPresence: true), PubNubChannel(id: "c3", withPresence: true), PubNubChannel(id: "c4", withPresence: false) ] - let expectedGroups = [ + let expGroups = [ PubNubChannel(id: "g1", withPresence: true), PubNubChannel(id: "g2", withPresence: true), PubNubChannel(id: "g3", withPresence: true), PubNubChannel(id: "g4", withPresence: false) ] + let expectedInvocations: [EffectInvocation] = [ + .cancel(.handshakeRequest), + .managed(.handshakeRequest( + channels: ["c1", "c1-pnpres", "c2", "c2-pnpres", "c3", "c3-pnpres", "c4"], + groups: ["g1", "g1-pnpres", "g2", "g2-pnpres", "g3", "g3-pnpres", "g4"] + )) + ] let expectedState = Subscribe.HandshakingState( - input: SubscribeInput( - channels: expectedChannels, - groups: expectedGroups - ), + input: SubscribeInput(channels: expChannels, groups: expGroups), cursor: SubscribeCursor(timetoken: 100, region: 55) ) @@ -479,29 +503,28 @@ class SubscribeTransitionTests: XCTestCase { cursor: SubscribeCursor(timetoken: 100, region: 55) ) ) - let expectedInvocations: [EffectInvocation] = [ - .managed(.handshakeRequest( - channels: ["c1", "c1-pnpres", "c2", "c2-pnpres", "c3", "c3-pnpres", "c4"], - groups: ["g1", "g1-pnpres", "g2", "g2-pnpres", "g3", "g3-pnpres", "g4"] - )) - ] - let expectedChannels = [ + let expChannels = [ PubNubChannel(id: "c1", withPresence: true), PubNubChannel(id: "c2", withPresence: true), PubNubChannel(id: "c3", withPresence: true), PubNubChannel(id: "c4", withPresence: false) ] - let expectedGroups = [ + let expGroups = [ PubNubChannel(id: "g1", withPresence: true), PubNubChannel(id: "g2", withPresence: true), PubNubChannel(id: "g3", withPresence: true), PubNubChannel(id: "g4", withPresence: false) ] + let expectedInvocations: [EffectInvocation] = [ + .managed(.handshakeRequest( + channels: ["c1", "c1-pnpres", "c2", "c2-pnpres", "c3", "c3-pnpres", "c4"], + groups: ["g1", "g1-pnpres", "g2", "g2-pnpres", "g3", "g3-pnpres", "g4"] + )) + ] + let expectedState = Subscribe.HandshakingState( - input: SubscribeInput( - channels: expectedChannels, - groups: expectedGroups - ), cursor: SubscribeCursor(timetoken: 100, region: 55) + input: SubscribeInput(channels: expChannels, groups: expGroups), + cursor: SubscribeCursor(timetoken: 100, region: 55) ) XCTAssertTrue(results.state.isEqual(to: expectedState)) @@ -517,23 +540,20 @@ class SubscribeTransitionTests: XCTestCase { cursor: SubscribeCursor(timetoken: 100, region: 55) ) ) - let expectedChannels = [ + let expChannels = [ PubNubChannel(id: "c1", withPresence: true), PubNubChannel(id: "c2", withPresence: true), PubNubChannel(id: "c3", withPresence: true), PubNubChannel(id: "c4", withPresence: false) ] - let expectedGroups = [ + let expGroups = [ PubNubChannel(id: "g1", withPresence: true), PubNubChannel(id: "g2", withPresence: true), PubNubChannel(id: "g3", withPresence: true), PubNubChannel(id: "g4", withPresence: false) ] let expectedState = Subscribe.HandshakeStoppedState( - input: SubscribeInput( - channels: expectedChannels, - groups: expectedGroups - ), + input: SubscribeInput(channels: expChannels, groups: expGroups), cursor: SubscribeCursor(timetoken: 100, region: 55) ) @@ -555,7 +575,7 @@ class SubscribeTransitionTests: XCTestCase { let expectedInvocations: [EffectInvocation] = [ .cancel(.handshakeRequest), .regular(.emitStatus(change: Subscribe.ConnectionStatusChange( - oldStatus: .connecting, + oldStatus: .disconnected, newStatus: .connected, error: nil ))), @@ -566,7 +586,8 @@ class SubscribeTransitionTests: XCTestCase { ] let expectedState = Subscribe.ReceivingState( input: input, - cursor: SubscribeCursor(timetoken: 1500100900, region: 41) + cursor: SubscribeCursor(timetoken: 1500100900, region: 41), + connectionStatus: .connected ) XCTAssertTrue(results.state.isEqual(to: expectedState)) @@ -583,7 +604,7 @@ class SubscribeTransitionTests: XCTestCase { let expectedInvocations: [EffectInvocation] = [ .cancel(.handshakeRequest), .regular(.emitStatus(change: Subscribe.ConnectionStatusChange( - oldStatus: .connecting, + oldStatus: .disconnected, newStatus: .connectionError(PubNubError(.unknown)), error: PubNubError(.unknown)) )) @@ -604,7 +625,8 @@ class SubscribeTransitionTests: XCTestCase { let results = transition.transition( from: Subscribe.ReceivingState( input: input, - cursor: SubscribeCursor(timetoken: 18001000, region: 123) + cursor: SubscribeCursor(timetoken: 18001000, region: 123), + connectionStatus: .connected ), event: .receiveSuccess( cursor: SubscribeCursor(timetoken: 18002000, region: 123), @@ -625,7 +647,8 @@ class SubscribeTransitionTests: XCTestCase { ] let expectedState = Subscribe.ReceivingState( input: input, - cursor: SubscribeCursor(timetoken: 18002000, region: 123) + cursor: SubscribeCursor(timetoken: 18002000, region: 123), + connectionStatus: .connected ) XCTAssertTrue(results.state.isEqual(to: expectedState)) @@ -638,7 +661,8 @@ class SubscribeTransitionTests: XCTestCase { let results = transition.transition( from: Subscribe.ReceivingState( input: input, - cursor: SubscribeCursor(timetoken: 100500900, region: 11) + cursor: SubscribeCursor(timetoken: 100500900, region: 11), + connectionStatus: .connected ), event: .receiveFailure(error: PubNubError(.unknown)) ) @@ -762,7 +786,7 @@ class SubscribeTransitionTests: XCTestCase { let expectedInvocations: [EffectInvocation] = [ .cancel(.handshakeRequest), .regular(.emitStatus(change: Subscribe.ConnectionStatusChange( - oldStatus: .connecting, + oldStatus: .disconnected, newStatus: .disconnected, error: nil ))) @@ -780,7 +804,8 @@ class SubscribeTransitionTests: XCTestCase { let results = transition.transition( from: Subscribe.ReceivingState( input: input, - cursor: SubscribeCursor(timetoken: 123, region: 456) + cursor: SubscribeCursor(timetoken: 123, region: 456), + connectionStatus: .connected ), event: .disconnect ) @@ -811,14 +836,13 @@ class SubscribeTransitionTests: XCTestCase { let expectedInvocations: [EffectInvocation] = [ .cancel(.handshakeRequest), .regular(.emitStatus(change: Subscribe.ConnectionStatusChange( - oldStatus: .connecting, + oldStatus: .disconnected, newStatus: .disconnected, error: nil ))) ] - let expectedState = Subscribe.UnsubscribedState() - XCTAssertTrue(results.state.isEqual(to: expectedState)) + XCTAssertTrue(results.state.isEqual(to: Subscribe.UnsubscribedState())) XCTAssertTrue(results.invocations.elementsEqual(expectedInvocations)) } @@ -865,7 +889,8 @@ class SubscribeTransitionTests: XCTestCase { let results = transition.transition( from: Subscribe.ReceivingState( input: input, - cursor: SubscribeCursor(timetoken: 123, region: 456) + cursor: SubscribeCursor(timetoken: 123, region: 456), + connectionStatus: .connected ), event: .unsubscribeAll ) @@ -877,9 +902,8 @@ class SubscribeTransitionTests: XCTestCase { error: nil ))) ] - let expectedState = Subscribe.UnsubscribedState() - XCTAssertTrue(results.state.isEqual(to: expectedState)) + XCTAssertTrue(results.state.isEqual(to: Subscribe.UnsubscribedState())) XCTAssertTrue(results.invocations.elementsEqual(expectedInvocations)) } @@ -899,9 +923,8 @@ class SubscribeTransitionTests: XCTestCase { error: nil ))) ] - let expectedState = Subscribe.UnsubscribedState() - XCTAssertTrue(results.state.isEqual(to: expectedState)) + XCTAssertTrue(results.state.isEqual(to: Subscribe.UnsubscribedState())) XCTAssertTrue(results.invocations.elementsEqual(expectedInvocations)) } @@ -920,9 +943,8 @@ class SubscribeTransitionTests: XCTestCase { error: nil ))) ] - let expectedState = Subscribe.UnsubscribedState() - XCTAssertTrue(results.state.isEqual(to: expectedState)) + XCTAssertTrue(results.state.isEqual(to: Subscribe.UnsubscribedState())) XCTAssertTrue(results.invocations.elementsEqual(expectedInvocations)) } } diff --git a/Tests/PubNubTests/Events/New/SubscriptionSetTests.swift b/Tests/PubNubTests/Events/New/SubscriptionSetTests.swift index 756c50ab..66223e41 100644 --- a/Tests/PubNubTests/Events/New/SubscriptionSetTests.swift +++ b/Tests/PubNubTests/Events/New/SubscriptionSetTests.swift @@ -9,7 +9,7 @@ // import XCTest -@testable import PubNub +@testable import PubNubSDK class SubscriptionSetTests: XCTestCase { private let pubnub = PubNub( diff --git a/Tests/PubNubTests/Events/New/SubscriptionTests.swift b/Tests/PubNubTests/Events/New/SubscriptionTests.swift index 143ed35b..2a538772 100644 --- a/Tests/PubNubTests/Events/New/SubscriptionTests.swift +++ b/Tests/PubNubTests/Events/New/SubscriptionTests.swift @@ -8,7 +8,7 @@ // LICENSE file in the root directory of this source tree. // -@testable import PubNub +@testable import PubNubSDK import XCTest class SubscriptionTests: XCTestCase { diff --git a/Tests/PubNubTests/Events/Old/EventStreamTests.swift b/Tests/PubNubTests/Events/Old/EventStreamTests.swift index af6ef7ba..c78c4636 100644 --- a/Tests/PubNubTests/Events/Old/EventStreamTests.swift +++ b/Tests/PubNubTests/Events/Old/EventStreamTests.swift @@ -8,7 +8,7 @@ // LICENSE file in the root directory of this source tree. // -@testable import PubNub +@testable import PubNubSDK import XCTest class EventStreamTests: XCTestCase { diff --git a/Tests/PubNubTests/Events/Old/SubscriptionStreamTests.swift b/Tests/PubNubTests/Events/Old/SubscriptionStreamTests.swift index 6e4d00e9..4ad1ba0e 100644 --- a/Tests/PubNubTests/Events/Old/SubscriptionStreamTests.swift +++ b/Tests/PubNubTests/Events/Old/SubscriptionStreamTests.swift @@ -8,7 +8,7 @@ // LICENSE file in the root directory of this source tree. // -@testable import PubNub +@testable import PubNubSDK import XCTest class SubscriptionListenerTests: XCTestCase { diff --git a/Tests/PubNubTests/Events/SessionStreamTests.swift b/Tests/PubNubTests/Events/SessionStreamTests.swift index 138913f8..25ecd158 100644 --- a/Tests/PubNubTests/Events/SessionStreamTests.swift +++ b/Tests/PubNubTests/Events/SessionStreamTests.swift @@ -8,7 +8,7 @@ // LICENSE file in the root directory of this source tree. // -@testable import PubNub +@testable import PubNubSDK import XCTest class SessionStreamTests: XCTestCase { diff --git a/Tests/PubNubTests/Events/SubscribeMessagesGeneratorTests.swift b/Tests/PubNubTests/Events/SubscribeMessagesGeneratorTests.swift index 1936d84f..a4f12ffe 100644 --- a/Tests/PubNubTests/Events/SubscribeMessagesGeneratorTests.swift +++ b/Tests/PubNubTests/Events/SubscribeMessagesGeneratorTests.swift @@ -9,7 +9,7 @@ // import Foundation -@testable import PubNub +@testable import PubNubSDK func mockMessagePayload( channel: String = "channel", diff --git a/Tests/PubNubTests/Extensions/Bool+PubNubTests.swift b/Tests/PubNubTests/Extensions/Bool+PubNubTests.swift index 74a0face..07f35d9f 100644 --- a/Tests/PubNubTests/Extensions/Bool+PubNubTests.swift +++ b/Tests/PubNubTests/Extensions/Bool+PubNubTests.swift @@ -8,7 +8,7 @@ // LICENSE file in the root directory of this source tree. // -@testable import PubNub +@testable import PubNubSDK import XCTest final class BoolPubNubTests: XCTestCase { diff --git a/Tests/PubNubTests/Extensions/Collection+PubNubTests.swift b/Tests/PubNubTests/Extensions/Collection+PubNubTests.swift index 57ca0b80..d12e4f5d 100644 --- a/Tests/PubNubTests/Extensions/Collection+PubNubTests.swift +++ b/Tests/PubNubTests/Extensions/Collection+PubNubTests.swift @@ -8,7 +8,7 @@ // LICENSE file in the root directory of this source tree. // -@testable import PubNub +@testable import PubNubSDK import XCTest final class CollectionPubNubTests: XCTestCase { diff --git a/Tests/PubNubTests/Extensions/Data+PubNubTests.swift b/Tests/PubNubTests/Extensions/Data+PubNubTests.swift index b88e169d..aef8fa43 100644 --- a/Tests/PubNubTests/Extensions/Data+PubNubTests.swift +++ b/Tests/PubNubTests/Extensions/Data+PubNubTests.swift @@ -10,7 +10,7 @@ import Foundation -@testable import PubNub +@testable import PubNubSDK import XCTest final class DataPubNubTests: XCTestCase { diff --git a/Tests/PubNubTests/Extensions/DateFormatter+PubNubTests.swift b/Tests/PubNubTests/Extensions/DateFormatter+PubNubTests.swift index d9a07a8b..92c50469 100644 --- a/Tests/PubNubTests/Extensions/DateFormatter+PubNubTests.swift +++ b/Tests/PubNubTests/Extensions/DateFormatter+PubNubTests.swift @@ -8,7 +8,7 @@ // LICENSE file in the root directory of this source tree. // -@testable import PubNub +@testable import PubNubSDK import XCTest final class DateFormatterPubNubTests: XCTestCase { diff --git a/Tests/PubNubTests/Extensions/DispatchQueue+PubNub.swift b/Tests/PubNubTests/Extensions/DispatchQueue+PubNub.swift index 0cd7fdf2..f5be01dd 100644 --- a/Tests/PubNubTests/Extensions/DispatchQueue+PubNub.swift +++ b/Tests/PubNubTests/Extensions/DispatchQueue+PubNub.swift @@ -8,7 +8,7 @@ // LICENSE file in the root directory of this source tree. // -@testable import PubNub +@testable import PubNubSDK import XCTest final class DispatchQueuePubNubTests: XCTestCase { diff --git a/Tests/PubNubTests/Extensions/Error+PubNubTests.swift b/Tests/PubNubTests/Extensions/Error+PubNubTests.swift index a1ca43d2..cb59f27b 100644 --- a/Tests/PubNubTests/Extensions/Error+PubNubTests.swift +++ b/Tests/PubNubTests/Extensions/Error+PubNubTests.swift @@ -8,7 +8,7 @@ // LICENSE file in the root directory of this source tree. // -@testable import PubNub +@testable import PubNubSDK import XCTest final class ErrorPubNubTests: XCTestCase { diff --git a/Tests/PubNubTests/Extensions/HTTPURLResponse+PubNubTests.swift b/Tests/PubNubTests/Extensions/HTTPURLResponse+PubNubTests.swift index 3cecb377..02ed8b5c 100644 --- a/Tests/PubNubTests/Extensions/HTTPURLResponse+PubNubTests.swift +++ b/Tests/PubNubTests/Extensions/HTTPURLResponse+PubNubTests.swift @@ -8,7 +8,7 @@ // LICENSE file in the root directory of this source tree. // -@testable import PubNub +@testable import PubNubSDK import XCTest final class HTTPURLResponsePubNubTests: XCTestCase { diff --git a/Tests/PubNubTests/Extensions/Int+PubNubTests.swift b/Tests/PubNubTests/Extensions/Int+PubNubTests.swift index b0adce54..8287c323 100644 --- a/Tests/PubNubTests/Extensions/Int+PubNubTests.swift +++ b/Tests/PubNubTests/Extensions/Int+PubNubTests.swift @@ -8,7 +8,7 @@ // LICENSE file in the root directory of this source tree. // -@testable import PubNub +@testable import PubNubSDK import XCTest class TimetokenTests: XCTestCase { diff --git a/Tests/PubNubTests/Extensions/OperationQueue+PubNubTests.swift b/Tests/PubNubTests/Extensions/OperationQueue+PubNubTests.swift index 6fc87b1a..a64a4d39 100644 --- a/Tests/PubNubTests/Extensions/OperationQueue+PubNubTests.swift +++ b/Tests/PubNubTests/Extensions/OperationQueue+PubNubTests.swift @@ -8,7 +8,7 @@ // LICENSE file in the root directory of this source tree. // -@testable import PubNub +@testable import PubNubSDK import XCTest final class OperationQueuePubNubTests: XCTestCase { diff --git a/Tests/PubNubTests/Extensions/Set+PubNubTests.swift b/Tests/PubNubTests/Extensions/Set+PubNubTests.swift index 130fbe4d..87de458c 100644 --- a/Tests/PubNubTests/Extensions/Set+PubNubTests.swift +++ b/Tests/PubNubTests/Extensions/Set+PubNubTests.swift @@ -8,7 +8,7 @@ // LICENSE file in the root directory of this source tree. // -@testable import PubNub +@testable import PubNubSDK import XCTest final class SetPubNubTests: XCTestCase { diff --git a/Tests/PubNubTests/Extensions/String+PubNubTests.swift b/Tests/PubNubTests/Extensions/String+PubNubTests.swift index 9620ee4c..b5e3a5fe 100644 --- a/Tests/PubNubTests/Extensions/String+PubNubTests.swift +++ b/Tests/PubNubTests/Extensions/String+PubNubTests.swift @@ -8,7 +8,7 @@ // LICENSE file in the root directory of this source tree. // -@testable import PubNub +@testable import PubNubSDK import XCTest final class StringPubNubTests: XCTestCase { diff --git a/Tests/PubNubTests/Extensions/URL+PubNubTests.swift b/Tests/PubNubTests/Extensions/URL+PubNubTests.swift index 5f09679b..a395dac8 100644 --- a/Tests/PubNubTests/Extensions/URL+PubNubTests.swift +++ b/Tests/PubNubTests/Extensions/URL+PubNubTests.swift @@ -8,7 +8,7 @@ // LICENSE file in the root directory of this source tree. // -@testable import PubNub +@testable import PubNubSDK import XCTest final class URLPubNubTests: XCTestCase { diff --git a/Tests/PubNubTests/Extensions/URLQueryItem+PubNubTests.swift b/Tests/PubNubTests/Extensions/URLQueryItem+PubNubTests.swift index 48d0abb7..2d739c18 100644 --- a/Tests/PubNubTests/Extensions/URLQueryItem+PubNubTests.swift +++ b/Tests/PubNubTests/Extensions/URLQueryItem+PubNubTests.swift @@ -9,7 +9,7 @@ // // -@testable import PubNub +@testable import PubNubSDK import XCTest final class URLQueryItemPubNubTests: XCTestCase { diff --git a/Tests/PubNubTests/Extensions/URLRequest+PubNubTests.swift b/Tests/PubNubTests/Extensions/URLRequest+PubNubTests.swift index 1d5afd4b..33c88580 100644 --- a/Tests/PubNubTests/Extensions/URLRequest+PubNubTests.swift +++ b/Tests/PubNubTests/Extensions/URLRequest+PubNubTests.swift @@ -8,7 +8,7 @@ // LICENSE file in the root directory of this source tree. // -@testable import PubNub +@testable import PubNubSDK import XCTest final class URLRequestPubNubTests: XCTestCase { diff --git a/Tests/PubNubTests/Extensions/URLSessionConfiguration+PubNubTests.swift b/Tests/PubNubTests/Extensions/URLSessionConfiguration+PubNubTests.swift index 16cd9396..82ff6ea9 100644 --- a/Tests/PubNubTests/Extensions/URLSessionConfiguration+PubNubTests.swift +++ b/Tests/PubNubTests/Extensions/URLSessionConfiguration+PubNubTests.swift @@ -8,7 +8,7 @@ // LICENSE file in the root directory of this source tree. // -@testable import PubNub +@testable import PubNubSDK import XCTest final class URLSessionConfigurationPubNubTests: XCTestCase { diff --git a/Tests/PubNubTests/Helpers/AnyJSON+CodableTests.swift b/Tests/PubNubTests/Helpers/AnyJSON+CodableTests.swift index 3695f073..31d01e3d 100644 --- a/Tests/PubNubTests/Helpers/AnyJSON+CodableTests.swift +++ b/Tests/PubNubTests/Helpers/AnyJSON+CodableTests.swift @@ -8,7 +8,7 @@ // LICENSE file in the root directory of this source tree. // -@testable import PubNub +@testable import PubNubSDK import XCTest // swiftlint:disable:next type_body_length diff --git a/Tests/PubNubTests/Helpers/AnyJSONTests.swift b/Tests/PubNubTests/Helpers/AnyJSONTests.swift index e26f8b56..30b5ba0f 100644 --- a/Tests/PubNubTests/Helpers/AnyJSONTests.swift +++ b/Tests/PubNubTests/Helpers/AnyJSONTests.swift @@ -8,7 +8,7 @@ // LICENSE file in the root directory of this source tree. // -@testable import PubNub +@testable import PubNubSDK import XCTest struct SomeCodable: Codable, Equatable { diff --git a/Tests/PubNubTests/Helpers/AtomicTests.swift b/Tests/PubNubTests/Helpers/AtomicTests.swift index 5284a550..4d55e10b 100644 --- a/Tests/PubNubTests/Helpers/AtomicTests.swift +++ b/Tests/PubNubTests/Helpers/AtomicTests.swift @@ -8,7 +8,7 @@ // LICENSE file in the root directory of this source tree. // -@testable import PubNub +@testable import PubNubSDK import XCTest class AtomicTests: XCTestCase { diff --git a/Tests/PubNubTests/Helpers/ConstantsTests.swift b/Tests/PubNubTests/Helpers/ConstantsTests.swift index 414274df..8b5b8ab6 100644 --- a/Tests/PubNubTests/Helpers/ConstantsTests.swift +++ b/Tests/PubNubTests/Helpers/ConstantsTests.swift @@ -8,7 +8,7 @@ // LICENSE file in the root directory of this source tree. // -@testable import PubNub +@testable import PubNubSDK import XCTest #if os(iOS) let osName = "iOS" diff --git a/Tests/PubNubTests/Helpers/CryptoTests.swift b/Tests/PubNubTests/Helpers/CryptoTests.swift index 868bd921..dc17115c 100644 --- a/Tests/PubNubTests/Helpers/CryptoTests.swift +++ b/Tests/PubNubTests/Helpers/CryptoTests.swift @@ -9,9 +9,10 @@ // import CommonCrypto -@testable import PubNub import XCTest +@testable import PubNubSDK + class CryptoTests: XCTestCase { func testEncryptDecrypt_Data() { let cryptoModule = CryptoModule.legacyCryptoModule(with: "SomeTestString") diff --git a/Tests/PubNubTests/Helpers/FlatJSONCodable+Test.swift b/Tests/PubNubTests/Helpers/FlatJSONCodable+Test.swift index 8166ffe0..a651e4f7 100644 --- a/Tests/PubNubTests/Helpers/FlatJSONCodable+Test.swift +++ b/Tests/PubNubTests/Helpers/FlatJSONCodable+Test.swift @@ -8,7 +8,7 @@ // LICENSE file in the root directory of this source tree. // -@testable import PubNub +@testable import PubNubSDK import XCTest class FlatJSONCodableTests: XCTestCase { diff --git a/Tests/PubNubTests/Helpers/PAMTokenTests.swift b/Tests/PubNubTests/Helpers/PAMTokenTests.swift index e11bb583..07e3ba64 100644 --- a/Tests/PubNubTests/Helpers/PAMTokenTests.swift +++ b/Tests/PubNubTests/Helpers/PAMTokenTests.swift @@ -8,7 +8,7 @@ // LICENSE file in the root directory of this source tree. // -@testable import PubNub +@testable import PubNubSDK import XCTest // swiftlint:disable line_length diff --git a/Tests/PubNubTests/Helpers/ValidatedTests.swift b/Tests/PubNubTests/Helpers/ValidatedTests.swift index 3cc6eb85..d13962e9 100644 --- a/Tests/PubNubTests/Helpers/ValidatedTests.swift +++ b/Tests/PubNubTests/Helpers/ValidatedTests.swift @@ -8,7 +8,7 @@ // LICENSE file in the root directory of this source tree. // -@testable import PubNub +@testable import PubNubSDK import XCTest class ValidatedTests: XCTestCase { diff --git a/Tests/PubNubTests/Helpers/WeakBoxTests.swift b/Tests/PubNubTests/Helpers/WeakBoxTests.swift index bbef3d3c..116eed30 100644 --- a/Tests/PubNubTests/Helpers/WeakBoxTests.swift +++ b/Tests/PubNubTests/Helpers/WeakBoxTests.swift @@ -8,7 +8,7 @@ // LICENSE file in the root directory of this source tree. // -@testable import PubNub +@testable import PubNubSDK import XCTest class WeakBoxTests: XCTestCase { diff --git a/Tests/PubNubTests/Helpers/XMLCodingTests.swift b/Tests/PubNubTests/Helpers/XMLCodingTests.swift index 5c00cb66..da3bcd42 100644 --- a/Tests/PubNubTests/Helpers/XMLCodingTests.swift +++ b/Tests/PubNubTests/Helpers/XMLCodingTests.swift @@ -8,7 +8,7 @@ // LICENSE file in the root directory of this source tree. // -@testable import PubNub +@testable import PubNubSDK import XCTest class XMLCodingTests: XCTestCase { diff --git a/Tests/PubNubTests/Integration/ChannelObjectsEndpointIntegrationTests.swift b/Tests/PubNubTests/Integration/ChannelObjectsEndpointIntegrationTests.swift index f11a76b2..3bbfc6f5 100644 --- a/Tests/PubNubTests/Integration/ChannelObjectsEndpointIntegrationTests.swift +++ b/Tests/PubNubTests/Integration/ChannelObjectsEndpointIntegrationTests.swift @@ -8,7 +8,7 @@ // LICENSE file in the root directory of this source tree. // -import PubNub +import PubNubSDK import XCTest class ChannelObjectsEndpointIntegrationTests: XCTestCase { diff --git a/Tests/PubNubTests/Integration/MessageActionsEndpointIntegrationTests.swift b/Tests/PubNubTests/Integration/MessageActionsEndpointIntegrationTests.swift index 16b4bcbc..3fb0eb5e 100644 --- a/Tests/PubNubTests/Integration/MessageActionsEndpointIntegrationTests.swift +++ b/Tests/PubNubTests/Integration/MessageActionsEndpointIntegrationTests.swift @@ -8,7 +8,7 @@ // LICENSE file in the root directory of this source tree. // -import PubNub +import PubNubSDK import XCTest class MessageActionsEndpointIntegrationTests: XCTestCase { diff --git a/Tests/PubNubTests/Integration/OnboardingSnippets.swift b/Tests/PubNubTests/Integration/OnboardingSnippets.swift index 47a51444..d0ea16f5 100644 --- a/Tests/PubNubTests/Integration/OnboardingSnippets.swift +++ b/Tests/PubNubTests/Integration/OnboardingSnippets.swift @@ -8,7 +8,7 @@ // LICENSE file in the root directory of this source tree. // -import PubNub +import PubNubSDK import XCTest class OnboardingSnippets: XCTestCase { diff --git a/Tests/PubNubTests/Integration/PresenceEndpointIntegrationTests.swift b/Tests/PubNubTests/Integration/PresenceEndpointIntegrationTests.swift index 535e0a23..26443dbd 100644 --- a/Tests/PubNubTests/Integration/PresenceEndpointIntegrationTests.swift +++ b/Tests/PubNubTests/Integration/PresenceEndpointIntegrationTests.swift @@ -8,7 +8,7 @@ // LICENSE file in the root directory of this source tree. // -import PubNub +import PubNubSDK import XCTest class PresenceEndpointIntegrationTests: XCTestCase { diff --git a/Tests/PubNubTests/Integration/PubNub+Integration.swift b/Tests/PubNubTests/Integration/PubNub+Integration.swift index f626306c..e42ca2d0 100644 --- a/Tests/PubNubTests/Integration/PubNub+Integration.swift +++ b/Tests/PubNubTests/Integration/PubNub+Integration.swift @@ -9,8 +9,7 @@ // import Foundation - -import PubNub +import PubNubSDK extension PubNub { func publishWithMessageAction( diff --git a/Tests/PubNubTests/Integration/PublishEndpointIntegrationTests.swift b/Tests/PubNubTests/Integration/PublishEndpointIntegrationTests.swift index 5fc0c138..ee3e092e 100644 --- a/Tests/PubNubTests/Integration/PublishEndpointIntegrationTests.swift +++ b/Tests/PubNubTests/Integration/PublishEndpointIntegrationTests.swift @@ -8,7 +8,7 @@ // LICENSE file in the root directory of this source tree. // -import PubNub +import PubNubSDK import XCTest class PublishEndpointIntegrationTests: XCTestCase { diff --git a/Tests/PubNubTests/Integration/PushIntegrationTests.swift b/Tests/PubNubTests/Integration/PushIntegrationTests.swift index aeb957d7..d383a154 100644 --- a/Tests/PubNubTests/Integration/PushIntegrationTests.swift +++ b/Tests/PubNubTests/Integration/PushIntegrationTests.swift @@ -7,9 +7,9 @@ // This source code is licensed under the license found in the // LICENSE file in the root directory of this source tree. // -import XCTest -import PubNub +import XCTest +import PubNubSDK class PushIntegrationTests: XCTestCase { let testsBundle = Bundle(for: PushIntegrationTests.self) diff --git a/Tests/PubNubTests/Integration/SubscriptionIntegrationTests.swift b/Tests/PubNubTests/Integration/SubscriptionIntegrationTests.swift index 9892df70..c6d74e8e 100644 --- a/Tests/PubNubTests/Integration/SubscriptionIntegrationTests.swift +++ b/Tests/PubNubTests/Integration/SubscriptionIntegrationTests.swift @@ -8,7 +8,7 @@ // LICENSE file in the root directory of this source tree. // -import PubNub +import PubNubSDK import XCTest class SubscriptionIntegrationTests: XCTestCase { @@ -32,8 +32,6 @@ class SubscriptionIntegrationTests: XCTestCase { for config in [configuration, eeConfiguration] { XCTContext.runActivity(named: "Testing configuration with enableEventEngine=\(config.enableEventEngine)") { _ in let subscribeExpect = expectation(description: "Subscribe Expectation") - let connectingExpect = expectation(description: "Connecting Expectation") - let disconnectedExpect = expectation(description: "Disconnected Expectation") disconnectedExpect.assertForOverFulfill = true disconnectedExpect.expectedFulfillmentCount = 1 @@ -46,8 +44,6 @@ class SubscriptionIntegrationTests: XCTestCase { switch event { case let .connectionStatusChanged(status): switch status { - case .connecting: - connectingExpect.fulfill() case .disconnectedUnexpectedly: disconnectedExpect.fulfill() case .connectionError: @@ -66,7 +62,7 @@ class SubscriptionIntegrationTests: XCTestCase { pubnub.subscribe(to: [testChannel]) defer { pubnub.disconnect() } - wait(for: [subscribeExpect, connectingExpect, disconnectedExpect], timeout: 10.0) + wait(for: [subscribeExpect, disconnectedExpect], timeout: 10.0) } } } @@ -82,7 +78,8 @@ class SubscriptionIntegrationTests: XCTestCase { let configWithEventEngineEnabled = PubNubConfiguration( publishKey: configurationFromBundle.publishKey, subscribeKey: configurationFromBundle.subscribeKey, - userId: configurationFromBundle.userId + userId: configurationFromBundle.userId, + enableEventEngine: true ) for config in [configurationFromBundle, configWithEventEngineEnabled] { @@ -163,7 +160,8 @@ class SubscriptionIntegrationTests: XCTestCase { let configWithEventEngineEnabled = PubNubConfiguration( publishKey: configurationFromBundle.publishKey, subscribeKey: configurationFromBundle.subscribeKey, - userId: configurationFromBundle.userId + userId: configurationFromBundle.userId, + enableEventEngine: true ) for config in [configurationFromBundle, configWithEventEngineEnabled] { @@ -208,7 +206,6 @@ class SubscriptionIntegrationTests: XCTestCase { firstSubscription = nil secondSubscription = nil pubnub.unsubscribe(from: [self.testChannel]) - subscriptionSet?.unsubscribe() subscriptionSet = nil default: break @@ -242,7 +239,8 @@ class SubscriptionIntegrationTests: XCTestCase { let configWithEventEngineEnabled = PubNubConfiguration( publishKey: configurationFromBundle.publishKey, subscribeKey: configurationFromBundle.subscribeKey, - userId: configurationFromBundle.userId + userId: configurationFromBundle.userId, + enableEventEngine: true ) for config in [configurationFromBundle, configWithEventEngineEnabled] { @@ -253,7 +251,7 @@ class SubscriptionIntegrationTests: XCTestCase { let statusExpect = XCTestExpectation(description: "StatusExpect") statusExpect.assertForOverFulfill = true - statusExpect.expectedFulfillmentCount = 3 + statusExpect.expectedFulfillmentCount = 2 let pubnub = PubNub(configuration: config) var statusCounter = 0 @@ -263,13 +261,11 @@ class SubscriptionIntegrationTests: XCTestCase { messageExpect.fulfill() pubnub.unsubscribe(from: [self.testChannel]) } - pubnub.onConnectionStateChange = { [unowned pubnub] change in + pubnub.onConnectionStateChange = { [unowned pubnub, unowned self] change in if statusCounter == 0 { - XCTAssertTrue(change == .connecting) - } else if statusCounter == 1 { XCTAssertTrue(change == .connected) pubnub.publish(channel: self.testChannel, message: "This is a message", completion: nil) - } else if statusCounter == 2 { + } else if statusCounter == 1 { XCTAssertTrue(change == .disconnected) } else { XCTFail("Unexpected condition") @@ -299,7 +295,9 @@ class SubscriptionIntegrationTests: XCTestCase { subscribeKey: PubNubConfiguration(from: testsBundle).subscribeKey, userId: PubNubConfiguration(from: testsBundle).userId )) - let timetoken = Timetoken(Int(Date().timeIntervalSince1970 * 10000000)) + let timetoken = Timetoken( + Int(Date().timeIntervalSince1970 * 10000000) + ) pubnub.publish(channel: testChannel, message: "Message", completion: { [unowned pubnub, unowned self] _ in pubnub.publish(channel: self.testChannel, message: "Second message", completion: { _ in @@ -328,7 +326,7 @@ class SubscriptionIntegrationTests: XCTestCase { func test_SimultaneousSubscriptionsToTheSameChannel() { let expectation = XCTestExpectation(description: "Test Simultaneous Subscriptions") expectation.assertForOverFulfill = true - expectation.expectedFulfillmentCount = 2 + expectation.expectedFulfillmentCount = 1 let pubnub = PubNub(configuration: PubNubConfiguration( publishKey: PubNubConfiguration(from: testsBundle).publishKey, @@ -336,10 +334,10 @@ class SubscriptionIntegrationTests: XCTestCase { userId: PubNubConfiguration(from: testsBundle).userId )) + let channelName = "channel" + pubnub.onConnectionStateChange = { newStatus in switch newStatus { - case .connecting: - expectation.fulfill() case .connected: expectation.fulfill() default: @@ -347,17 +345,17 @@ class SubscriptionIntegrationTests: XCTestCase { } } - pubnub.subscribe(to: ["channel"]) - pubnub.subscribe(to: ["channel"]) + pubnub.subscribe(to: [channelName]) + pubnub.subscribe(to: [channelName]) - XCTAssertEqual(pubnub.subscribedChannels, ["channel"]) + XCTAssertEqual(pubnub.subscribedChannels, [channelName]) wait(for: [expectation], timeout: 5.0) } func test_SimultaneousSubscriptionsToTheSameChannelWithTimetoken() { let expectation = XCTestExpectation(description: "Test Simultaneous Subscriptions With Timetoken") expectation.assertForOverFulfill = true - expectation.expectedFulfillmentCount = 3 + expectation.expectedFulfillmentCount = 1 let pubnub = PubNub(configuration: PubNubConfiguration( publishKey: PubNubConfiguration(from: testsBundle).publishKey, @@ -365,10 +363,10 @@ class SubscriptionIntegrationTests: XCTestCase { userId: PubNubConfiguration(from: testsBundle).userId )) + let channelName = "channel" + pubnub.onConnectionStateChange = { newStatus in switch newStatus { - case .connecting: - expectation.fulfill() case .connected: expectation.fulfill() default: @@ -376,8 +374,8 @@ class SubscriptionIntegrationTests: XCTestCase { } } - pubnub.subscribe(to: ["channel"]) - pubnub.subscribe(to: ["channel"], at: Timetoken(Int(Date().timeIntervalSince1970 * 10000000))) + pubnub.subscribe(to: [channelName]) + pubnub.subscribe(to: [channelName], at: Timetoken(Int(Date().timeIntervalSince1970 * 10000000))) wait(for: [expectation], timeout: 5.0) } diff --git a/Tests/PubNubTests/Integration/UUIDObjectsEndpointIntegrationTests.swift b/Tests/PubNubTests/Integration/UUIDObjectsEndpointIntegrationTests.swift index 94561e05..5adc27ef 100644 --- a/Tests/PubNubTests/Integration/UUIDObjectsEndpointIntegrationTests.swift +++ b/Tests/PubNubTests/Integration/UUIDObjectsEndpointIntegrationTests.swift @@ -8,7 +8,7 @@ // LICENSE file in the root directory of this source tree. // -import PubNub +import PubNubSDK import XCTest class UUIDObjectsEndpointIntegrationTests: XCTestCase { diff --git a/Tests/PubNubTests/Mocking/ImportTestResource.swift b/Tests/PubNubTests/Mocking/ImportTestResource.swift index afe0d48c..bf3f91d2 100644 --- a/Tests/PubNubTests/Mocking/ImportTestResource.swift +++ b/Tests/PubNubTests/Mocking/ImportTestResource.swift @@ -8,7 +8,7 @@ // LICENSE file in the root directory of this source tree. // -@testable import PubNub +@testable import PubNubSDK import XCTest enum ImportTestResourceError: Error, LocalizedError { diff --git a/Tests/PubNubTests/Mocking/MockRequestOperators.swift b/Tests/PubNubTests/Mocking/MockRequestOperators.swift index 7fa2fb21..be33a248 100644 --- a/Tests/PubNubTests/Mocking/MockRequestOperators.swift +++ b/Tests/PubNubTests/Mocking/MockRequestOperators.swift @@ -8,8 +8,8 @@ // LICENSE file in the root directory of this source tree. // -@testable import PubNub import XCTest +@testable import PubNubSDK struct DefaultOperator: RequestOperator, Equatable { let uuid = UUID() diff --git a/Tests/PubNubTests/Mocking/MockURLSession.swift b/Tests/PubNubTests/Mocking/MockURLSession.swift index 72b9b500..f8960aff 100644 --- a/Tests/PubNubTests/Mocking/MockURLSession.swift +++ b/Tests/PubNubTests/Mocking/MockURLSession.swift @@ -9,7 +9,7 @@ // import Foundation -@testable import PubNub +@testable import PubNubSDK class MockURLSessionDataTask: URLSessionDataTask { weak var mockSession: MockURLSession? diff --git a/Tests/PubNubTests/Mocking/SessionStreamAwait.swift b/Tests/PubNubTests/Mocking/SessionStreamAwait.swift index cf08415a..dd2d29bf 100644 --- a/Tests/PubNubTests/Mocking/SessionStreamAwait.swift +++ b/Tests/PubNubTests/Mocking/SessionStreamAwait.swift @@ -9,9 +9,10 @@ // import Foundation -@testable import PubNub import XCTest +@testable import PubNubSDK + final class SessionExpector { public var expectations = [XCTestExpectation]() public var sessionListener: SessionListener diff --git a/Tests/PubNubTests/Mocking/TestLogWriter.swift b/Tests/PubNubTests/Mocking/TestLogWriter.swift index 33595e4d..7ea76920 100644 --- a/Tests/PubNubTests/Mocking/TestLogWriter.swift +++ b/Tests/PubNubTests/Mocking/TestLogWriter.swift @@ -9,7 +9,7 @@ // import Foundation -@testable import PubNub +@testable import PubNubSDK class TestSyncLogWriter: LogWriter { var executor: LogExecutable = LogExecutionType.sync(lock: NSRecursiveLock()) diff --git a/Tests/PubNubTests/Mocking/TestSetup.swift b/Tests/PubNubTests/Mocking/TestSetup.swift index a00b1b6d..af1a2920 100644 --- a/Tests/PubNubTests/Mocking/TestSetup.swift +++ b/Tests/PubNubTests/Mocking/TestSetup.swift @@ -9,7 +9,7 @@ // import Foundation -import PubNub +import PubNubSDK /// Anything that needs to be executed once can be placed inside the init class TestSetup: NSObject { diff --git a/Tests/PubNubTests/Mocking/XMLEncoder.swift b/Tests/PubNubTests/Mocking/XMLEncoder.swift index cec9ca8d..519041e3 100644 --- a/Tests/PubNubTests/Mocking/XMLEncoder.swift +++ b/Tests/PubNubTests/Mocking/XMLEncoder.swift @@ -10,7 +10,7 @@ import Foundation -@testable import PubNub +@testable import PubNubSDK /// `XMLEncoder` facilitates the encoding of `Encodable` values into XML. class XMLEncoder { diff --git a/Tests/PubNubTests/Networking/Operators/AutomaticRetryTests.swift b/Tests/PubNubTests/Networking/Operators/AutomaticRetryTests.swift index dd1d8577..73caa95b 100644 --- a/Tests/PubNubTests/Networking/Operators/AutomaticRetryTests.swift +++ b/Tests/PubNubTests/Networking/Operators/AutomaticRetryTests.swift @@ -8,7 +8,7 @@ // LICENSE file in the root directory of this source tree. // -@testable import PubNub +@testable import PubNubSDK import XCTest class AutomaticRetryTests: XCTestCase { diff --git a/Tests/PubNubTests/Networking/Operators/RequestIdOperatorTests.swift b/Tests/PubNubTests/Networking/Operators/RequestIdOperatorTests.swift index 2b3b97ad..dbb2126a 100644 --- a/Tests/PubNubTests/Networking/Operators/RequestIdOperatorTests.swift +++ b/Tests/PubNubTests/Networking/Operators/RequestIdOperatorTests.swift @@ -8,7 +8,7 @@ // LICENSE file in the root directory of this source tree. // -@testable import PubNub +@testable import PubNubSDK import XCTest class RequestIdOperatorTests: XCTestCase { diff --git a/Tests/PubNubTests/Networking/Operators/RequestMutatorTests.swift b/Tests/PubNubTests/Networking/Operators/RequestMutatorTests.swift index 6c5cbc0d..248bc0cc 100644 --- a/Tests/PubNubTests/Networking/Operators/RequestMutatorTests.swift +++ b/Tests/PubNubTests/Networking/Operators/RequestMutatorTests.swift @@ -8,7 +8,7 @@ // LICENSE file in the root directory of this source tree. // -@testable import PubNub +@testable import PubNubSDK import XCTest class RequestMutatorTests: XCTestCase { diff --git a/Tests/PubNubTests/Networking/Operators/RequestRetrierTests.swift b/Tests/PubNubTests/Networking/Operators/RequestRetrierTests.swift index c2587bf2..25fe0f4e 100644 --- a/Tests/PubNubTests/Networking/Operators/RequestRetrierTests.swift +++ b/Tests/PubNubTests/Networking/Operators/RequestRetrierTests.swift @@ -8,7 +8,7 @@ // LICENSE file in the root directory of this source tree. // -@testable import PubNub +@testable import PubNubSDK import XCTest class RequestRetrierTests: XCTestCase { diff --git a/Tests/PubNubTests/Networking/Routers/ChannelGroupEndpointTests.swift b/Tests/PubNubTests/Networking/Routers/ChannelGroupEndpointTests.swift index fd49d8c7..2fd59019 100644 --- a/Tests/PubNubTests/Networking/Routers/ChannelGroupEndpointTests.swift +++ b/Tests/PubNubTests/Networking/Routers/ChannelGroupEndpointTests.swift @@ -8,7 +8,7 @@ // LICENSE file in the root directory of this source tree. // -@testable import PubNub +@testable import PubNubSDK import XCTest final class ChannelGroupsRouterTests: XCTestCase { diff --git a/Tests/PubNubTests/Networking/Routers/FileManagementRouterTests.swift b/Tests/PubNubTests/Networking/Routers/FileManagementRouterTests.swift index f67aa1e2..f9a2c237 100644 --- a/Tests/PubNubTests/Networking/Routers/FileManagementRouterTests.swift +++ b/Tests/PubNubTests/Networking/Routers/FileManagementRouterTests.swift @@ -8,7 +8,7 @@ // LICENSE file in the root directory of this source tree. // -@testable import PubNub +@testable import PubNubSDK import XCTest final class FileManagementRouterTests: XCTestCase { diff --git a/Tests/PubNubTests/Networking/Routers/HistoryRouterTests.swift b/Tests/PubNubTests/Networking/Routers/HistoryRouterTests.swift index 594a8ea2..56d3895b 100644 --- a/Tests/PubNubTests/Networking/Routers/HistoryRouterTests.swift +++ b/Tests/PubNubTests/Networking/Routers/HistoryRouterTests.swift @@ -9,7 +9,7 @@ // // swiftlint:disable file_length -@testable import PubNub +@testable import PubNubSDK import XCTest final class HistoryRouterTests: XCTestCase { diff --git a/Tests/PubNubTests/Networking/Routers/MessageActionsRouterTests.swift b/Tests/PubNubTests/Networking/Routers/MessageActionsRouterTests.swift index cdb70e63..493798d0 100644 --- a/Tests/PubNubTests/Networking/Routers/MessageActionsRouterTests.swift +++ b/Tests/PubNubTests/Networking/Routers/MessageActionsRouterTests.swift @@ -8,7 +8,7 @@ // LICENSE file in the root directory of this source tree. // -@testable import PubNub +@testable import PubNubSDK import XCTest final class MessageActionsRouterTests: XCTestCase { diff --git a/Tests/PubNubTests/Networking/Routers/ObjectsChannelRouterTests.swift b/Tests/PubNubTests/Networking/Routers/ObjectsChannelRouterTests.swift index f9911bac..d845d183 100644 --- a/Tests/PubNubTests/Networking/Routers/ObjectsChannelRouterTests.swift +++ b/Tests/PubNubTests/Networking/Routers/ObjectsChannelRouterTests.swift @@ -8,7 +8,7 @@ // LICENSE file in the root directory of this source tree. // -@testable import PubNub +@testable import PubNubSDK import XCTest final class ObjectsChannelRouterTests: XCTestCase { diff --git a/Tests/PubNubTests/Networking/Routers/ObjectsMembershipsRouterTests.swift b/Tests/PubNubTests/Networking/Routers/ObjectsMembershipsRouterTests.swift index 5839cc2c..3815db0c 100644 --- a/Tests/PubNubTests/Networking/Routers/ObjectsMembershipsRouterTests.swift +++ b/Tests/PubNubTests/Networking/Routers/ObjectsMembershipsRouterTests.swift @@ -8,7 +8,7 @@ // LICENSE file in the root directory of this source tree. // -@testable import PubNub +@testable import PubNubSDK import XCTest final class ObjectsMembershipsRouterTests: XCTestCase { diff --git a/Tests/PubNubTests/Networking/Routers/ObjectsUUIDRouterTests.swift b/Tests/PubNubTests/Networking/Routers/ObjectsUUIDRouterTests.swift index 6dec83f9..7ae7eba7 100644 --- a/Tests/PubNubTests/Networking/Routers/ObjectsUUIDRouterTests.swift +++ b/Tests/PubNubTests/Networking/Routers/ObjectsUUIDRouterTests.swift @@ -8,7 +8,7 @@ // LICENSE file in the root directory of this source tree. // -@testable import PubNub +@testable import PubNubSDK import XCTest final class ObjectsUUIDRouterTests: XCTestCase { diff --git a/Tests/PubNubTests/Networking/Routers/PresenceRouterTests.swift b/Tests/PubNubTests/Networking/Routers/PresenceRouterTests.swift index 5f99cd96..8d4863bc 100644 --- a/Tests/PubNubTests/Networking/Routers/PresenceRouterTests.swift +++ b/Tests/PubNubTests/Networking/Routers/PresenceRouterTests.swift @@ -8,7 +8,7 @@ // LICENSE file in the root directory of this source tree. // -@testable import PubNub +@testable import PubNubSDK import XCTest final class PresenceRouterTests: XCTestCase { diff --git a/Tests/PubNubTests/Networking/Routers/PublishRouterTests.swift b/Tests/PubNubTests/Networking/Routers/PublishRouterTests.swift index af50512f..3f220621 100644 --- a/Tests/PubNubTests/Networking/Routers/PublishRouterTests.swift +++ b/Tests/PubNubTests/Networking/Routers/PublishRouterTests.swift @@ -8,7 +8,7 @@ // LICENSE file in the root directory of this source tree. // -@testable import PubNub +@testable import PubNubSDK import XCTest final class PublishRouterTests: XCTestCase { diff --git a/Tests/PubNubTests/Networking/Routers/PushRouterTests.swift b/Tests/PubNubTests/Networking/Routers/PushRouterTests.swift index 1ff8e6e6..71e40080 100644 --- a/Tests/PubNubTests/Networking/Routers/PushRouterTests.swift +++ b/Tests/PubNubTests/Networking/Routers/PushRouterTests.swift @@ -8,7 +8,7 @@ // LICENSE file in the root directory of this source tree. // -@testable import PubNub +@testable import PubNubSDK import XCTest final class PushRouterTests: XCTestCase { diff --git a/Tests/PubNubTests/Networking/Routers/SubscribeRouterTests.swift b/Tests/PubNubTests/Networking/Routers/SubscribeRouterTests.swift index 6baf0dd6..7fcf3ece 100644 --- a/Tests/PubNubTests/Networking/Routers/SubscribeRouterTests.swift +++ b/Tests/PubNubTests/Networking/Routers/SubscribeRouterTests.swift @@ -10,7 +10,7 @@ import XCTest -@testable import PubNub +@testable import PubNubSDK final class SubscribeRouterTests: XCTestCase { let config = PubNubConfiguration( @@ -851,16 +851,21 @@ extension SubscribeRouterTests { let mockResponses = ["subscription_handshake_success", "subscription_invalid_json", "cancelled"] let mockResult = mockSubscriptionSession(with: mockResponses, raw: [corruptedData], and: configuration) let errorExpect = XCTestExpectation(description: "Error Event") - let statusExpect = XCTestExpectation(description: "Status Event") let pubnub = PubNub(configuration: configuration) + let statusExpect: XCTestExpectation? = if (configuration.enableEventEngine) { + XCTestExpectation(description: "Status Event") + } else { + nil + } + mockResult.listener.didReceiveSubscription = { [mockResult] event in switch event { case .subscriptionChanged: break case let .connectionStatusChanged(connection): - if connection == .disconnected { - statusExpect.fulfill() + if case .connectionError = connection { + statusExpect?.fulfill() } case let .subscribeError(error): XCTAssertEqual(error.reason, .jsonDataDecodingFailure) @@ -874,7 +879,7 @@ extension SubscribeRouterTests { XCTAssertEqual(mockResult.subscriptionSession.subscribedChannels, [testChannel]) defer { mockResult.listener.cancel() } - wait(for: [errorExpect, statusExpect], timeout: 1.0, enforceOrder: true) + wait(for: [errorExpect, statusExpect].compactMap { $0 }, timeout: 1.0, enforceOrder: true) } } } @@ -936,8 +941,9 @@ extension SubscribeRouterTests { let statusExpect = XCTestExpectation(description: "Status Event") let otherChannel = "OtherChannel" let pubnub = PubNub(configuration: configuration) + let subscriptionSession = mockResult.subscriptionSession - mockResult.listener.didReceiveSubscription = { [weak self, mockResult] event in + mockResult.listener.didReceiveSubscription = { [weak self, weak subscriptionSession] event in switch event { case let .subscriptionChanged(change): switch change { @@ -953,8 +959,8 @@ extension SubscribeRouterTests { case let .connectionStatusChanged(status): switch status { case .connected: - mockResult.subscriptionSession.unsubscribeAll() - XCTAssertEqual(mockResult.subscriptionSession.subscribedChannels, []) + subscriptionSession?.unsubscribeAll() + XCTAssertEqual(subscriptionSession?.subscribedChannels, []) statusExpect.fulfill() case .disconnected: statusExpect.fulfill() @@ -969,8 +975,6 @@ extension SubscribeRouterTests { mockResult.subscriptionSession.subscribe(to: [testChannel, otherChannel], using: pubnub) XCTAssertTrue(mockResult.subscriptionSession.subscribedChannels.contains(testChannel)) XCTAssertTrue(mockResult.subscriptionSession.subscribedChannels.contains(otherChannel)) - mockResult.subscriptionSession.unsubscribeAll() - XCTAssertEqual(mockResult.subscriptionSession.subscribedChannels, []) defer { mockResult.listener.cancel() } wait(for: [statusExpect], timeout: 1.0) diff --git a/Tests/PubNubTests/Networking/Routers/TimeRouterTests.swift b/Tests/PubNubTests/Networking/Routers/TimeRouterTests.swift index 76a0cc27..fb57cf90 100644 --- a/Tests/PubNubTests/Networking/Routers/TimeRouterTests.swift +++ b/Tests/PubNubTests/Networking/Routers/TimeRouterTests.swift @@ -8,7 +8,7 @@ // LICENSE file in the root directory of this source tree. // -@testable import PubNub +@testable import PubNubSDK import XCTest class TimeRouterTests: XCTestCase { diff --git a/Tests/PubNubTests/Networking/Session+EndpointErrorTests.swift b/Tests/PubNubTests/Networking/Session+EndpointErrorTests.swift index ad47d5bb..1afaa19b 100644 --- a/Tests/PubNubTests/Networking/Session+EndpointErrorTests.swift +++ b/Tests/PubNubTests/Networking/Session+EndpointErrorTests.swift @@ -8,7 +8,7 @@ // LICENSE file in the root directory of this source tree. // -@testable import PubNub +@testable import PubNubSDK import XCTest final class SessionEndpointErrorTests: XCTestCase { diff --git a/Tests/PubNubTests/Networking/Session+URLErrorTests.swift b/Tests/PubNubTests/Networking/Session+URLErrorTests.swift index ad3df63c..f3119fc5 100644 --- a/Tests/PubNubTests/Networking/Session+URLErrorTests.swift +++ b/Tests/PubNubTests/Networking/Session+URLErrorTests.swift @@ -8,7 +8,7 @@ // LICENSE file in the root directory of this source tree. // -@testable import PubNub +@testable import PubNubSDK import XCTest final class SessionURLErrorTests: XCTestCase { diff --git a/Tests/PubNubTests/PubNubConfigurationTests.swift b/Tests/PubNubTests/PubNubConfigurationTests.swift index 2424ade5..258a3935 100644 --- a/Tests/PubNubTests/PubNubConfigurationTests.swift +++ b/Tests/PubNubTests/PubNubConfigurationTests.swift @@ -8,7 +8,7 @@ // LICENSE file in the root directory of this source tree. // -@testable import PubNub +@testable import PubNubSDK import XCTest class PubNubConfigurationTests: XCTestCase { diff --git a/Tests/PubNubTests/PubNubTests.swift b/Tests/PubNubTests/PubNubTests.swift index 8a1546ea..ee249d3b 100644 --- a/Tests/PubNubTests/PubNubTests.swift +++ b/Tests/PubNubTests/PubNubTests.swift @@ -8,7 +8,7 @@ // LICENSE file in the root directory of this source tree. // -@testable import PubNub +@testable import PubNubSDK import XCTest final class PubNubTests: XCTestCase { diff --git a/Tests/PubNubTests/Push/PubNubPushTargetTests.swift b/Tests/PubNubTests/Push/PubNubPushTargetTests.swift index 05f19698..53abff2f 100644 --- a/Tests/PubNubTests/Push/PubNubPushTargetTests.swift +++ b/Tests/PubNubTests/Push/PubNubPushTargetTests.swift @@ -8,7 +8,7 @@ // LICENSE file in the root directory of this source tree. // -@testable import PubNub +@testable import PubNubSDK import XCTest class PubNubPushTargetTests: XCTestCase { diff --git a/Tests/PubNubTests/Subscription/SubscribeSessionFactoryTests.swift b/Tests/PubNubTests/Subscription/SubscribeSessionFactoryTests.swift index fa30d95c..f55bfe30 100644 --- a/Tests/PubNubTests/Subscription/SubscribeSessionFactoryTests.swift +++ b/Tests/PubNubTests/Subscription/SubscribeSessionFactoryTests.swift @@ -8,7 +8,7 @@ // LICENSE file in the root directory of this source tree. // -@testable import PubNub +@testable import PubNubSDK import XCTest class SubscribeSessionFactoryTests: XCTestCase { diff --git a/Tests/PubNubTests/Subscription/SubscriptionSessionTests.swift b/Tests/PubNubTests/Subscription/SubscriptionSessionTests.swift index fd182da2..c88464b0 100644 --- a/Tests/PubNubTests/Subscription/SubscriptionSessionTests.swift +++ b/Tests/PubNubTests/Subscription/SubscriptionSessionTests.swift @@ -27,7 +27,7 @@ import XCTest -@testable import PubNub +@testable import PubNubSDK class SubscriptionSessionTests: XCTestCase { let config = PubNubConfiguration(