MCPcopy Create free account
hub / github.com/CyCoreSystems/ari-proxy / TestChannelPlay

Function TestChannelPlay

internal/integration/channel.go:762–827  ·  view source on GitHub ↗
(t *testing.T, s Server)

Source from the content-addressed store, hash-verified

760}
761
762func TestChannelPlay(t *testing.T, s Server) {
763 key := ari.NewKey(ari.ChannelKey, "c1")
764 var cd ari.ChannelData
765 cd.ID = "c1"
766 cd.Name = "channe1"
767 cd.State = "Up"
768
769 runTest("ok", t, s, func(t *testing.T, m *mock, cl ari.Client) {
770 pbkey := ari.NewKey(ari.PlaybackKey, "pb1")
771 expected := ari.NewPlaybackHandle(pbkey, m.Playback, nil)
772
773 m.Channel.On("Data", key).Return(&cd, nil)
774 m.Channel.On("Play", key, "playbackID", "sound:hello").Return(expected, nil)
775
776 h, err := cl.Channel().Play(key, "playbackID", "sound:hello")
777 if err != nil {
778 t.Errorf("Unexpected error in remote Play call: %s", err)
779 }
780 if h == nil {
781 t.Error("Expected non-nil handle")
782 } else if h.ID() != "playbackID" {
783 t.Errorf("Expected handle id '%s', got '%s'", h.ID(), "playbackID")
784 }
785
786 m.Shutdown()
787
788 m.Channel.AssertCalled(t, "Play", key, "playbackID", "sound:hello")
789 })
790
791 runTest("no-id", t, s, func(t *testing.T, m *mock, cl ari.Client) {
792 pbkey := ari.NewKey(ari.PlaybackKey, "pb1")
793 expected := ari.NewPlaybackHandle(pbkey, m.Playback, nil)
794
795 m.Channel.On("Data", key).Return(&cd, nil)
796 m.Channel.On("Play", key, nonEmpty, "sound:hello").Return(expected, nil)
797
798 h, err := cl.Channel().Play(key, "", "sound:hello")
799 if err != nil {
800 t.Errorf("Unexpected error in remote Play call: %s", err)
801 }
802 if h == nil {
803 t.Error("Expected non-nil handle")
804 }
805
806 m.Shutdown()
807
808 m.Channel.AssertCalled(t, "Play", key, nonEmpty, "sound:hello")
809 })
810
811 runTest("err", t, s, func(t *testing.T, m *mock, cl ari.Client) {
812 m.Channel.On("Data", key).Return(&cd, nil)
813 m.Channel.On("Play", key, "playbackID", "sound:hello").Return(nil, errors.New("error"))
814
815 h, err := cl.Channel().Play(key, "playbackID", "sound:hello")
816 if err == nil {
817 t.Errorf("Expected error in remote Play call")
818 }
819 if h != nil {

Callers 1

TestChannelPlayFunction · 0.92

Calls 5

runTestFunction · 0.85
ChannelMethod · 0.80
NewMethod · 0.80
PlayMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected