Skip to content

Commit

Permalink
jmcvetta#94 - Rename connectBench helper files
Browse files Browse the repository at this point in the history
Importing the testing package in a file, which is used by the main binary, will pollute the flags package with testing help usage messages. This hinders the usage of the neoism package in a cli application. The file benchmark_test*.go are loading the testing package and are therefore responsible for the flag pollution. To exclude the benchmark_connect helpers one can suffix the files with _test. This will ensure that the benchmark_connect helpers are only loaded during testing and do not pollute the main binary. Another solution would be to introduce a neoism_test package, which would result a massive code reorganization.
  • Loading branch information
co0p committed Feb 25, 2018
1 parent 4674154 commit dc74631
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
30 changes: 30 additions & 0 deletions benchmark_gae_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Copyright (c) 2012-2013 Jason McVetta. This is Free Software, released under
// the terms of the GPL v3. See http://www.gnu.org/copyleft/gpl.html for details.
// Resist intellectual serfdom - the ownership of ideas is akin to slavery.

// +build appengine

package neoism

import (
"log"
"testing"

"appengine/aetest"
)

func connectBench(b *testing.B) *Database {
gaeContext, err := aetest.NewContext(nil)
if err != nil {
b.Fatal(err)
}
defer gaeContext.Close()

log.SetFlags(log.Ltime | log.Lshortfile)
db, err := Connect("http://localhost:7474/db/data", gaeContext)

if err != nil {
b.Fatal(err)
}
return db
}
21 changes: 21 additions & 0 deletions benchmark_standalone_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Copyright (c) 2012-2013 Jason McVetta. This is Free Software, released under
// the terms of the GPL v3. See http://www.gnu.org/copyleft/gpl.html for details.
// Resist intellectual serfdom - the ownership of ideas is akin to slavery.

// +build !appengine

package neoism

import (
"log"
"testing"
)

func connectBench(b *testing.B) *Database {
log.SetFlags(log.Ltime | log.Lshortfile)
db, err := Connect("http://localhost:7474/db/data")
if err != nil {
b.Fatal(err)
}
return db
}

0 comments on commit dc74631

Please sign in to comment.