Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
streamer45 committed Dec 20, 2024
1 parent a03083e commit 0625808
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions cmd/transcriber/call/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,18 @@ func TestPublishTranscriptions(t *testing.T) {
ModelSize: config.ModelSizeTiny,
}
cfg.SetDefaults()

tmpDir, err := os.MkdirTemp("", "")
require.NoError(t, err)
dataDir := os.Getenv("DATA_DIR")
os.Setenv("DATA_DIR", tmpDir)
defer os.Setenv("DATA_DIR", dataDir)

tr, err := NewTranscriber(cfg, GetDataDir(""))
require.NoError(t, err)
require.NotNil(t, tr)

t.Run("", func(t *testing.T) {
t.Run("invalid response", func(t *testing.T) {
err := tr.publishTranscription(transcribe.Transcription{})
require.EqualError(t, err, "failed to get filename for call: failed to get filename: AppErrorFromJSON: model.utils.decode_json.app_error, body: 404 page not found\n, json: cannot unmarshal number into Go value of type model.AppError")
})
Expand All @@ -97,11 +104,16 @@ func TestPublishTranscriptions(t *testing.T) {
},
}

tr.dataPath = "/invalid"
defer func() {
tr.dataPath = GetDataDir("")
}()

err := tr.publishTranscription(transcribe.Transcription{})
require.EqualError(t, err, fmt.Sprintf("failed to open output file: open %s: no such file or directory", filepath.Join(tr.dataPath, "Call_Test.vtt")))
})

vttFile, err := os.CreateTemp("", "Call_Test.vtt")
vttFile, err := os.CreateTemp(tmpDir, "Call_Test.vtt")
require.NoError(t, err)
defer os.Remove(vttFile.Name())

Expand All @@ -124,10 +136,6 @@ All right, we should be recording. Welcome everyone, developers meeting for Dece
`))
require.NoError(t, err)

dataDir := os.Getenv("DATA_DIR")
os.Setenv("DATA_DIR", filepath.Dir(vttFile.Name()))
defer os.Setenv("DATA_DIR", dataDir)

maxAPIRetryAttempts = 2

t.Run("upload session creation failure", func(t *testing.T) {
Expand Down

0 comments on commit 0625808

Please sign in to comment.