We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent e655bcc commit defe049Copy full SHA for defe049
1 file changed
query_test.go
@@ -7,6 +7,7 @@ import (
7
"net/http/httptest"
8
"os"
9
"strings"
10
+ "sync"
11
"testing"
12
13
"github.com/antchfx/xpath"
@@ -158,6 +159,22 @@ func TestXPathCdUp(t *testing.T) {
158
159
}
160
161
162
+func TestConcurrentQuery(t *testing.T) {
163
+ var wg sync.WaitGroup
164
+ for i := 0; i < 10; i++ {
165
+ wg.Add(1)
166
+ go func(i int) {
167
+ defer wg.Done()
168
+ s := `<html><head></head><body><div>a</div></body>`
169
+ doc := loadHTML(s)
170
+ if n := FindOne(doc, `//div`); n == nil {
171
+ t.Fatalf("should find one but got nil [%d]", i)
172
+ }
173
+ }(i)
174
175
+ wg.Done()
176
+}
177
+
178
func loadHTML(str string) *html.Node {
179
node, err := Parse(strings.NewReader(str))
180
if err != nil {
0 commit comments