simple test of a health endpoint

This commit is contained in:
Tim Möhlmann
2023-04-25 15:04:35 +03:00
parent e167365548
commit a22b58f1c0
6 changed files with 131 additions and 42 deletions

View File

@@ -5,9 +5,7 @@ import (
_ "embed"
"errors"
"io"
"os"
"strings"
"sync"
"github.com/spf13/cobra"
"github.com/spf13/viper"
@@ -71,30 +69,3 @@ func initConfig() {
logging.WithFields("file", file).OnError(err).Warn("unable to read config file")
}
}
type TestServer struct {
*start.Server
wg sync.WaitGroup
}
func (s *TestServer) Done() {
s.Shutdown <- os.Interrupt
s.wg.Wait()
}
func NewTestServer(args []string) *TestServer {
testServer := new(TestServer)
server := make(chan *start.Server, 1)
testServer.wg.Add(1)
go func(wg *sync.WaitGroup) {
defer wg.Done()
cmd := New(os.Stdout, os.Stdin, args, server)
cmd.SetArgs(args)
logging.OnError(cmd.Execute()).Fatal()
}(&testServer.wg)
testServer.Server = <-server
return testServer
}