aboutsummaryrefslogtreecommitdiff
path: root/misc
diff options
context:
space:
mode:
authorXe Iaso <me@xeiaso.net>2023-06-24 07:06:03 -0400
committerXe Iaso <me@xeiaso.net>2023-06-24 07:06:03 -0400
commit7724fa5a14ce57640659bb57cd1b78ef95273952 (patch)
treeeb5e857164c266aecba06eb1b55bd136a08e23f0 /misc
parent0381ae5a1970d69712d698c48da50f95294deb37 (diff)
downloadx-7724fa5a14ce57640659bb57cd1b78ef95273952.tar.xz
x-7724fa5a14ce57640659bb57cd1b78ef95273952.zip
misc/localca: fix use of time.Sleep in test code
Signed-off-by: Xe Iaso <me@xeiaso.net>
Diffstat (limited to 'misc')
-rw-r--r--misc/localca/localca_test.go12
1 files changed, 8 insertions, 4 deletions
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)