-
Notifications
You must be signed in to change notification settings - Fork 33
/
http_server_test_common.go
31 lines (26 loc) · 1.07 KB
/
http_server_test_common.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
package httpservertest
import (
"context"
"testing"
"github.com/bonnefoa/kubectl-fzf/v3/internal/httpserver"
"github.com/bonnefoa/kubectl-fzf/v3/internal/k8s/clusterconfig"
"github.com/bonnefoa/kubectl-fzf/v3/internal/k8s/store"
"github.com/bonnefoa/kubectl-fzf/v3/internal/k8s/store/storetest"
"github.com/stretchr/testify/require"
)
func GetTestClusterConfigCli() *clusterconfig.ClusterConfigCli {
return &clusterconfig.ClusterConfigCli{ClusterName: "minikube", CacheDir: "./testdata"}
}
func GetTestStoreConfigCli() *store.StoreConfigCli {
return &store.StoreConfigCli{ClusterConfigCli: GetTestClusterConfigCli()}
}
func StartTestHttpServer(t *testing.T) *httpserver.FzfHttpServer {
ctx := context.Background()
storeConfigCli := GetTestStoreConfigCli()
storeConfig := store.NewStoreConfig(storeConfigCli)
_, podStore := storetest.GetTestPodStore(t)
h := &httpserver.HttpServerConfigCli{ListenAddress: "localhost:0", Debug: false}
fzfHttpServer, err := httpserver.StartHttpServer(ctx, h, storeConfig, []*store.Store{podStore})
require.NoError(t, err)
return fzfHttpServer
}