Add names to service and router. Add more store tests. Fixes GH-101

This commit is contained in:
Paul Lorenz
2020-06-18 14:36:58 -04:00
parent 68fd06d4e6
commit ffbb4e4cc3
17 changed files with 613 additions and 142 deletions
+2 -2
View File
@@ -25,8 +25,8 @@ import (
func TestLifecycle(t *testing.T) {
linkController := newLinkController()
r0 := NewRouter("r0", "")
r1 := NewRouter("r1", "")
r0 := NewRouter("r0", "", "")
r1 := NewRouter("r1", "", "")
l0 := &Link{
Id: &identity.TokenId{Token: "l0"},
Src: r0,
+8 -1
View File
@@ -30,6 +30,7 @@ import (
type Router struct {
models.BaseEntity
Name string
Fingerprint *string
AdvertisedListener string
Control channel2.Channel
@@ -42,6 +43,7 @@ func (entity *Router) fillFrom(_ Controller, _ *bbolt.Tx, boltEntity boltz.Entit
if !ok {
return errors.Errorf("unexpected type %v when filling model router", reflect.TypeOf(boltEntity))
}
entity.Name = boltRouter.Name
entity.Fingerprint = boltRouter.Fingerprint
entity.FillCommon(boltRouter)
return nil
@@ -50,13 +52,18 @@ func (entity *Router) fillFrom(_ Controller, _ *bbolt.Tx, boltEntity boltz.Entit
func (entity *Router) toBolt() *db.Router {
return &db.Router{
BaseExtEntity: *boltz.NewExtEntity(entity.Id, entity.Tags),
Name: entity.Name,
Fingerprint: entity.Fingerprint,
}
}
func NewRouter(id, fingerprint string) *Router {
func NewRouter(id, name, fingerprint string) *Router {
if name == "" {
name = id
}
return &Router{
BaseEntity: models.BaseEntity{Id: id},
Name: name,
Fingerprint: &fingerprint,
}
}
+3
View File
@@ -29,6 +29,7 @@ import (
type Service struct {
models.BaseEntity
Name string
TerminatorStrategy string
Terminators []*Terminator
}
@@ -38,6 +39,7 @@ func (entity *Service) fillFrom(ctrl Controller, tx *bbolt.Tx, boltEntity boltz.
if !ok {
return errors.Errorf("unexpected type %v when filling model service", reflect.TypeOf(boltEntity))
}
entity.Name = boltService.Name
entity.TerminatorStrategy = boltService.TerminatorStrategy
entity.FillCommon(boltService)
@@ -54,6 +56,7 @@ func (entity *Service) fillFrom(ctrl Controller, tx *bbolt.Tx, boltEntity boltz.
func (entity *Service) toBolt() *db.Service {
return &db.Service{
BaseExtEntity: *boltz.NewExtEntity(entity.Id, entity.Tags),
Name: entity.Name,
TerminatorStrategy: entity.TerminatorStrategy,
}
}