diff --git a/sdk/communication/AzureCommunicationChat/Tests/ChatClientDVRTests.swift b/sdk/communication/AzureCommunicationChat/Tests/ChatClientDVRTests.swift index 6a485d8a5..74f429a9c 100644 --- a/sdk/communication/AzureCommunicationChat/Tests/ChatClientDVRTests.swift +++ b/sdk/communication/AzureCommunicationChat/Tests/ChatClientDVRTests.swift @@ -35,7 +35,7 @@ class ChatClientDVRTests: XCTestCase { /// ChatClient initialized in setup. private var chatClient: ChatClient! - private var transport: DVRSessionTransport? + private var transport: TransportStage! /// Test mode. private var mode = environmentVariable(forKey: "TEST_MODE", default: "playback") @@ -47,7 +47,7 @@ class ChatClientDVRTests: XCTestCase { let fullname = self.name var testName = fullname.split(separator: " ")[1] testName.removeLast() - transport = DVRSessionTransport(cassetteName: String(testName)) + transport = mode != "live" ? DVRSessionTransport(cassetteName: String(testName)) : URLSessionTransport() let transportOptions = TransportOptions(transport: transport) let options = AzureCommunicationChatClientOptions(transportOptions: transportOptions) transport?.open() diff --git a/sdk/test/AzureTest/DVRSessionTransport.swift b/sdk/test/AzureTest/DVRSessionTransport.swift index d3d5c7178..fa767362f 100644 --- a/sdk/test/AzureTest/DVRSessionTransport.swift +++ b/sdk/test/AzureTest/DVRSessionTransport.swift @@ -64,8 +64,14 @@ public class DVRSessionTransport: TransportStage { } session = Session(outputDirectory: outputDirectory, cassetteName: cassetteName) if environmentVariable(forKey: "TEST_MODE", default: "playback") == "record" { + session?.recordMode = .all session?.recordingEnabled = true session?.beginRecording() + + } + else { // when live DVR isn't used, so anything else is treated as playback + session?.recordMode = .none + session?.recordingEnabled = false } }