Skip to content

Commit ecec07c

Browse files
holimanbulgakovk
authored andcommitted
graphql: fix spurious error in test (ethereum#22164)
This solves an issue in graphql tests: graphql_test.go:38: could not create new node: datadir already used by another process
1 parent c52351d commit ecec07c

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

graphql/graphql_test.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,14 @@ import (
3333
)
3434

3535
func TestBuildSchema(t *testing.T) {
36-
stack, err := node.New(&node.DefaultConfig)
36+
ddir, err := ioutil.TempDir("", "graphql-buildschema")
37+
if err != nil {
38+
t.Fatalf("failed to create temporary datadir: %v", err)
39+
}
40+
// Copy config
41+
conf := node.DefaultConfig
42+
conf.DataDir = ddir
43+
stack, err := node.New(&conf)
3744
if err != nil {
3845
t.Fatalf("could not create new node: %v", err)
3946
}
@@ -157,6 +164,7 @@ func TestGraphQLHTTPOnSamePort_GQLRequest_Unsuccessful(t *testing.T) {
157164
if err != nil {
158165
t.Fatalf("could not read from response body: %v", err)
159166
}
167+
resp.Body.Close()
160168
// make sure the request is not handled successfully
161169
if want, have := "404 page not found\n", string(bodyBytes); have != want {
162170
t.Errorf("have:\n%v\nwant:\n%v", have, want)

0 commit comments

Comments
 (0)