github.com/juju/juju@v0.0.0-20240327075706-a90865de2538/api/controller/caasmodelconfigmanager/client_test.go (about) 1 // Copyright 2021 Canonical Ltd. 2 // Licensed under the AGPLv3, see LICENCE file for details. 3 4 package caasmodelconfigmanager_test 5 6 import ( 7 "github.com/juju/testing" 8 jc "github.com/juju/testing/checkers" 9 gc "gopkg.in/check.v1" 10 11 basetesting "github.com/juju/juju/api/base/testing" 12 "github.com/juju/juju/api/controller/caasmodelconfigmanager" 13 "github.com/juju/juju/controller" 14 "github.com/juju/juju/rpc/params" 15 ) 16 17 type caasmodelconfigmanagerSuite struct { 18 testing.IsolationSuite 19 } 20 21 var _ = gc.Suite(&caasmodelconfigmanagerSuite{}) 22 23 func newClient(f basetesting.APICallerFunc) (*caasmodelconfigmanager.Client, error) { 24 return caasmodelconfigmanager.NewClient(basetesting.BestVersionCaller{APICallerFunc: f, BestVersion: 1}) 25 } 26 27 func (s *caasmodelconfigmanagerSuite) TestControllerConfig(c *gc.C) { 28 client, err := newClient(func(objType string, version int, id, request string, arg, result interface{}) error { 29 c.Check(objType, gc.Equals, "CAASModelConfigManager") 30 c.Check(id, gc.Equals, "") 31 c.Check(request, gc.Equals, "ControllerConfig") 32 c.Assert(arg, gc.IsNil) 33 c.Assert(result, gc.FitsTypeOf, ¶ms.ControllerConfigResult{}) 34 *(result.(*params.ControllerConfigResult)) = params.ControllerConfigResult{ 35 Config: params.ControllerConfig{ 36 "caas-image-repo": ` 37 { 38 "serveraddress": "quay.io", 39 "auth": "xxxxx==", 40 "repository": "test-account" 41 } 42 `[1:], 43 }, 44 } 45 return nil 46 }) 47 c.Assert(err, jc.ErrorIsNil) 48 49 cfg, err := client.ControllerConfig() 50 c.Assert(err, jc.ErrorIsNil) 51 c.Assert(cfg, jc.DeepEquals, controller.Config{ 52 "caas-image-repo": ` 53 { 54 "serveraddress": "quay.io", 55 "auth": "xxxxx==", 56 "repository": "test-account" 57 } 58 `[1:], 59 }) 60 }