Skip to content

Commit

Permalink
VT-8411:unitTestCaseAdded
Browse files Browse the repository at this point in the history
  • Loading branch information
ajay-plivo committed Nov 7, 2024
1 parent d6f88e6 commit fbaf8de
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 3 deletions.
10 changes: 7 additions & 3 deletions transcription.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ type RecordingTranscriptionRequest struct {
RecordingID string `json:"recording_id"`
}

type DeleteRecordingTranscriptionRequest struct {
TranscriptionID string `json:"transcription_id"`
}

type GetRecordingTranscriptionParams struct {
Type string `url:"type"`
}
Expand All @@ -33,7 +37,7 @@ func (service *TranscriptionService) CreateRecordingTranscription(request Record
return
}
response = make(map[string]interface{})
err = service.client.ExecuteRequest(req, response, isVoiceRequest())
err = service.client.ExecuteRequest(req, &response, isVoiceRequest())
return
}

Expand All @@ -50,8 +54,8 @@ func (service *TranscriptionService) GetRecordingTranscription(request GetRecord
return
}

func (service *TranscriptionService) DeleteRecordingTranscription(request RecordingTranscriptionRequest) (response map[string]interface{}, err error) {
req, err := service.client.NewRequest("DELETE", nil, "Transcription/%s", request.RecordingID)
func (service *TranscriptionService) DeleteRecordingTranscription(request DeleteRecordingTranscriptionRequest) (response map[string]interface{}, err error) {
req, err := service.client.NewRequest("DELETE", nil, "Transcription/%s", request.TranscriptionID)
if err != nil {
return
}
Expand Down
23 changes: 23 additions & 0 deletions transcription_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package plivo

import (
"encoding/json"
"errors"
"testing"
)
Expand Down Expand Up @@ -45,3 +46,25 @@ func TestTranscriptionService_GetRecordingTranscriptionWithParam(t *testing.T) {
}
client.httpClient = cl
}

func TestTranscriptionService_CreateRecordingTranscription(t *testing.T) {
expectResponse("createRecordingTranscription.json", 200)
var response map[string]interface{}
if err := json.Unmarshal([]byte(expectedResponse), &response); err != nil {
t.Fatalf("failed to unmarshal expected response: %v", err)
}
if _, err := client.Transcription.CreateRecordingTranscription(RecordingTranscriptionRequest{
RecordingID: "e12d05fe-6979-485c-83dc-9276114dba3b",
}); err != nil {
panic(err)
}

cl := client.httpClient
client.httpClient = nil
_, err := client.Transcription.CreateRecordingTranscription(RecordingTranscriptionRequest{})
if err == nil {
client.httpClient = cl
panic(errors.New("error expected"))
}
client.httpClient = cl
}

0 comments on commit fbaf8de

Please sign in to comment.