Skip to content

Commit

Permalink
Clean up temp file after test
Browse files Browse the repository at this point in the history
  • Loading branch information
lincmba committed Jan 8, 2025
1 parent 7f81ed6 commit c52f396
Showing 1 changed file with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,16 @@ class SpeechToTextTest {
val mockResponse = RecognizeResponse.newBuilder().addResults(mockResult).build()
every { mockSpeechClient.recognize(mockConfig, mockRecognitionAudio) } returns mockResponse

val resultFile = speechToText.transcribeAudioToText(mockAudioFile)
var resultFile: File? = null
try {
resultFile = speechToText.transcribeAudioToText(mockAudioFile)

assertNotNull(resultFile, "Result file should not be null")
assertTrue(resultFile.exists(), "Result file should exist")
assertEquals("Hello World", resultFile.readText(), "Transcription content should match")
assertNotNull(resultFile, "Result file should not be null")
assertTrue(resultFile.exists(), "Result file should exist")
assertEquals("Hello World", resultFile.readText(), "Transcription content should match")
} finally {
resultFile?.delete()
assertTrue(resultFile?.exists() == false, "Result file should be deleted")
}
}
}

0 comments on commit c52f396

Please sign in to comment.