Skip to content

Commit

Permalink
Add simple SipTransactionManager UT to expose issue in the PR#17.
Browse files Browse the repository at this point in the history
  • Loading branch information
sobomax committed May 28, 2024
1 parent b25d797 commit b738651
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions sippy/stm_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package sippy

import (
"testing"
"runtime"

"github.com/sippy/go-b2bua/sippy/conf"
"github.com/sippy/go-b2bua/sippy/log"
)

func Test_SipTransactionManager(t *testing.T) {
var err error

error_logger := sippy_log.NewErrorLogger()
sip_logger := NewTestSipLogger()
config := sippy_conf.NewConfig(error_logger, sip_logger)
config.SetSipAddress(config.GetMyAddress())
config.SetSipPort(config.GetMyPort())
cmap := NewTestCallMap(config)
tfactory := NewTestSipTransportFactory()
config.SetSipTransportFactory(tfactory)
numGoroutinesBefore := runtime.NumGoroutine()
cmap.sip_tm, err = NewSipTransactionManager(config, cmap)
if err != nil {
t.Fatal("Cannot create SIP transaction manager: " + err.Error())
}
go cmap.sip_tm.Run()
cmap.sip_tm.Shutdown()
numGoroutinesAfter := runtime.NumGoroutine()
if numGoroutinesBefore != numGoroutinesAfter {
t.Fatalf("numGoroutinesBefore = %d, numGoroutinesAfter = %d\n", numGoroutinesBefore, numGoroutinesAfter)
}
}

0 comments on commit b738651

Please sign in to comment.