mirror of
https://github.com/tailscale/tailscale.git
synced 2025-08-22 02:50:42 +00:00
portlist: add a synchronous Poll method
This is a follow up on PR #8172 that adds a synchronous Poll method which allows for the Poller to be used as a zero value without needing the constructor. The local backend is also changed to use the new API. A follow up PR will remove the async functionality from the portlist package. Updates #8171 Signed-off-by: Marwan Sulaiman <marwan@tailscale.com>
This commit is contained in:

committed by
Marwan Sulaiman

parent
d3c8c3dd00
commit
5dd0b02133
@@ -175,12 +175,33 @@ func TestEqualLessThan(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestClose(t *testing.T) {
|
||||
var p Poller
|
||||
err := p.Close()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
p = Poller{}
|
||||
_, _, err = p.Poll()
|
||||
if err != nil {
|
||||
t.Skipf("skipping due to poll error: %v", err)
|
||||
}
|
||||
err = p.Close()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestPoller(t *testing.T) {
|
||||
p, err := NewPoller()
|
||||
if err != nil {
|
||||
t.Skipf("not running test: %v", err)
|
||||
}
|
||||
defer p.Close()
|
||||
t.Cleanup(func() {
|
||||
if err := p.Close(); err != nil {
|
||||
t.Errorf("error closing poller in test: %v", err)
|
||||
}
|
||||
})
|
||||
|
||||
var wg sync.WaitGroup
|
||||
wg.Add(2)
|
||||
|
Reference in New Issue
Block a user