Skip to content

Commit

Permalink
Inheriting SubscribeRouterTests and using different PNConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
jguz-pubnub committed Oct 27, 2023
1 parent d0b2a32 commit a350a1c
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 7 deletions.
4 changes: 4 additions & 0 deletions PubNub.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,7 @@
3D2D57252A8A1EEC00BEA8CB /* WaitEffect.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3D2D57242A8A1EEC00BEA8CB /* WaitEffect.swift */; };
3D371DE62A4EE20700953D7F /* PubNubEventEngineTestsHelpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3D371DE52A4EE20700953D7F /* PubNubEventEngineTestsHelpers.swift */; };
3D371DE72A4EE20700953D7F /* PubNubEventEngineTestsHelpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3D371DE52A4EE20700953D7F /* PubNubEventEngineTestsHelpers.swift */; };
3D5848A02AEBED5C00C20C92 /* SubscribeRouterWithEventEngineTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3D58489F2AEBED5C00C20C92 /* SubscribeRouterWithEventEngineTests.swift */; };
3D8773662A6130EC004A2953 /* Presence.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3D8773652A6130EC004A2953 /* Presence.swift */; };
3D8773682A613A58004A2953 /* PresenceTransition.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3D8773672A613A58004A2953 /* PresenceTransition.swift */; };
3D9134972A1216F7000A5124 /* PubNubPushTargetTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3D9134962A1216F7000A5124 /* PubNubPushTargetTests.swift */; };
Expand Down Expand Up @@ -953,6 +954,7 @@
3D2D57222A8A1AF100BEA8CB /* PresenceLeaveRequest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PresenceLeaveRequest.swift; sourceTree = "<group>"; };
3D2D57242A8A1EEC00BEA8CB /* WaitEffect.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WaitEffect.swift; sourceTree = "<group>"; };
3D371DE52A4EE20700953D7F /* PubNubEventEngineTestsHelpers.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PubNubEventEngineTestsHelpers.swift; sourceTree = "<group>"; };
3D58489F2AEBED5C00C20C92 /* SubscribeRouterWithEventEngineTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SubscribeRouterWithEventEngineTests.swift; sourceTree = "<group>"; };
3D8773652A6130EC004A2953 /* Presence.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Presence.swift; sourceTree = "<group>"; };
3D8773672A613A58004A2953 /* PresenceTransition.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PresenceTransition.swift; sourceTree = "<group>"; };
3D9134962A1216F7000A5124 /* PubNubPushTargetTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PubNubPushTargetTests.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1625,6 +1627,7 @@
35A6C7B622FBEA7200E97CC5 /* PushRouterTests.swift */,
359287B3231720C20046F7A2 /* PublishRouterTests.swift */,
359287BC23173D490046F7A2 /* SubscribeRouterTests.swift */,
3D58489F2AEBED5C00C20C92 /* SubscribeRouterWithEventEngineTests.swift */,
3557CDFF237F6380004BBACC /* TimeRouterTests.swift */,
35DA9AB42335491F00867989 /* ObjectsUUIDRouterTests.swift */,
3562DBC22345066F006DFFBC /* ObjectsChannelRouterTests.swift */,
Expand Down Expand Up @@ -3418,6 +3421,7 @@
35FE941B22EFE5400051C455 /* EventStreamTests.swift in Sources */,
35FE93C322EF57FA0051C455 /* Session+URLErrorTests.swift in Sources */,
35FE940122EF983A0051C455 /* Session+EndpointErrorTests.swift in Sources */,
3D5848A02AEBED5C00C20C92 /* SubscribeRouterWithEventEngineTests.swift in Sources */,
3D9B29FA2A65609000C988C9 /* EmitMessagesTests.swift in Sources */,
357AEB8422E6954600C18250 /* Collection+PubNubTests.swift in Sources */,
35D0615223035E4300FDB2F9 /* CryptoTests.swift in Sources */,
Expand Down
27 changes: 20 additions & 7 deletions Tests/PubNubTests/Networking/Routers/SubscribeRouterTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,32 @@
@testable import PubNub
import XCTest

final class SubscribeRouterTests: XCTestCase {
let config = PubNubConfiguration(
publishKey: "FakeTestString",
subscribeKey: "FakeTestString",
userId: UUID().uuidString,
enableEventEngine: false
)
class SubscribeRouterTests: XCTestCase {
var config: PubNubConfiguration!

let testChannel = "TestChannel"
let testAction = PubNubMessageActionBase(
actionType: "reaction", actionValue: "winky_face",
actionTimetoken: 15_725_459_793_173_220, messageTimetoken: 15_725_459_448_096_144,
publisher: "SomeUser", channel: "TestChannel", published: 15_725_459_794_105_070
)

// MARK: - Set Up

override func setUp() {
super.setUp()
config = PubNubConfiguration(
publishKey: "FakeTestString",
subscribeKey: "FakeTestString",
userId: UUID().uuidString,
enableEventEngine: false
)
}

override func tearDown() {
config = nil
super.tearDown()
}

// MARK: - Endpoint Tests

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
//
// SubscribeRouterWithEventEngineTests.swift
//
// PubNub Real-time Cloud-Hosted Push API and Push Notification Client Frameworks
// Copyright © 2023 PubNub Inc.
// https://www.pubnub.com/
// https://www.pubnub.com/terms
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//

import Foundation

@testable import PubNub

class SubscribeRouterWithEventEngineTests: SubscribeRouterTests {
override func setUp() {
super.setUp()
config = PubNubConfiguration(
publishKey: "FakeTestString",
subscribeKey: "FakeTestString",
userId: UUID().uuidString,
enableEventEngine: true
)
}

func test_SubscribeRouterWithEventEngineEnabled() {
// This class reuses all test cases from the parent class with different PubNubConfiguration.
// This empty replacement method was added so that the XCTest framework can also run these inherited test cases
}
}

0 comments on commit a350a1c

Please sign in to comment.