1 // Copyright 2020 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
12 func TestSetOption(t *testing.T) {
17 check func(Options) bool
22 check: func(o Options) bool { return o.SymbolStyle == DynamicSymbols },
28 check: func(o Options) bool { return o.SymbolStyle == "" },
34 check: func(o Options) bool { return o.SymbolStyle == "" },
37 name: "symbolMatcher",
38 value: "caseInsensitive",
39 check: func(o Options) bool { return o.SymbolMatcher == SymbolCaseInsensitive },
42 name: "completionBudget",
44 check: func(o Options) bool { return o.CompletionBudget == 2*time.Second },
49 check: func(o Options) bool { return o.Staticcheck == true },
53 value: map[string]interface{}{"generate": true},
54 check: func(o Options) bool { return o.Codelens["generate"] },
57 name: "allExperiments",
59 check: func(o Options) bool {
60 return true // just confirm that we handle this setting
65 for _, test := range tests {
67 result := opts.set(test.name, test.value)
68 if (result.Error != nil) != test.wantError {
69 t.Fatalf("Options.set(%q, %v): result.Error = %v, want error: %t", test.name, test.value, result.Error, test.wantError)
71 // TODO: this could be made much better using cmp.Diff, if that becomes
72 // available in this module.
73 if !test.check(opts) {
74 t.Errorf("Options.set(%q, %v): unexpected result %+v", test.name, test.value, opts)