github.com/jhump/golang-x-tools@v0.0.0-20220218190644-4958d6d39439/internal/lsp/command/interface_test.go (about) 1 // Copyright 2021 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. 4 5 package command_test 6 7 import ( 8 "bytes" 9 "io/ioutil" 10 "testing" 11 12 "github.com/jhump/golang-x-tools/internal/lsp/command/gen" 13 "github.com/jhump/golang-x-tools/internal/testenv" 14 ) 15 16 func TestGenerated(t *testing.T) { 17 testenv.NeedsGoBuild(t) // This is a lie. We actually need the source code. 18 19 onDisk, err := ioutil.ReadFile("command_gen.go") 20 if err != nil { 21 t.Fatal(err) 22 } 23 24 generated, err := gen.Generate() 25 if err != nil { 26 t.Fatal(err) 27 } 28 if !bytes.Equal(onDisk, generated) { 29 t.Error("command_gen.go is stale -- regenerate") 30 } 31 }