github.com/choria-io/go-choria@v0.28.1-0.20240416190746-b3bf9c7d5a45/lifecycle/tally/options_test.go (about)

     1  // Copyright (c) 2020-2021, R.I. Pienaar and the Choria Project contributors
     2  //
     3  // SPDX-License-Identifier: Apache-2.0
     4  
     5  package tally
     6  
     7  import (
     8  	imock "github.com/choria-io/go-choria/inter/imocks"
     9  	"github.com/golang/mock/gomock"
    10  	. "github.com/onsi/ginkgo/v2"
    11  	. "github.com/onsi/gomega"
    12  )
    13  
    14  var _ = Describe("Options", func() {
    15  	Describe("Validate", func() {
    16  		It("Should detect missing connectors", func() {
    17  			opt := options{
    18  				Component: "ginkgo",
    19  			}
    20  			Expect(opt.Validate()).To(MatchError("needs a connector"))
    21  		})
    22  
    23  		It("Should default the optionals", func() {
    24  			ctrl := gomock.NewController(GinkgoT())
    25  			defer ctrl.Finish()
    26  
    27  			opt := options{
    28  				Component: "ginkgo",
    29  				Connector: imock.NewMockConnector(ctrl),
    30  			}
    31  			Expect(opt.Validate()).To(Succeed())
    32  			Expect(opt.StatPrefix).To(Equal("lifecycle_tally"))
    33  			Expect(opt.Log).ToNot(BeNil())
    34  		})
    35  	})
    36  })