func WrongQueryExecutor(driver neo4j.Driver) func(ctx *TestContext) {
	return func(ctx *TestContext) {
		session := newStressSession(driver, false, neo4j.AccessModeRead, ctx)
		defer session.Close()
		_, err := session.Run("RETURN wrongThing", nil)
		ExpectNotNil(err)
	}
}
WrongQueryExecutor returns a new test executor which fails using Session.Run
package main
import (
	"fmt"
	"github.com/neo4j/neo4j-go-driver/v4/neo4j"
)
func ExpectNoError(err error) {
	if err != nil {
		panic(fmt.Sprintf("Expected no error: %s", err.Error()))
	}
}
func ExpectNotNil(x interface{}) {
	if x == nil {
		panic("Expected not nil")
	}
}
func ExpectNil(x interface{}) {
	if x != nil {
		panic(fmt.Sprintf("Expected nil but was %+v (%T)", x, x))
	}
}
func ExpectTrue(b bool) {
	if !b {
		panic("Expected true")
	}
}
func ExpectFalse(b bool) {
	if b {
		panic("Expected false")
	}
}
func ExpectInt(a, b int) {
	if a != b {
		panic(fmt.Sprintf("%d != %d", a, b))
	}
}
func newStressSession(driver neo4j.Driver, useBookmark bool, accessMode neo4j.AccessMode, ctx *TestContext) neo4j.Session {
	var session neo4j.Session
	var err error
	if useBookmark {
		session, err = driver.Session(accessMode, ctx.getBookmark())
	} else {
		session, err = driver.Session(accessMode)
	}
	ExpectNoError(err)
	ExpectNotNil(session)
	return session
}
func ReadQueryExecutor(driver neo4j.Driver, useBookmark bool) func(ctx *TestContext) {
	return func(ctx *TestContext) {
		session := newStressSession(driver, useBookmark, neo4j.AccessModeRead, ctx)
		defer session.Close()
		result, err := session.Run("MATCH (n) RETURN n LIMIT 1", nil)
		ExpectNoError(err)
		if result.Next() {
			nodeInt := result.Record().Values[0]
			ExpectNotNil(nodeInt)
			_, ok := nodeInt.(neo4j.Node)
			ExpectTrue(ok)
		}
		ExpectNil(result.Err())
		ExpectFalse(result.Next())
		summary, err := result.Consume()
		ExpectNoError(err)
		ExpectNotNil(summary)
		ctx.processSummary(summary)
	}
}
func ReadQueryInTxExecutor(driver neo4j.Driver, useBookmark bool) func(ctx *TestContext) {
	return func(ctx *TestContext) {
		session := newStressSession(driver, useBookmark, neo4j.AccessModeRead, ctx)
		defer session.Close()
		tx, err := session.BeginTransaction()
		ExpectNoError(err)
		defer tx.Close()
		result, err := tx.Run("MATCH (n) RETURN n LIMIT 1", nil)
		ExpectNoError(err)
		if result.Next() {
			nodeInt := result.Record().Values[0]
			ExpectNotNil(nodeInt)
			_, ok := nodeInt.(neo4j.Node)
			ExpectTrue(ok)
		}
		ExpectNil(result.Err())
		ExpectFalse(result.Next())
		summary, err := result.Consume()
		ExpectNoError(err)
		ExpectNotNil(summary)
		err = tx.Commit()
		ExpectNoError(err)
		ctx.processSummary(summary)
	}
}
func ReadQueryWithReadTransactionExecutor(driver neo4j.Driver, useBookmark bool) func(ctx *TestContext) {
	return func(ctx *TestContext) {
		session := newStressSession(driver, useBookmark, neo4j.AccessModeRead, ctx)
		defer session.Close()
		summary, err := session.ReadTransaction(func(tx neo4j.Transaction) (interface{}, error) {
			result, err := tx.Run("MATCH (n) RETURN n LIMIT 1", nil)
			if err != nil {
				return nil, err
			}
			if result.Next() {
				nodeInt := result.Record().Values[0]
				ExpectNotNil(nodeInt)
				_, ok := nodeInt.(neo4j.Node)
				ExpectTrue(ok)
			}
			return result.Consume()
		})
		ExpectNoError(err)
		ExpectNotNil(summary)
		ctx.processSummary(summary.(neo4j.ResultSummary))
	}
}
func WriteQueryExecutor(driver neo4j.Driver, useBookmark bool) func(ctx *TestContext) {
	return func(ctx *TestContext) {
		session := newStressSession(driver, useBookmark, neo4j.AccessModeWrite, ctx)
		defer session.Close()
		result, err := session.Run("CREATE ()", nil)
		ExpectNoError(err)
		summary, err := result.Consume()
		ExpectNoError(err)
		ExpectInt(summary.Counters().NodesCreated(), 1)
		ctx.setBookmark(session.LastBookmark())
		ctx.addCreated()
	}
}
func WriteQueryInTxExecutor(driver neo4j.Driver, useBookmark bool) func(ctx *TestContext) {
	return func(ctx *TestContext) {
		session := newStressSession(driver, useBookmark, neo4j.AccessModeWrite, ctx)
		defer session.Close()
		tx, err := session.BeginTransaction()
		ExpectNoError(err)
		defer tx.Close()
		result, err := tx.Run("CREATE ()", nil)
		ExpectNoError(err)
		summary, err := result.Consume()
		ExpectNoError(err)
		ExpectInt(summary.Counters().NodesCreated(), 1)
		err = tx.Commit()
		ExpectNoError(err)
		ctx.setBookmark(session.LastBookmark())
		ctx.addCreated()
	}
}
func WriteQueryWithWriteTransactionExecutor(driver neo4j.Driver, useBookmark bool) func(ctx *TestContext) {
	return func(ctx *TestContext) {
		session := newStressSession(driver, useBookmark, neo4j.AccessModeWrite, ctx)
		defer session.Close()
		summary, err := session.WriteTransaction(func(tx neo4j.Transaction) (interface{}, error) {
			result, err := tx.Run("CREATE ()", nil)
			if err != nil {
				return nil, err
			}
			return result.Consume()
		})
		ExpectNoError(err)
		ExpectNotNil(summary)
		ExpectInt(summary.(neo4j.ResultSummary).Counters().NodesCreated(), 1)
		ctx.setBookmark(session.LastBookmark())
		ctx.addCreated()
	}
}
func WriteQueryInReadSessionExecutor(driver neo4j.Driver, useBookmark bool) func(ctx *TestContext) {
	return func(ctx *TestContext) {
		session := newStressSession(driver, useBookmark, neo4j.AccessModeRead, ctx)
		defer session.Close()
		_, err := session.Run("CREATE ()", nil)
		ExpectNotNil(err)
	}
}
func WriteQueryInTxInReadSessionExecutor(driver neo4j.Driver, useBookmark bool) func(ctx *TestContext) {
	return func(ctx *TestContext) {
		session := newStressSession(driver, useBookmark, neo4j.AccessModeRead, ctx)
		defer session.Close()
		tx, err := session.BeginTransaction()
		ExpectNoError(err)
		defer tx.Close()
		_, err = tx.Run("CREATE ()", nil)
		ExpectNotNil(err)
	}
}
func FailingQueryExecutor(driver neo4j.Driver, useBookmark bool) func(ctx *TestContext) {
	return func(ctx *TestContext) {
		session := newStressSession(driver, useBookmark, neo4j.AccessModeRead, ctx)
		defer session.Close()
		result, err := session.Run("UNWIND [10, 5, 0] AS x RETURN 10 / x", nil)
		ExpectNoError(err)
		summary, err := result.Consume()
		ExpectNotNil(err)
		ExpectNil(summary)
	}
}
func FailingQueryInTxExecutor(driver neo4j.Driver, useBookmark bool) func(ctx *TestContext) {
	return func(ctx *TestContext) {
		session := newStressSession(driver, useBookmark, neo4j.AccessModeRead, ctx)
		defer session.Close()
		tx, err := session.BeginTransaction()
		ExpectNoError(err)
		defer tx.Close()
		result, err := tx.Run("UNWIND [10, 5, 0] AS x RETURN 10 / x", nil)
		ExpectNoError(err)
		summary, err := result.Consume()
		ExpectNotNil(err)
		ExpectNil(summary)
	}
}
func FailingQueryWithReadTransactionExecutor(driver neo4j.Driver, useBookmark bool) func(ctx *TestContext) {
	return func(ctx *TestContext) {
		session := newStressSession(driver, useBookmark, neo4j.AccessModeRead, ctx)
		defer session.Close()
		summary, err := session.ReadTransaction(func(tx neo4j.Transaction) (interface{}, error) {
			result, err := tx.Run("UNWIND [10, 5, 0] AS x RETURN 10 / x", nil)
			if err != nil {
				return nil, err
			}
			return result.Consume()
		})
		if !neo4j.IsNeo4jError(err) {
			panic(err)
		}
		ExpectNil(summary)
	}
}
func FailingQueryWithWriteTransactionExecutor(driver neo4j.Driver, useBookmark bool) func(ctx *TestContext) {
	return func(ctx *TestContext) {
		session := newStressSession(driver, useBookmark, neo4j.AccessModeRead, ctx)
		defer session.Close()
		summary, err := session.WriteTransaction(func(tx neo4j.Transaction) (interface{}, error) {
			result, err := tx.Run("UNWIND [10, 5, 0] AS x RETURN 10 / x", nil)
			if err != nil {
				return nil, err
			}
			return result.Consume()
		})
		if !neo4j.IsNeo4jError(err) {
			panic(err)
		}
		ExpectNil(summary)
	}
}