Skip to content

Commit

Permalink
fix some test failures on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
mschoch committed Feb 9, 2016
1 parent ebb7d2d commit 9a1e6e1
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 4 deletions.
6 changes: 6 additions & 0 deletions examples_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ func TestMain(m *testing.M) {
panic(err)
}
toRun := m.Run()
if example_index != nil {
err = example_index.Close()
if err != nil {
panic(err)
}
}
err = os.RemoveAll("path_to_index")
if err != nil {
panic(err)
Expand Down
32 changes: 28 additions & 4 deletions index_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -593,6 +593,12 @@ func TestBatchString(t *testing.T) {
if err != nil {
t.Fatal(err)
}
defer func() {
err := index.Close()
if err != nil {
t.Fatal(err)
}
}()

batch := index.NewBatch()
err = batch.Index("a", []byte("{}"))
Expand Down Expand Up @@ -634,12 +640,24 @@ func TestIndexMetadataRaceBug198(t *testing.T) {
if err != nil {
t.Fatal(err)
}
defer func() {
err := index.Close()
if err != nil {
t.Fatal(err)
}
}()

done := make(chan struct{})
go func() {
for {
_, err := index.DocCount()
if err != nil {
t.Fatal(err)
select {
case <-done:
return
default:
_, err := index.DocCount()
if err != nil {
t.Fatal(err)
}
}
}
}()
Expand All @@ -655,7 +673,7 @@ func TestIndexMetadataRaceBug198(t *testing.T) {
t.Fatal(err)
}
}

close(done)
}

func TestIndexCountMatchSearch(t *testing.T) {
Expand Down Expand Up @@ -1122,6 +1140,12 @@ func TestIndexEmptyDocId(t *testing.T) {
if err != nil {
t.Fatal(err)
}
defer func() {
err := index.Close()
if err != nil {
t.Fatal(err)
}
}()

doc := map[string]interface{}{
"body": "nodocid",
Expand Down

0 comments on commit 9a1e6e1

Please sign in to comment.