From b738651b26ce1546f9df839ab6f0e47509a6ee88 Mon Sep 17 00:00:00 2001 From: Maksym Sobolyev Date: Tue, 28 May 2024 08:48:09 -0700 Subject: [PATCH] Add simple SipTransactionManager UT to expose issue in the PR#17. --- sippy/stm_test.go | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 sippy/stm_test.go diff --git a/sippy/stm_test.go b/sippy/stm_test.go new file mode 100644 index 0000000..a111237 --- /dev/null +++ b/sippy/stm_test.go @@ -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) + } +} \ No newline at end of file