Skip to content

Commit

Permalink
refactor: add test and remove unused
Browse files Browse the repository at this point in the history
  • Loading branch information
siyul-park committed Nov 26, 2023
1 parent 1b2ef00 commit 590ff8e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 13 deletions.
13 changes: 0 additions & 13 deletions pkg/symbol/table.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,19 +168,6 @@ func (t *Table) insert(sym *Symbol) error {
t.unlinks[sym.ID()] = unlinks
}

for name, locations := range t.linked[sym.ID()] {
p1, ok := sym.Port(name)
if !ok {
continue
}
for _, location := range locations {
ref := t.symbols[location.ID]
if p2, ok := ref.Port(location.Port); ok {
p1.Link(p2)
}
}
}

if err := t.load(sym); err != nil {
return err
}

Check warning on line 173 in pkg/symbol/table.go

View check run for this annotation

Codecov / codecov/patch

pkg/symbol/table.go#L172-L173

Added lines #L172 - L173 were not covered by tests
Expand Down
21 changes: 21 additions & 0 deletions pkg/symbol/table_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package symbol
import (
"testing"

"github.com/go-faker/faker/v4"
"github.com/oklog/ulid/v2"
"github.com/siyul-park/uniflow/pkg/node"
"github.com/siyul-park/uniflow/pkg/scheme"
Expand Down Expand Up @@ -267,3 +268,23 @@ func TestTable_LookupByID(t *testing.T) {
assert.True(t, ok)
assert.Equal(t, sym, r)
}

func TestTable_LookupByName(t *testing.T) {
tb := NewTable()
defer tb.Close()

n := node.NewOneToOneNode(node.OneToOneNodeConfig{})
defer n.Close()
spec := &scheme.SpecMeta{
ID: n.ID(),
Namespace: scheme.NamespaceDefault,
Name: faker.Word(),
}
sym := &Symbol{Node: n, Spec: spec}

_ = tb.Insert(sym)

r, ok := tb.LookupByName(spec.GetNamespace(), spec.GetName())
assert.True(t, ok)
assert.Equal(t, sym, r)
}

0 comments on commit 590ff8e

Please sign in to comment.