package asterisk import ( "fmt" "os" "testing" "time" "github.com/CyCoreSystems/ari/v5" ) // This opt-in diagnostic only Creates and Hangups an ARI channel. It never calls // Dial, creates media resources, or sends SIP INVITE. func TestNativeChannelEndHostNonDialing(t *testing.T) { if os.Getenv("GO_SIP_END_ONLY_DIAGNOSTIC") != "1" { t.Skip("explicit non-dialing test-host authorization required") } directory := os.Getenv("GO_SIP_END_ONLY_CONFIG_DIR") endpoint := os.Getenv("GO_SIP_END_ONLY_ENDPOINT") if directory == "" || endpoint == "" { t.Fatal("private Asterisk config directory and already-loaded endpoint required") } client, err := (Loader{ConfigDir: directory}).OpenLineTestARI() if err != nil { t.Fatal(err) } id := fmt.Sprintf("siptest-end-only-%d", time.Now().UnixNano()) handle, err := client.Channel().Create(nil, ari.ChannelCreateRequest{ChannelID: id, Endpoint: endpoint, App: "sip-call"}) if err != nil { client.Close() t.Fatal(err) } call := &NativeCall{client: client, outbound: handle, verifyEnd: true} defer call.Close() if err = call.Close(); err != nil { t.Fatal(err) } if !call.EndConfirmed() { t.Fatal("exact channel disappearance not confirmed") } t.Log("non-dialing native channel teardown confirmed; Dial not invoked") }