Debian Codegraph @

gopls/internal/test/marker/testdata/codeaction/addtest_pre124.txt

raw
1 This test checks the fallback behavior of the 'add test for FUNC' code action
2 when the module's Go version is older than 1.24 (before testing.T.Context was
3 available): the generated test must continue to use context.Background() and
4 reuse the existing rename of the "context" import in the test file.
5
6 -- flags --
7 -ignore_extra_diags
8
9 -- go.mod --
10 module example.com
11
12 go 1.23
13
14 -- a/a.go --
15 package a
16
17 import "context"
18
19 func Foo(ctx context.Context) {} //@codeaction("Foo", "source.addTest", edit=foo)
20
21 -- a/a_test.go --
22 package a_test
23
24 import renamedctx "context"
25
26 -- @foo/a/a_test.go --
27 @@ -3 +3,3 @@
28 -import renamedctx "context"
29 +import (
30 + renamedctx "context"
31 + "testing"
32 @@ -5 +7,16 @@
33 + "example.com/a"
34 +)
35 +
36 +
37 +func TestFoo(t *testing.T) {
38 + tests := []struct {
39 + name string // description of this test case
40 + }{
41 + // TODO: Add test cases.
42 + }
43 + for _, tt := range tests {
44 + t.Run(tt.name, func(t *testing.T) {
45 + a.Foo(renamedctx.Background())
46 + })
47 + }
48 +}