Mohammed Naser | f5b77ee | 2023-11-29 23:10:43 -0500 | [diff] [blame] | 1 | package senlin |
| 2 | |
| 3 | import ( |
| 4 | _ "embed" |
| 5 | "os" |
| 6 | "testing" |
| 7 | |
| 8 | "github.com/goccy/go-yaml" |
| 9 | "github.com/stretchr/testify/assert" |
| 10 | "github.com/stretchr/testify/require" |
| 11 | ) |
| 12 | |
| 13 | var ( |
| 14 | //go:embed vars/main.yml |
| 15 | varsFile []byte |
| 16 | vars Vars |
| 17 | ) |
| 18 | |
| 19 | type Vars struct { |
| 20 | SenlinHelmValues `yaml:"_senlin_helm_values"` |
| 21 | } |
| 22 | |
| 23 | type SenlinHelmValues struct { |
| 24 | Conf `yaml:"conf"` |
| 25 | } |
| 26 | |
| 27 | type Conf struct { |
| 28 | Senlin SenlinConf `yaml:"senlin"` |
| 29 | } |
| 30 | |
| 31 | type SenlinConf struct { |
| 32 | API SenlinAPIConf `yaml:"senlin_api"` |
| 33 | } |
| 34 | |
| 35 | type SenlinAPIConf struct { |
| 36 | Workers int32 `yaml:"workers"` |
| 37 | } |
| 38 | |
| 39 | func TestMain(m *testing.M) { |
| 40 | t := &testing.T{} |
| 41 | err := yaml.UnmarshalWithOptions(varsFile, &vars) |
| 42 | require.NoError(t, err) |
| 43 | |
| 44 | code := m.Run() |
| 45 | os.Exit(code) |
| 46 | } |
| 47 | |
| 48 | func TestSenlinHelmValues(t *testing.T) { |
| 49 | assert.Equal(t, int32(2), vars.SenlinHelmValues.Conf.Senlin.API.Workers) |
| 50 | } |