forked from kodehat/portkey
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main_test.go
35 lines (30 loc) · 798 Bytes
/
main_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package main
import (
"context"
"os"
"testing"
"time"
"github.com/kodehat/portkey/internal/config"
"github.com/kodehat/portkey/internal/models"
"github.com/kodehat/portkey/internal/utils"
)
var CONFIG_EMPTY config.Config = config.Config{
LogLevel: "INFO",
Host: "localhost",
Port: "3000",
Portals: []models.Portal{},
Pages: []models.Page{},
}
func setup(t *testing.T, config config.Config) error {
ctx := context.Background()
ctx, cancel := context.WithCancel(ctx)
t.Cleanup(cancel)
go run(ctx, config, os.Stdin, os.Stdout, os.Stderr)
return utils.WaitForReady(ctx, time.Duration(5)*time.Second, "http://localhost:3000/healthz")
}
func TestStart(t *testing.T) {
err := setup(t, CONFIG_EMPTY)
if err != nil {
t.Fatalf("server was unable to start %v", err)
}
}