cuelang.org/go@v0.10.1/cmd/cuepls/internal/test/integration/base/base_test.go (about)

     1  //go:build !windows
     2  
     3  package feature
     4  
     5  import (
     6  	"testing"
     7  
     8  	"cuelang.org/go/internal/golangorgx/gopls/hooks"
     9  	. "cuelang.org/go/internal/golangorgx/gopls/test/integration"
    10  	"cuelang.org/go/internal/golangorgx/gopls/test/integration/fake"
    11  	"github.com/go-quicktest/qt"
    12  )
    13  
    14  func TestMain(m *testing.M) {
    15  	Main(m, hooks.Options)
    16  }
    17  
    18  func TestFormatFile(t *testing.T) {
    19  	const files = `
    20  -- go.mod --
    21  module mod.com
    22  
    23  go 1.12
    24  -- foo.cue --
    25  package foo
    26  
    27    // this is a test
    28  `
    29  	Run(t, files, func(t *testing.T, env *Env) {
    30  		env.OpenFile("foo.cue")
    31  		env.EditBuffer("foo.cue", fake.NewEdit(0, 0, 1, 0, "package bar\n"))
    32  		env.FormatBuffer("foo.cue")
    33  		got := env.BufferText("foo.cue")
    34  		want := "package bar\n\n// this is a test\n"
    35  		qt.Assert(t, qt.Equals(got, want))
    36  	})
    37  }