Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Env Variable TEST_MODE works as expected #909

Merged
merged 6 commits into from
Jun 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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()
Expand Down
6 changes: 6 additions & 0 deletions sdk/test/AzureTest/DVRSessionTransport.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

Expand Down