generated from TrueCloudLab/basic
engine: Extend with target listing method #47
3 changed files with 16 additions and 0 deletions
|
@ -136,3 +136,14 @@ func (s *inmemoryLocalStorage) DropAllOverrides(name chain.Name) error {
|
|||
s.nameToResourceChains[name] = make(targetToChain)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *inmemoryLocalStorage) ListOverrideDefinedTargets(name chain.Name) ([]engine.Target, error) {
|
||||
s.guard.RLock()
|
||||
defer s.guard.RUnlock()
|
||||
ttc := s.nameToResourceChains[name]
|
||||
var keys []engine.Target
|
||||
for k := range ttc {
|
||||
keys = append(keys, k)
|
||||
}
|
||||
return keys, nil
|
||||
}
|
||||
|
|
|
@ -184,6 +184,9 @@ func TestListOverrides(t *testing.T) {
|
|||
inmem.AddOverride(chain.Ingress, resrc, addChain)
|
||||
l, _ := inmem.ListOverrides(chain.Ingress, resrc)
|
||||
require.Len(t, l, 1)
|
||||
targets, err := inmem.ListOverrideDefinedTargets(chain.Ingress)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, []engine.Target{resrc}, targets)
|
||||
})
|
||||
|
||||
t.Run("list after drop", func(t *testing.T) {
|
||||
|
|
|
@ -24,6 +24,8 @@ type LocalOverrideStorage interface {
|
|||
ListOverrides(name chain.Name, target Target) ([]*chain.Chain, error)
|
||||
|
||||
DropAllOverrides(name chain.Name) error
|
||||
|
||||
ListOverrideDefinedTargets(name chain.Name) ([]Target, error)
|
||||
}
|
||||
|
||||
type TargetType rune
|
||||
|
|
Loading…
Reference in a new issue