From 1b668b4cb1d78bf8294c72b8096666a7f92134a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Flc=E3=82=9B?= Date: Sat, 17 Feb 2024 17:54:38 +0800 Subject: [PATCH] test(foundation): Optimize code (#103) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat(foundation): Added two system-level events. Signed-off-by: Flc゛ * feat(foundation): Added two system-level events. Signed-off-by: Flc゛ * test(foundation): Optimize code Signed-off-by: Flc゛ --------- Signed-off-by: Flc゛ --- foundation/foundation_test.go | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/foundation/foundation_test.go b/foundation/foundation_test.go index a53e18a4..e83d81cd 100644 --- a/foundation/foundation_test.go +++ b/foundation/foundation_test.go @@ -2,10 +2,8 @@ package foundation import ( "context" - "fmt" "sync" "testing" - "time" "github.com/stretchr/testify/assert" @@ -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" } }() @@ -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)) }