Skip to content

Commit

Permalink
Fixed UTs
Browse files Browse the repository at this point in the history
  • Loading branch information
Abinaya-Shunmugavel committed Jul 20, 2023
1 parent 23b81f9 commit 2c0378d
Show file tree
Hide file tree
Showing 4 changed files with 120 additions and 114 deletions.
16 changes: 0 additions & 16 deletions calls.go
Original file line number Diff line number Diff line change
Expand Up @@ -278,22 +278,6 @@ type CallStreamGetSpecific struct {
StreamID string `json:"stream_id" url:"stream_id"`
}

type VoiceInteractionResponse struct {
StartTime string `json:"start_time,omitempty" url:"start_time,omitempty"`
EndTime string `json:"end_time,omitempty" url:"end_time,omitempty"`
FirstPartyResourceUrl string `json:"first_party_resource_url,omitempty" url:"first_party_resource_url,omitempty"`
SecondPartyResourceUrl string `json:"second_party_resource_url,omitempty" url:"second_party_resource_url,omitempty"`
FirstPartyStatus string `json:"first_party_status,omitempty" url:"first_party_status,omitempty"`
SecondPartyStatus string `json:"second_party_status,omitempty" url:"second_party_status,omitempty"`
Type string `json:"type,omitempty" url:"type,omitempty"`
TotalCallAmount float64 `json:"total_call_amount,omitempty" url:"total_call_amount,omitempty"`
CallBilledDuration int `json:"call_billed_duration,omitempty" url:"call_billed_duration,omitempty"`
RecordingResourceUrl string `json:"recording_resource_url,omitempty" url:"recording_resource_url,omitempty"`
AuthID string `json:"auth_id,omitempty" url:"auth_id,omitempty"`
TotalCallCount int `json:"total_call_count" url:"total_call_count"`
Duration float64 `json:"duration" url:"duration"`
}

