golang.org/x/tools/gopls@v0.15.3/internal/test/integration/misc/embed_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  package misc
     5  
     6  import (
     7  	"testing"
     8  
     9  	. "golang.org/x/tools/gopls/internal/test/integration"
    10  )
    11  
    12  func TestMissingPatternDiagnostic(t *testing.T) {
    13  	const files = `
    14  -- go.mod --
    15  module example.com
    16  -- x.go --
    17  package x
    18  
    19  import (
    20  	_ "embed"
    21  )
    22  
    23  // Issue 47436
    24  func F() {}
    25  
    26  //go:embed NONEXISTENT
    27  var foo string
    28  `
    29  	Run(t, files, func(t *testing.T, env *Env) {
    30  		env.OpenFile("x.go")
    31  		env.AfterChange(
    32  			Diagnostics(
    33  				env.AtRegexp("x.go", `NONEXISTENT`),
    34  				WithMessage("no matching files found"),
    35  			),
    36  		)
    37  		env.RegexpReplace("x.go", `NONEXISTENT`, "x.go")
    38  		env.AfterChange(NoDiagnostics(ForFile("x.go")))
    39  	})
    40  }