-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathworkspace_create_external_error_test.go
89 lines (71 loc) · 1.74 KB
/
workspace_create_external_error_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
package langd
import (
"path/filepath"
"testing"
)
func Test_Workspace_Change_Creates_Error(t *testing.T) {
src1 := `package foo
var Foof int = 1`
src2 := `package bar
import "../foo"
func IncFoof() int {
foo.Foof++
return foo.Foof
}`
rootPath, overlayFs := createOverlay(map[string]string{
filepath.Join("foo", "foo.go"): src1,
filepath.Join("bar", "bar.go"): src2,
})
barPath := filepath.Join(rootPath, "bar")
fooGoPath := filepath.Join(rootPath, "foo", "foo.go")
w, closer := workspaceSetup(t, barPath, overlayFs, false)
defer closer()
w.OpenFile(fooGoPath, src1)
w.Loader.Wait()
w.ChangeFile(fooGoPath, 1, 5, 1, 9, "FOOF")
w.Loader.Wait()
errCount := 0
w.Loader.Errors(func(file string, errs []FileError) {
errCount += len(errs)
})
if errCount == 0 {
t.Errorf("Did not get any errors")
}
}
func Test_Workspace_Change_Creates_Error_Indirect(t *testing.T) {
src1 := `package foo
type Foo struct {}
func (f *Foo) Add() int {
return 0
}`
src2 := `package bar
import "../foo"
type Bar struct {
F *foo.Foo
}`
src3 := `package baz
import "../bar"
func Do(b *bar.Bar) int {
return b.F.Add()
}`
rootPath, overlayFs := createOverlay(map[string]string{
filepath.Join("foo", "foo.go"): src1,
filepath.Join("bar", "bar.go"): src2,
filepath.Join("baz", "baz.go"): src3,
})
bazPath := filepath.Join(rootPath, "baz")
fooGoPath := filepath.Join(rootPath, "foo", "foo.go")
w, closer := workspaceSetup(t, bazPath, overlayFs, false)
defer closer()
w.OpenFile(fooGoPath, src1)
w.Loader.Wait()
w.ChangeFile(fooGoPath, 2, 15, 2, 18, "Inc")
w.Loader.Wait()
errCount := 0
w.Loader.Errors(func(file string, errs []FileError) {
errCount += len(errs)
})
if errCount == 0 {
t.Errorf("Did not get any errors")
}
}