From 7724fa5a14ce57640659bb57cd1b78ef95273952 Mon Sep 17 00:00:00 2001 From: Xe Iaso Date: Sat, 24 Jun 2023 07:06:03 -0400 Subject: misc/localca: fix use of time.Sleep in test code Signed-off-by: Xe Iaso --- misc/localca/localca_test.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'misc') diff --git a/misc/localca/localca_test.go b/misc/localca/localca_test.go index 0c85fba..ffefa33 100644 --- a/misc/localca/localca_test.go +++ b/misc/localca/localca_test.go @@ -8,7 +8,6 @@ import ( "os" "path" "testing" - "time" "golang.org/x/crypto/acme/autocert" ) @@ -47,12 +46,16 @@ func TestLocalCA(t *testing.T) { GetCertificate: m.GetCertificate, } + ch := make(chan struct{}) + go func() { lis, err := tls.Listen("tcp", ":9293", tc) if err != nil { - t.Fatal(err) + t.Error(err) + return } defer lis.Close() + ch <- struct{}{} for { select { @@ -63,7 +66,8 @@ func TestLocalCA(t *testing.T) { cli, err := lis.Accept() if err != nil { - t.Fatal(err) + t.Error(err) + return } defer cli.Close() @@ -71,7 +75,7 @@ func TestLocalCA(t *testing.T) { } }() - time.Sleep(130 * time.Millisecond) + <-ch cli, err := tls.Dial("tcp", "localhost:9293", &tls.Config{InsecureSkipVerify: true}) if err != nil { t.Fatal(err) -- cgit v1.2.3