defmodule MedicalTranscription.TranscriptionServerTest do | |
@moduledoc """ | |
Tests for MedicalTranscription.TranscriptionServer | |
""" | |
use MedicalTranscription.DataCase | |
import MedicalTranscription.TranscriptionsFixtures | |
alias MedicalTranscription.TranscriptionServer | |
setup do | |
sample_file = | |
__DIR__ | |
|> Path.join("../../medasrdemo-Paul.mp3") | |
|> Path.expand() | |
transcription = transcription_fixture(%{filename: sample_file}) | |
%{transcription: transcription} | |
end | |
test "transcribe and tag audio", %{transcription: transcription} do | |
spec = {TranscriptionServer, transcription: transcription} | |
{:ok, pid} = start_supervised(spec) | |
# NOTE: Monitoring the async process to ensure it completes | |
# before asserting results. See https://elixirforum.com/t/whats-the-correct-way-to-handle-async-tasks-i-dont-care-about-in-an-exunit-test-error-postgrex-protocol-disconnected/36605/2 | |
# for further explanation. | |
ref = Process.monitor(pid) | |
assert_receive({:DOWN, ^ref, :process, _object, _pid}, 5_000) | |
end | |
end | |