Skip to content

Commit

Permalink
Env Variable TEST_MODE works as expected (#909)
Browse files Browse the repository at this point in the history
* Environment Variable for sdk root

Enforce that DVR record-playback honors environment variables

* Environment Variables work as intended with the new DVR updates

* Undo Podfile Changes

Local Changes that need to be removed

* Slight edit to record mode

Co-authored-by: Jair Myree <[email protected]>
  • Loading branch information
jairmyree and Jair Myree authored Jun 17, 2021
1 parent 869d673 commit 3e94533
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
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

0 comments on commit 3e94533

Please sign in to comment.