(t *testing.T)
| 9 | ) |
| 10 | |
| 11 | func Test_inOptionSet(t *testing.T) { |
| 12 | t.Parallel() |
| 13 | |
| 14 | options := func(vals ...string) []TemplateVersionParameterOption { |
| 15 | opts := make([]TemplateVersionParameterOption, 0, len(vals)) |
| 16 | for _, val := range vals { |
| 17 | opts = append(opts, TemplateVersionParameterOption{ |
| 18 | Name: val, |
| 19 | Value: val, |
| 20 | }) |
| 21 | } |
| 22 | return opts |
| 23 | } |
| 24 | |
| 25 | tests := []struct { |
| 26 | name string |
| 27 | param TemplateVersionParameter |
| 28 | value string |
| 29 | want bool |
| 30 | }{ |
| 31 | // The function should never be called with 0 options, but if it is, |
| 32 | // it should always return false. |
| 33 | { |
| 34 | name: "empty", |
| 35 | want: false, |
| 36 | }, |
| 37 | { |
| 38 | name: "no-options", |
| 39 | param: TemplateVersionParameter{ |
| 40 | Options: make([]TemplateVersionParameterOption, 0), |
| 41 | }, |
| 42 | }, |
| 43 | { |
| 44 | name: "no-options-multi", |
| 45 | param: TemplateVersionParameter{ |
| 46 | Type: provider.OptionTypeListString, |
| 47 | FormType: string(provider.ParameterFormTypeMultiSelect), |
| 48 | Options: make([]TemplateVersionParameterOption, 0), |
| 49 | }, |
| 50 | want: false, |
| 51 | }, |
| 52 | { |
| 53 | name: "no-options-list(string)", |
| 54 | param: TemplateVersionParameter{ |
| 55 | Type: provider.OptionTypeListString, |
| 56 | FormType: "", |
| 57 | Options: make([]TemplateVersionParameterOption, 0), |
| 58 | }, |
| 59 | want: false, |
| 60 | }, |
| 61 | { |
| 62 | name: "list(string)-no-form", |
| 63 | param: TemplateVersionParameter{ |
| 64 | Type: provider.OptionTypeListString, |
| 65 | FormType: "", |
| 66 | Options: options("red", "green", "blue"), |
| 67 | }, |
| 68 | want: false, |
nothing calls this directly
no test coverage detected