Created
December 11, 2014 16:49
-
-
Save bithavoc/d7e892328550118ad1fc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
. "github.com/smartystreets/goconvey/convey" | |
"sync" | |
"testing" | |
) | |
var mutex sync.Mutex | |
type useIndexHandler func() | |
// | |
// Exclusive Index usage helper. | |
// use only in root Convey (the ones that starts with testing.T) | |
// | |
func useIndex(handle useIndexHandler) { | |
//TODO: wipe elastic search index | |
//TODO: feed elastic index | |
mutex.Lock() | |
defer mutex.Unlock() | |
handle() | |
// ... other stuff to run after every test | |
} | |
func Test1(t *testing.T) { | |
Convey("Given something", t, func() { | |
useIndex(func() { | |
// test logic here | |
So(1, ShouldEqual, 1) | |
Convey("nested something", func() { | |
So(2, ShouldEqual, 2) | |
}) | |
}) | |
}) | |
Convey("Given something else", t, func() { | |
useIndex(func() { | |
// test logic here | |
So(1, ShouldEqual, 1) | |
}) | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment