Skip to content

Commit

Permalink
Merge pull request #107 from free5gc/fix/ut-failed
Browse files Browse the repository at this point in the history
fix: unit test failed
  • Loading branch information
ianchen0119 authored May 21, 2024
2 parents 6769b6f + 5e7392f commit 8c1d9b6
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
6 changes: 4 additions & 2 deletions internal/context/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,10 @@ type SMFContext struct {
}

func GenerateChargingID() int32 {
if id, err := smfContext.ChargingIDGenerator.Allocate(); err == nil {
return int32(id)
if smfContext.ChargingIDGenerator != nil {
if id, err := smfContext.ChargingIDGenerator.Allocate(); err == nil {
return int32(id)
}
}
return 0
}
Expand Down
3 changes: 2 additions & 1 deletion internal/context/sm_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,8 @@ func NewSMContext(id string, pduSessID int32) *SMContext {
smContext.ChargingInfo = make(map[uint32]*ChargingInfo)
smContext.ChargingID = GenerateChargingID()

if factory.SmfConfig.Configuration != nil {
if factory.SmfConfig != nil &&
factory.SmfConfig.Configuration != nil {
smContext.UrrReportTime = time.Duration(factory.SmfConfig.Configuration.UrrPeriod) * time.Second
smContext.UrrReportThreshold = factory.SmfConfig.Configuration.UrrThreshold
logger.CtxLog.Infof("UrrPeriod: %v", smContext.UrrReportTime)
Expand Down
6 changes: 6 additions & 0 deletions internal/context/sm_context_policy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -671,6 +671,12 @@ func TestApplyPccRules(t *testing.T) {
},
}
smctx.SelectedSessionRuleID = "SessRuleId-1"
smctx.DnnConfiguration = models.DnnConfiguration{
SessionAmbr: &models.Ambr{
Uplink: "1 Gbps",
Downlink: "1 Gbps",
},
}
err := smctx.AllocUeIP()
require.NoError(t, err)
err = smctx.SelectDefaultDataPath()
Expand Down

0 comments on commit 8c1d9b6

Please sign in to comment.