package asterisk import ( "context" "github.com/CyCoreSystems/ari/v5" "testing" "time" ) func TestLineTestUsesIsolatedApplicationAndNoMediaOrAI(t *testing.T) { events := make(chan ari.Event, 3) channels := &testChannels{events: events, dataErr: nativeHTTPStatusError{code: 404}} client := &testARIClient{channels: channels, bridges: &testBridges{}, bus: &testBus{sub: answerEvents{events: events}}} call, err := dialWithOptions(context.Background(), client, NativeDial{ExecutionID: "siptest-1", TrunkID: "siptest-shuqi", DialedCallee: "708918601010101", CallerID: "BD123", AnswerTimeout: time.Second, BindSIPCall: testBindSIPCall}, true) if err != nil { t.Fatal(err) } if channels.issued != 1 || channels.create.App != "sip-call" || call.Media != nil || len(client.bridges.attached) != 0 || channels.media.App != "" { t.Fatal("line test must send one Dial without ExternalMedia, bridge, or business application") } if err = call.Close(); err != nil { t.Fatal(err) } if !call.EndConfirmed() { t.Fatal("teardown must be confirmed") } } func TestLineTestDoesNotInventConfirmedTermination(t *testing.T) { events := make(chan ari.Event, 3) client := &testARIClient{channels: &testChannels{events: events}, bridges: &testBridges{}, bus: &testBus{sub: answerEvents{events: events}}} call, err := dialWithOptions(context.Background(), client, NativeDial{ExecutionID: "siptest-1", TrunkID: "siptest-shuqi", DialedCallee: "708918601010101", CallerID: "BD123", AnswerTimeout: time.Second, BindSIPCall: testBindSIPCall}, true) if err != nil { t.Fatal(err) } if err = call.Close(); err == nil { t.Fatal("an unconfirmed channel termination must report an error") } if call.EndConfirmed() { t.Fatal("successful Hangup HTTP is not proof that the channel disappeared") } }