package opscore

import (
	"testing"

	"github.com/tidbcloud/devops/pkg/infra/utils/test"
	"go.uber.org/mock/gomock"

	. "github.com/onsi/ginkgo/v2"
	. "github.com/onsi/gomega"
)

func TestOpsCoreClient(t *testing.T) {
	RegisterFailHandler(Fail)
	RunSpecs(t, "Ops Core Client Suite", test.ReporterConfig())
}

var _ = Describe("Client", func() {
	It("initializes all gRPC service clients", func() {
		client, err := NewClient("localhost:8080")

		Expect(err).NotTo(HaveOccurred())
		Expect(client.Auth).NotTo(BeNil())
		Expect(client.IAM).NotTo(BeNil())
		Expect(client.User).NotTo(BeNil())
	})

	It("initializes all mock service clients", func() {
		ctrl := gomock.NewController(GinkgoT())

		client := NewMockClient(ctrl)

		Expect(client.Auth).To(BeAssignableToTypeOf(&MockAuthServiceClient{}))
		Expect(client.IAM).To(BeAssignableToTypeOf(&MockIAMServiceClient{}))
		Expect(client.User).To(BeAssignableToTypeOf(&MockUserServiceClient{}))
	})
})
