forked from weaveworks/weave-gitops
-
Notifications
You must be signed in to change notification settings - Fork 0
/
version_test.go
36 lines (29 loc) · 957 Bytes
/
version_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
36
package server_test
import (
"context"
"testing"
"github.com/go-logr/logr"
. "github.com/onsi/gomega"
pb "github.com/weaveworks/weave-gitops/pkg/api/core"
"github.com/weaveworks/weave-gitops/pkg/kube"
"google.golang.org/grpc/metadata"
"sigs.k8s.io/controller-runtime/pkg/client"
logf "sigs.k8s.io/controller-runtime/pkg/log"
)
func TestGetVersion(t *testing.T) {
g := NewGomegaWithT(t)
c := makeGRPCServer(k8sEnv.Rest, t)
logf.SetLogger(logr.Discard())
scheme, err := kube.CreateScheme()
g.Expect(err).To(BeNil())
ctx := context.Background()
_, err = client.New(k8sEnv.Rest, client.Options{
Scheme: scheme,
})
g.Expect(err).NotTo(HaveOccurred())
md := metadata.Pairs(MetadataUserKey, "anne", MetadataGroupsKey, "system:masters")
outgoingCtx := metadata.NewOutgoingContext(ctx, md)
resp, err := c.GetVersion(outgoingCtx, &pb.GetVersionRequest{})
g.Expect(err).NotTo(HaveOccurred())
g.Expect(resp.Semver).To(Equal("v0.0.0"))
}