github.com/juju/juju@v0.0.0-20240430160146-1752b71fcf00/caas/kubernetes/provider/template_test.go (about) 1 // Copyright 2019 Canonical Ltd. 2 // Licensed under the AGPLv3, see LICENCE file for details. 3 4 package provider_test 5 6 import ( 7 jc "github.com/juju/testing/checkers" 8 gc "gopkg.in/check.v1" 9 10 "github.com/juju/juju/caas/kubernetes/provider" 11 "github.com/juju/juju/testing" 12 ) 13 14 type templateSuite struct { 15 testing.BaseSuite 16 } 17 18 var _ = gc.Suite(&templateSuite{}) 19 20 func (t *templateSuite) TestToYaml(c *gc.C) { 21 in := struct { 22 Command []string `yaml:"command,omitempty"` 23 }{ 24 Command: []string{"sh", "-c", ` 25 set -ex 26 echo "do some stuff here for gitlab container" 27 `[1:]}, 28 } 29 out, err := provider.ToYaml(in) 30 c.Assert(err, jc.ErrorIsNil) 31 c.Assert(out, jc.DeepEquals, ` 32 command: 33 - sh 34 - -c 35 - | 36 set -ex 37 echo "do some stuff here for gitlab container" 38 `[1:]) 39 } 40 41 func (t *templateSuite) TestIndent(c *gc.C) { 42 out := provider.Indent(6, ` 43 line 1 44 line 2 45 line 3`[1:]) 46 c.Assert(out, jc.DeepEquals, ` 47 line 1 48 line 2 49 line 3 50 `[1:]) 51 52 out = provider.Indent(8, ` 53 line 1 54 line 2 55 line 3`[1:]) 56 c.Assert(out, jc.DeepEquals, ` 57 line 1 58 line 2 59 line 3 60 `[1:]) 61 }