Skip to content

Commit

Permalink
test(foundation): Optimize code (#103)
Browse files Browse the repository at this point in the history
* feat(foundation): Added two system-level events.

Signed-off-by: Flc゛ <four_leaf_clover@foxmail.com>

* feat(foundation): Added two system-level events.

Signed-off-by: Flc゛ <four_leaf_clover@foxmail.com>

* test(foundation): Optimize code

Signed-off-by: Flc゛ <four_leaf_clover@foxmail.com>

---------

Signed-off-by: Flc゛ <four_leaf_clover@foxmail.com>
  • Loading branch information
flc1125 authored Feb 17, 2024
1 parent feb640a commit 1b668b4
Showing 1 changed file with 3 additions and 15 deletions.
18 changes: 3 additions & 15 deletions foundation/foundation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@ package foundation

import (
"context"
"fmt"
"sync"
"testing"
"time"

"github.com/stretchr/testify/assert"

Expand Down Expand Up @@ -53,11 +51,11 @@ func TestBootAndShut(t *testing.T) {
shut = NewShutdown(WithManager(m), WithDispatcher(d))
)
wg.Add(4)
assert.Equal(t, 0, len(c))

go func() {
defer wg.Done()
if <-m.Until(BootstrapName).Done(); true {
fmt.Println("bootstrap done")
c <- "bootstrap done"
}
}()
Expand All @@ -74,17 +72,7 @@ func TestBootAndShut(t *testing.T) {
assert.NoError(t, boot(context.Background()))
assert.NoError(t, shut(context.Background()))

// wg.Wait()
wg.Wait()

// assert.Equal(t, 4, len(c))
time.Sleep(time.Second)

for {
select {
case v := <-c:
fmt.Println(v)
default:
return
}
}
assert.Equal(t, 4, len(c))
}

0 comments on commit 1b668b4

Please sign in to comment.