Skip to content

Commit

Permalink
Exclude integration tests with go test -short
Browse files Browse the repository at this point in the history
  • Loading branch information
fbiville committed Mar 18, 2022
1 parent 9a8de1d commit 876f708
Show file tree
Hide file tree
Showing 17 changed files with 77 additions and 146 deletions.
7 changes: 5 additions & 2 deletions neo4j/test-integration/auth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ import (
"github.com/neo4j/neo4j-go-driver/v5/neo4j/test-integration/dbserver"
)

func TestAuthentication(tt *testing.T) {
func TestAuthentication(outer *testing.T) {
if testing.Short() {
outer.Skip()
}
server := dbserver.GetDbServer()

getDriverAndSession := func(token neo4j.AuthToken) (neo4j.Driver, neo4j.Session) {
Expand All @@ -38,7 +41,7 @@ func TestAuthentication(tt *testing.T) {
return driver, driver.NewSession(neo4j.SessionConfig{AccessMode: neo4j.AccessModeRead})
}

tt.Run("when wrong credentials are provided, it should fail with authentication error", func(t *testing.T) {
outer.Run("when wrong credentials are provided, it should fail with authentication error", func(t *testing.T) {
token := neo4j.BasicAuth("wrong", "wrong", "")
driver, session := getDriverAndSession(token)
defer driver.Close()
Expand Down
3 changes: 3 additions & 0 deletions neo4j/test-integration/bookmark_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ import (
)

func TestBookmark(outer *testing.T) {
if testing.Short() {
outer.Skip()
}
server := dbserver.GetDbServer()

createNodeInTx := func(driver neo4j.Driver) string {
Expand Down
23 changes: 13 additions & 10 deletions neo4j/test-integration/dbconn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,11 @@ func BenchmarkQuery(b *testing.B) {
}
}

// Tests the specification of the internal connection connection API
func TestConnectionConformance(ot *testing.T) {
// Tests the specification of the internal connection API
func TestConnectionConformance(outer *testing.T) {
if testing.Short() {
outer.Skip()
}
server, boltConn := makeRawConnection(&log.Console{Errors: true, Infos: true, Warns: true, Debugs: true}, nil)
defer boltConn.Close(context.Background())

Expand Down Expand Up @@ -330,15 +333,15 @@ func TestConnectionConformance(ot *testing.T) {
}
// Run all above in sequence
for _, c := range cases {
ot.Run(c.name, func(t *testing.T) {
outer.Run(c.name, func(t *testing.T) {
c.fun(t, boltConn)
if !boltConn.IsAlive() {
t.Error("Connection died")
}
})
}
// Run some of the above at random as one test
ot.Run("Random sequence", func(t *testing.T) {
outer.Run("Random sequence", func(t *testing.T) {
randoms := make([]int, 25)
for i := range randoms {
randoms[i] = int(randInt() % int64(len(cases)))
Expand Down Expand Up @@ -441,7 +444,7 @@ func TestConnectionConformance(ot *testing.T) {
},
}
for _, c := range cases {
ot.Run(c.name, func(t *testing.T) {
outer.Run(c.name, func(t *testing.T) {
c.fun(t, boltConn)
if !boltConn.IsAlive() {
t.Error("Connection died")
Expand All @@ -460,7 +463,7 @@ func TestConnectionConformance(ot *testing.T) {
})
}
// Run some of the above at random as one test
ot.Run("Random reset sequence", func(t *testing.T) {
outer.Run("Random reset sequence", func(t *testing.T) {
randoms := make([]int, 25)
for i := range randoms {
randoms[i] = int(randInt() % int64(len(cases)))
Expand All @@ -476,7 +479,7 @@ func TestConnectionConformance(ot *testing.T) {
})

// Write really big query
ot.Run("Really big query", func(t *testing.T) {
outer.Run("Really big query", func(t *testing.T) {
query := "RETURN $x"
bigBuilder := strings.Builder{}
s := "0123456789"
Expand Down Expand Up @@ -558,7 +561,7 @@ func TestConnectionConformance(ot *testing.T) {
}

// Temporal types
ot.Run("Temporal types", func(tt *testing.T) {
outer.Run("Temporal types", func(tt *testing.T) {
london, _ := time.LoadLocation("Europe/London")

// In Cypher
Expand Down Expand Up @@ -673,7 +676,7 @@ func TestConnectionConformance(ot *testing.T) {
})

// Bookmark tests
ot.Run("Bookmarks", func(tt *testing.T) {
outer.Run("Bookmarks", func(tt *testing.T) {
boltConn.Reset(context.Background())
lastBookmark := boltConn.Bookmark()

Expand Down Expand Up @@ -745,7 +748,7 @@ func TestConnectionConformance(ot *testing.T) {
})

// Enterprise feature
ot.Run("Multidatabase", func(tt *testing.T) {
outer.Run("Multidatabase", func(tt *testing.T) {
selector, supportsMultidatabase := boltConn.(idb.DatabaseSelector)
if !supportsMultidatabase {
tt.Skipf("Database %s:%s does not support multidatabase functionality", boltConn.ServerName(), boltConn.ServerVersion())
Expand Down
3 changes: 3 additions & 0 deletions neo4j/test-integration/driver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ import (
)

func TestDriver(outer *testing.T) {
if testing.Short() {
outer.Skip()
}
server := dbserver.GetDbServer()

outer.Run("VerifyConnectivity", func(inner *testing.T) {
Expand Down
7 changes: 7 additions & 0 deletions neo4j/test-integration/examples_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ import (
)

func TestExamples(outer *testing.T) {
if testing.Short() {
outer.Skip()
}

outer.Run("Single Instance", func(inner *testing.T) {
var (
Expand Down Expand Up @@ -810,6 +813,10 @@ func addPersonNode(driver neo4j.Driver, name string) (int64, error) {
// end::read-write-transaction[]

func TestExamplesDatabaseSelection(t *testing.T) {
if testing.Short() {
t.Skip()
}

driver := dbserver.GetDbServer().Driver()
defer driver.Close()
// tag::database-selection[]
Expand Down
16 changes: 10 additions & 6 deletions neo4j/test-integration/multidatabase_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,32 +26,36 @@ import (
"github.com/neo4j/neo4j-go-driver/v5/neo4j/test-integration/dbserver"
)

func TestMultidatabase(ot *testing.T) {
func TestMultidatabase(outer *testing.T) {
if testing.Short() {
outer.Skip()
}

server := dbserver.GetDbServer()

driver := server.Driver()
defer driver.Close()

// Need > 4.0 for database support
if server.Version.LessThan(V4) {
ot.Skip("Versions prior to 4.0 does not support multidatabase")
outer.Skip("Versions prior to 4.0 does not support multidatabase")
}

if !server.IsEnterprise {
ot.Skip("Need enterprise version to test multidatabase")
outer.Skip("Need enterprise version to test multidatabase")
}

// Ensure that a test database exists using system database
func() {
sysSess := driver.NewSession(neo4j.SessionConfig{DatabaseName: "system"})
defer sysSess.Close()
_, err := sysSess.Run("DROP DATABASE testdb IF EXISTS", nil)
assertNil(ot, err)
assertNil(outer, err)
_, err = sysSess.Run("CREATE DATABASE testdb", nil)
assertNil(ot, err)
assertNil(outer, err)
}()

ot.Run("Node created in test db should not be visible in default db", func(t *testing.T) {
outer.Run("Node created in test db should not be visible in default db", func(t *testing.T) {
// Create node in testdb session
testSess := driver.NewSession(neo4j.SessionConfig{DatabaseName: "testdb"})
randId := createRandomNode(t, testSess)
Expand Down
3 changes: 3 additions & 0 deletions neo4j/test-integration/routing_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ import (
)

func TestRouting(outer *testing.T) {
if testing.Short() {
outer.Skip()
}
server := dbserver.GetDbServer()

var session neo4j.Session
Expand Down
3 changes: 3 additions & 0 deletions neo4j/test-integration/session_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ import (
)

func TestSession(outer *testing.T) {
if testing.Short() {
outer.Skip()
}
server := dbserver.GetDbServer()

outer.Run("with read access mode", func(inner *testing.T) {
Expand Down
12 changes: 8 additions & 4 deletions neo4j/test-integration/spatialtypes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ import (
"github.com/neo4j/neo4j-go-driver/v5/neo4j/test-integration/dbserver"
)

func TestSpatialTypes(st *testing.T) {
func TestSpatialTypes(outer *testing.T) {
if testing.Short() {
outer.Skip()
}

const (
WGS84SrID uint32 = 4326
WGS843DSrID uint32 = 4979
Expand All @@ -38,7 +42,7 @@ func TestSpatialTypes(st *testing.T) {
server := dbserver.GetDbServer()
driver := server.Driver()
if server.Version.LessThan(V340) {
st.Skip("Spatial types are only available after neo4j 3.4.0 release")
outer.Skip("Spatial types are only available after neo4j 3.4.0 release")
}

// Returns a random 2D/3D point (depending on seq) with random values for X, Y and Z when applicable.
Expand Down Expand Up @@ -103,7 +107,7 @@ func TestSpatialTypes(st *testing.T) {
}

// Verifies that a single 2D point can be received.
st.Run("Receive", func(rt *testing.T) {
outer.Run("Receive", func(rt *testing.T) {
rt.Run("Point2D", func(t *testing.T) {
p1 := single(t, driver, "RETURN point({x: 39.111748, y:-76.775635})", nil).(neo4j.Point2D)
p2 := neo4j.Point2D{X: 39.111748, Y: -76.775635, SpatialRefId: CartesianSrID}
Expand All @@ -118,7 +122,7 @@ func TestSpatialTypes(st *testing.T) {
})
})

st.Run("Send", func(tt *testing.T) {
outer.Run("Send", func(tt *testing.T) {
// Verifies that a single 2D point can be sent (and received)
tt.Run("Point2D", func(t *testing.T) {
p1 := neo4j.Point2D{SpatialRefId: WGS84SrID, X: 51.5044585, Y: -0.105658}
Expand Down
3 changes: 3 additions & 0 deletions neo4j/test-integration/summary_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ import (
)

func TestResultSummary(outer *testing.T) {
if testing.Short() {
outer.Skip()
}

const extraDatabase = "extra"

Expand Down
3 changes: 3 additions & 0 deletions neo4j/test-integration/temporaltypes2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ import (
)

func TestTemporalTypes2(outer *testing.T) {
if testing.Short() {
outer.Skip()
}
server := dbserver.GetDbServer()
driver := server.Driver()
if server.Version.LessThan(V340) {
Expand Down
6 changes: 3 additions & 3 deletions neo4j/test-integration/temporaltypes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ import (
)

func TestTemporalTypes(outer *testing.T) {
const (
numberOfRandomValues = 200
)
if testing.Short() {
outer.Skip()
}

server := dbserver.GetDbServer()
var driver neo4j.Driver
Expand Down
4 changes: 4 additions & 0 deletions neo4j/test-integration/timeout_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ import (
)

func TestTimeoutAndLifetime(outer *testing.T) {
if testing.Short() {
outer.Skip()
}

server := dbserver.GetDbServer()

outer.Run("should error when ConnectionAcquisitionTimeout is hit", func(t *testing.T) {
Expand Down
4 changes: 4 additions & 0 deletions neo4j/test-integration/transaction_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ import (
)

func TestTransaction(outer *testing.T) {
if testing.Short() {
outer.Skip()
}

server := dbserver.GetDbServer()
var err error
var driver neo4j.Driver
Expand Down
4 changes: 4 additions & 0 deletions neo4j/test-integration/types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ import (
)

func TestTypes(outer *testing.T) {
if testing.Short() {
outer.Skip()
}

server := dbserver.GetDbServer()
var err error
var driver neo4j.Driver
Expand Down
Loading

0 comments on commit 876f708

Please sign in to comment.