func (service *CallService) List(params CallListParams) (response *CallListResponse, err error) {
req, err := service.client.NewRequest("GET", params, "Call")
if err != nil {
Expand Down
98 changes: 0 additions & 98 deletions calls_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -366,101 +366,3 @@ func TestCallService_GetAllStreams(t *testing.T) {

assertRequest(t, "GET", "Call/%s/Stream", CallID)
}

func TestCallService_CreateMaskingSession(t *testing.T) {
expectResponse("createMaskingSessionResponse.json", 200)

if _, err := client.MaskingSession.CreateMaskingSession(CreateMaskingSessionParams{}); err != nil {
panic(err)
}

cl := client.httpClient
client.httpClient = nil
_, err := client.MaskingSession.CreateMaskingSession(CreateMaskingSessionParams{})
if err == nil {
client.httpClient = cl
panic(errors.New("error expected"))
}
client.httpClient = cl

assertRequest(t, "POST", "Masking/Session")
}

func TestCallService_DeleteMaskingSession(t *testing.T) {
expectResponse("deleteMaskingSessionResponse.json", 204)
SessionUuid := "15e4256c-be01-475c-9a69-95cf65bbed71"

if _, err := client.MaskingSession.DeleteMaskingSession(SessionUuid); err != nil {
panic(err)
}

cl := client.httpClient
client.httpClient = nil
_, err := client.MaskingSession.DeleteMaskingSession(SessionUuid)
if err == nil {
client.httpClient = cl
panic(errors.New("error expected"))
}
client.httpClient = cl

assertRequest(t, "DELETE", "Masking/Session/%s", SessionUuid)
}

func TestCallService_GetMaskingSession(t *testing.T) {
expectResponse("getMaskingSessionResponse.json", 200)
SessionUuid := "15e4256c-be01-475c-9a69-95cf65bbed71"

if _, err := client.MaskingSession.GetMaskingSession(SessionUuid); err != nil {
panic(err)
}

cl := client.httpClient
client.httpClient = nil
_, err := client.MaskingSession.GetMaskingSession(SessionUuid)
if err == nil {
client.httpClient = cl
panic(errors.New("error expected"))
}
client.httpClient = cl

assertRequest(t, "GET", "Masking/Session/%s", SessionUuid)
}

func TestCallService_updateMaskingSession(t *testing.T) {
expectResponse("updateMaskingSessionResponse.json", 204)
SessionUuid := "15e4256c-be01-475c-9a69-95cf65bbed71"

if _, err := client.MaskingSession.UpdateMaskingSession(UpdateMaskingSessionParams{}, SessionUuid); err != nil {
panic(err)
}

cl := client.httpClient
client.httpClient = nil
_, err := client.MaskingSession.UpdateMaskingSession(UpdateMaskingSessionParams{}, SessionUuid)
if err == nil {
client.httpClient = cl
panic(errors.New("error expected"))
}
client.httpClient = cl

assertRequest(t, "POST", "Masking/Session/%s", SessionUuid)
}

func TestCallService_ListMaskingSession(t *testing.T) {
expectResponse("listMaskingSessionResponse.json", 204)

if _, err := client.MaskingSession.ListMaskingSession(ListSessionFilterParams{}); err != nil {
panic(err)
}

cl := client.httpClient
client.httpClient = nil
_, err := client.MaskingSession.ListMaskingSession(ListSessionFilterParams{})
if err == nil {
client.httpClient = cl
panic(errors.New("error expected"))
}
client.httpClient = cl

assertRequest(t, "GET", "Masking/Session")
}
16 changes: 16 additions & 0 deletions maskingsession.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,22 @@ type ListSessionFilterParams struct {
Offset int64 `json:"offset,omitempty" url:"offset,omitempty"`
}

type VoiceInteractionResponse struct {
StartTime string `json:"start_time,omitempty" url:"start_time,omitempty"`
EndTime string `json:"end_time,omitempty" url:"end_time,omitempty"`
FirstPartyResourceUrl string `json:"first_party_resource_url,omitempty" url:"first_party_resource_url,omitempty"`
SecondPartyResourceUrl string `json:"second_party_resource_url,omitempty" url:"second_party_resource_url,omitempty"`
FirstPartyStatus string `json:"first_party_status,omitempty" url:"first_party_status,omitempty"`
SecondPartyStatus string `json:"second_party_status,omitempty" url:"second_party_status,omitempty"`
Type string `json:"type,omitempty" url:"type,omitempty"`
TotalCallAmount float64 `json:"total_call_amount,omitempty" url:"total_call_amount,omitempty"`
CallBilledDuration int `json:"call_billed_duration,omitempty" url:"call_billed_duration,omitempty"`
RecordingResourceUrl string `json:"recording_resource_url,omitempty" url:"recording_resource_url,omitempty"`
AuthID string `json:"auth_id,omitempty" url:"auth_id,omitempty"`
TotalCallCount int `json:"total_call_count" url:"total_call_count"`
Duration float64 `json:"duration" url:"duration"`
}

type CreateMaskingSessionResponse struct {
ApiID string `json:"api_id,omitempty" url:"api_id,omitempty"`
SessionUUID string `json:"session_uuid,omitempty" url:"session_uuid,omitempty"`
Expand Down
104 changes: 104 additions & 0 deletions maskingsession_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
package plivo

import (
"errors"
"testing"
)

func TestCallService_CreateMaskingSession(t *testing.T) {
expectResponse("createMaskingSessionResponse.json", 200)

if _, err := client.MaskingSession.CreateMaskingSession(CreateMaskingSessionParams{}); err != nil {
panic(err)
}

cl := client.httpClient
client.httpClient = nil
_, err := client.MaskingSession.CreateMaskingSession(CreateMaskingSessionParams{})
if err == nil {
client.httpClient = cl
panic(errors.New("error expected"))
}
client.httpClient = cl

assertRequest(t, "POST", "Masking/Session")
}

func TestCallService_DeleteMaskingSession(t *testing.T) {
expectResponse("deleteMaskingSessionResponse.json", 204)
SessionUuid := "15e4256c-be01-475c-9a69-95cf65bbed71"

if _, err := client.MaskingSession.DeleteMaskingSession(SessionUuid); err != nil {
panic(err)
}

cl := client.httpClient
client.httpClient = nil
_, err := client.MaskingSession.DeleteMaskingSession(SessionUuid)
if err == nil {
client.httpClient = cl
panic(errors.New("error expected"))
}
client.httpClient = cl

assertRequest(t, "DELETE", "Masking/Session/%s", SessionUuid)
}

func TestCallService_GetMaskingSession(t *testing.T) {
expectResponse("getMaskingSessionResponse.json", 200)
SessionUuid := "15e4256c-be01-475c-9a69-95cf65bbed71"

if _, err := client.MaskingSession.GetMaskingSession(SessionUuid); err != nil {
panic(err)
}

cl := client.httpClient
client.httpClient = nil
_, err := client.MaskingSession.GetMaskingSession(SessionUuid)
if err == nil {
client.httpClient = cl
panic(errors.New("error expected"))
}
client.httpClient = cl

assertRequest(t, "GET", "Masking/Session/%s", SessionUuid)
}

func TestCallService_updateMaskingSession(t *testing.T) {
expectResponse("updateMaskingSessionResponse.json", 204)
SessionUuid := "15e4256c-be01-475c-9a69-95cf65bbed71"

if _, err := client.MaskingSession.UpdateMaskingSession(UpdateMaskingSessionParams{}, SessionUuid); err != nil {
panic(err)
}

cl := client.httpClient
client.httpClient = nil
_, err := client.MaskingSession.UpdateMaskingSession(UpdateMaskingSessionParams{}, SessionUuid)
if err == nil {
client.httpClient = cl
panic(errors.New("error expected"))
}
client.httpClient = cl

assertRequest(t, "POST", "Masking/Session/%s", SessionUuid)
}

func TestCallService_ListMaskingSession(t *testing.T) {
expectResponse("listMaskingSessionResponse.json", 204)

if _, err := client.MaskingSession.ListMaskingSession(ListSessionFilterParams{}); err != nil {
panic(err)
}

cl := client.httpClient
client.httpClient = nil
_, err := client.MaskingSession.ListMaskingSession(ListSessionFilterParams{})
if err == nil {
client.httpClient = cl
panic(errors.New("error expected"))
}
client.httpClient = cl

assertRequest(t, "GET", "Masking/Session")
}

0 comments on commit 2c0378d

Please sign in to comment.