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

Function TestChannelCreate

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

Source from the content-addressed store, hash-verified

425}
426
427func TestChannelCreate(t *testing.T, s Server) {
428 runTest("ok", t, s, func(t *testing.T, m *mock, cl ari.Client) {
429 req := ari.ChannelCreateRequest{}
430 req.App = "App"
431 req.ChannelID = "1234"
432
433 chkey := ari.NewKey(ari.ChannelKey, "ch2")
434 expected := ari.NewChannelHandle(chkey, m.Channel, nil)
435
436 m.Channel.On("Create", &ari.Key{Kind: "", ID: "", Node: "", Dialog: "", App: ""}, req).Return(expected, nil)
437
438 h, err := cl.Channel().Create(nil, req)
439 if err != nil {
440 t.Errorf("Unexpected error in remote Create call: %s", err)
441 }
442 if h == nil {
443 t.Errorf("Expected non-nil channel handle")
444 } else if h.ID() != req.ChannelID {
445 t.Errorf("Expected handle id '%s', got '%s'", h.ID(), req.ChannelID)
446 }
447
448 m.Shutdown()
449
450 m.Channel.AssertCalled(t, "Create", &ari.Key{Kind: "", ID: "", Node: "", Dialog: "", App: ""}, ari.ChannelCreateRequest{App: "App", ChannelID: "1234"})
451 })
452
453 runTest("err", t, s, func(t *testing.T, m *mock, cl ari.Client) {
454 req := ari.ChannelCreateRequest{}
455 req.App = "App"
456 req.ChannelID = "1234"
457
458 m.Channel.On("Create", &ari.Key{Kind: "", ID: "", Node: "", Dialog: "", App: ""}, req).Return(nil, errors.New("error"))
459
460 h, err := cl.Channel().Create(nil, req)
461 if err == nil {
462 t.Errorf("Expected error in remote Create call")
463 }
464 if h != nil {
465 t.Errorf("Expected nil channel handle")
466 }
467
468 m.Shutdown()
469
470 m.Channel.AssertCalled(t, "Create", &ari.Key{Kind: "", ID: "", Node: "", Dialog: "", App: ""}, ari.ChannelCreateRequest{App: "App", ChannelID: "1234"})
471 })
472}
473
474func TestChannelContinue(t *testing.T, s Server) {
475 key := ari.NewKey(ari.ChannelKey, "c1")

Callers 1

TestChannelCreateFunction · 0.92

Calls 4

runTestFunction · 0.85
ChannelMethod · 0.80
NewMethod · 0.80
CreateMethod · 0.45

Tested by

no test coverage detected