Skip to content

Commit

Permalink
fix: unit test failed
Browse files Browse the repository at this point in the history
  • Loading branch information
ianchen0119 committed May 21, 2024
1 parent 6769b6f commit 5e7392f
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 5e7392f

Please sign in to comment.