Skip to content

Commit

Permalink
Fix uncaught exception crash in STT test
Browse files Browse the repository at this point in the history
  • Loading branch information
Mike Kistler committed May 18, 2018
1 parent ca0f987 commit 4e9a481
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions Tests/SpeechToTextV1Tests/SpeechToTextTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,11 @@ class SpeechToTextTests: XCTestCase {
let failure = { (error: Error) in XCTFail("Failed to lookup languageModel: \(error.localizedDescription)") }
speechToText.listLanguageModels(failure: failure) {
response in
let existingLanguageModel = response.customizations.first { $0.name == "swift-test-model" }
languageModel = existingLanguageModel ?? self.createTestLanguageModel()
languageModel = response.customizations.first { $0.name == "swift-test-model" }
expectation.fulfill()
}
wait(for: [expectation], timeout: timeout)
return languageModel
return languageModel ?? self.createTestLanguageModel()
}

func createTestLanguageModel() -> LanguageModel {
Expand All @@ -90,15 +89,15 @@ class SpeechToTextTests: XCTestCase {
func lookupOrCreateTestAcousticModel() -> AcousticModel {
var acousticModel: AcousticModel!
let expectation = self.expectation(description: "listAcousticModels")
let failure = { (error: Error) in XCTFail("Failed to lookup acousticModel: \(error.localizedDescription)") }
let failure = { (error: Error) in
XCTFail("Failed to lookup acousticModel: \(error.localizedDescription)") }
speechToText.listAcousticModels(failure: failure) {
response in
let existingAcousticModel = response.customizations.first { $0.name == "swift-test-model" }
acousticModel = existingAcousticModel ?? self.createTestAcousticModel()
acousticModel = response.customizations.first { $0.name == "swift-test-model" }
expectation.fulfill()
}
wait(for: [expectation], timeout: timeout)
return acousticModel
return acousticModel ?? self.createTestAcousticModel()
}

func createTestAcousticModel() -> AcousticModel {
Expand Down

0 comments on commit 4e9a481

Please sign in to comment.