Code Review
/
ric-plt
/
appmgr.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
Improve appmgr UT coverage
[ric-plt/appmgr.git]
/
pkg
/
resthooks
/
resthooks.go
diff --git
a/pkg/resthooks/resthooks.go
b/pkg/resthooks/resthooks.go
index
471eec1
..
9ac49f9
100755
(executable)
--- a/
pkg/resthooks/resthooks.go
+++ b/
pkg/resthooks/resthooks.go
@@
-22,20
+22,24
@@
package resthooks
import (
"bytes"
"encoding/json"
import (
"bytes"
"encoding/json"
- sdl "gerrit.o
ran-o
sc.org/r/ric-plt/sdlgo"
+ sdl "gerrit.o
-ran-
sc.org/r/ric-plt/sdlgo"
cmap "github.com/orcaman/concurrent-map"
"github.com/segmentio/ksuid"
"net/http"
"time"
cmap "github.com/orcaman/concurrent-map"
"github.com/segmentio/ksuid"
"net/http"
"time"
- "gerrit.o
ran-o
sc.org/r/ric-plt/appmgr/pkg/appmgr"
- "gerrit.o
ran-o
sc.org/r/ric-plt/appmgr/pkg/models"
+ "gerrit.o
-ran-
sc.org/r/ric-plt/appmgr/pkg/appmgr"
+ "gerrit.o
-ran-
sc.org/r/ric-plt/appmgr/pkg/models"
)
func NewResthook(restoreData bool) *Resthook {
)
func NewResthook(restoreData bool) *Resthook {
+ return createResthook(restoreData, sdl.NewSdlInstance("appmgr", sdl.NewDatabase()))
+}
+
+func createResthook(restoreData bool, sdlInst iSdl) *Resthook {
rh := &Resthook{
client: &http.Client{},
rh := &Resthook{
client: &http.Client{},
- db: sdl
.NewSdlInstance("appmgr", sdl.NewDatabase())
,
+ db: sdl
Inst
,
}
if restoreData {
}
if restoreData {
@@
-51,7
+55,8
@@
func (rh *Resthook) AddSubscription(sr models.SubscriptionRequest) *models.Subsc
r := v.Val.(SubscriptionInfo).req
if *r.Data.TargetURL == *sr.Data.TargetURL && r.Data.EventType == sr.Data.EventType {
appmgr.Logger.Info("Similar subscription already exists!")
r := v.Val.(SubscriptionInfo).req
if *r.Data.TargetURL == *sr.Data.TargetURL && r.Data.EventType == sr.Data.EventType {
appmgr.Logger.Info("Similar subscription already exists!")
- return &models.SubscriptionResponse{}
+ resp := v.Val.(SubscriptionInfo).resp
+ return &resp
}
}
}
}
@@
-175,7
+180,6
@@
func (rh *Resthook) retry(s SubscriptionInfo, fn func() error) error {
func (rh *Resthook) StoreSubscriptions(m cmap.ConcurrentMap) {
for v := range m.Iter() {
s := v.Val.(SubscriptionInfo)
func (rh *Resthook) StoreSubscriptions(m cmap.ConcurrentMap) {
for v := range m.Iter() {
s := v.Val.(SubscriptionInfo)
-
data, err := json.Marshal(s.req)
if err != nil {
appmgr.Logger.Error("json.marshal failed: %v ", err.Error())
data, err := json.Marshal(s.req)
if err != nil {
appmgr.Logger.Error("json.marshal failed: %v ", err.Error())