blob: e1d5c23b6716e90095f4fb5c03701054e63cbe98 [file] [log] [blame]
// Copyright 2021 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package symbolsearch
import (
"testing"
"github.com/google/go-cmp/cmp"
)
// TestGenerateQuery ensure that go generate was run and the generated queries
// are up to date with the raw queries.
func TestGenerateQuery(t *testing.T) {
for _, test := range []struct {
name, q, want string
}{
{"querySearchSymbol", newQuery(SearchTypeSymbol), querySearchSymbol},
{"querySearchPackageDotSymbol", newQuery(SearchTypePackageDotSymbol), querySearchPackageDotSymbol},
{"querySearchMultiWord", newQuery(SearchTypeMultiWord), querySearchMultiWord},
{"queryMatchingSymbolIDsSymbol", matchingIDsQuery(SearchTypeSymbol), queryMatchingSymbolIDsSymbol},
{"queryMatchingSymbolIDsPackageDotSymbol", matchingIDsQuery(SearchTypePackageDotSymbol), queryMatchingSymbolIDsPackageDotSymbol},
{"queryMatchingSymbolIDsMultiWord", matchingIDsQuery(SearchTypeMultiWord), queryMatchingSymbolIDsMultiWord},
{"oldQuerySymbol", rawQuerySymbol, oldQuerySymbol},
{"oldQueryPackageDotSymbol", rawQueryPackageDotSymbol, oldQueryPackageDotSymbol},
{"oldQueryMultiWord", rawQueryMultiWord, oldQueryMultiWord},
} {
t.Run(test.name, func(t *testing.T) {
if diff := cmp.Diff(test.want, test.q); diff != "" {
t.Errorf("mismatch (-want, +got):\n%s", diff)
}
})
}
}