Skip to content

Commit

Permalink
Merge pull request #39 from timshannon/issue21
Browse files Browse the repository at this point in the history
Update to Badger V2 and Update library to V2
  • Loading branch information
timshannon committed Oct 13, 2020
2 parents 8addb9d + d4ec6a3 commit 61de1b6
Show file tree
Hide file tree
Showing 20 changed files with 63 additions and 64 deletions.
2 changes: 1 addition & 1 deletion aggregate.go
Expand Up @@ -9,7 +9,7 @@ import (
"reflect"
"sort"

"github.com/dgraph-io/badger"
"github.com/dgraph-io/badger/v2"
)

// AggregateResult allows you to access the results of an aggregate query
Expand Down
2 changes: 1 addition & 1 deletion aggregate_test.go
Expand Up @@ -8,7 +8,7 @@ import (
"fmt"
"testing"

"github.com/timshannon/badgerhold"
"github.com/timshannon/badgerhold/v2"
)

func TestFindAggregateGroup(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions bench_test.go
Expand Up @@ -11,8 +11,8 @@ import (
"os"
"testing"

"github.com/dgraph-io/badger"
"github.com/timshannon/badgerhold"
"github.com/dgraph-io/badger/v2"
"github.com/timshannon/badgerhold/v2"
)

type BenchData struct {
Expand Down
2 changes: 1 addition & 1 deletion compare_test.go
Expand Up @@ -11,7 +11,7 @@ import (
"testing"
"time"

"github.com/timshannon/badgerhold"
"github.com/timshannon/badgerhold/v2"
)

type CItemTest struct {
Expand Down
2 changes: 1 addition & 1 deletion delete.go
Expand Up @@ -7,7 +7,7 @@ package badgerhold
import (
"reflect"

"github.com/dgraph-io/badger"
"github.com/dgraph-io/badger/v2"
)

// Delete deletes a record from the bolthold, datatype just needs to be an example of the type stored so that
Expand Down
4 changes: 2 additions & 2 deletions delete_test.go
Expand Up @@ -8,8 +8,8 @@ import (
"testing"
"time"

"github.com/dgraph-io/badger"
"github.com/timshannon/badgerhold"
"github.com/dgraph-io/badger/v2"
"github.com/timshannon/badgerhold/v2"
)

func TestDelete(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions example_test.go
Expand Up @@ -10,8 +10,8 @@ import (
"os"
"time"

"github.com/dgraph-io/badger"
"github.com/timshannon/badgerhold"
"github.com/dgraph-io/badger/v2"
"github.com/timshannon/badgerhold/v2"
)

type Item struct {
Expand Down
2 changes: 1 addition & 1 deletion find_test.go
Expand Up @@ -11,7 +11,7 @@ import (
"testing"
"time"

"github.com/timshannon/badgerhold"
"github.com/timshannon/badgerhold/v2"
)

type ItemTest struct {
Expand Down
2 changes: 1 addition & 1 deletion get.go
Expand Up @@ -9,7 +9,7 @@ import (
"reflect"
"strings"

"github.com/dgraph-io/badger"
"github.com/dgraph-io/badger/v2"
)

// ErrNotFound is returned when no data is found for the given key
Expand Down
2 changes: 1 addition & 1 deletion get_test.go
Expand Up @@ -8,7 +8,7 @@ import (
"testing"
"time"

"github.com/timshannon/badgerhold"
"github.com/timshannon/badgerhold/v2"
)

func TestGet(t *testing.T) {
Expand Down
7 changes: 2 additions & 5 deletions go.mod
@@ -1,8 +1,5 @@
module github.com/timshannon/badgerhold
module github.com/timshannon/badgerhold/v2

require (
github.com/AndreasBriese/bbloom v0.0.0-20190825152654-46b345b51c96 // indirect
github.com/dgraph-io/badger v1.6.0
)
require github.com/dgraph-io/badger/v2 v2.2007.2

go 1.13
33 changes: 25 additions & 8 deletions go.sum
@@ -1,27 +1,38 @@
github.com/AndreasBriese/bbloom v0.0.0-20190306092124-e2d15f34fcf9 h1:HD8gA2tkByhMAwYaFAX9w2l7vxvBQ5NMoxDrkhqhtn4=
github.com/AndreasBriese/bbloom v0.0.0-20190306092124-e2d15f34fcf9/go.mod h1:bOvUY6CB00SOBii9/FifXqc0awNKxLFCL/+pkDPuyl8=
github.com/AndreasBriese/bbloom v0.0.0-20190825152654-46b345b51c96 h1:cTp8I5+VIoKjsnZuH8vjyaysT/ses3EvZeaV/1UkF2M=
github.com/AndreasBriese/bbloom v0.0.0-20190825152654-46b345b51c96/go.mod h1:bOvUY6CB00SOBii9/FifXqc0awNKxLFCL/+pkDPuyl8=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/DataDog/zstd v1.4.1 h1:3oxKN3wbHibqx897utPC2LTQU4J+IHWWJO+glkAkpFM=
github.com/DataDog/zstd v1.4.1/go.mod h1:1jcaCB/ufaK+sKp1NBhlGmpz41jOoPQ35bpF36t7BBo=
github.com/OneOfOne/xxhash v1.2.2 h1:KMrpdQIwFcEqXDklaen+P1axHaj9BSKzvpUUfnHldSE=
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
github.com/cespare/xxhash v1.1.0 h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko=
github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc=
github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk=
github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dgraph-io/badger v1.6.0 h1:DshxFxZWXUcO0xX476VJC07Xsr6ZCBVRHKZ93Oh7Evo=
github.com/dgraph-io/badger v1.6.0/go.mod h1:zwt7syl517jmP8s94KqSxTlM6IMsdhYy6psNgSztDR4=
github.com/dgraph-io/badger/v2 v2.2007.2 h1:EjjK0KqwaFMlPin1ajhP943VPENHJdEz1KLIegjaI3k=
github.com/dgraph-io/badger/v2 v2.2007.2/go.mod h1:26P/7fbL4kUZVEVKLAKXkBXKOydDmM2p1e+NhhnBCAE=
github.com/dgraph-io/ristretto v0.0.3-0.20200630154024-f66de99634de h1:t0UHb5vdojIDUqktM6+xJAfScFBsVpXZmqC9dsgJmeA=
github.com/dgraph-io/ristretto v0.0.3-0.20200630154024-f66de99634de/go.mod h1:KPxhHT9ZxKefz+PCeOGsrHpl1qZ7i70dGTu2u+Ahh6E=
github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2 h1:tdlZCpZ/P9DhczCTSixgIKmwPv6+wP5DGjqLYw5SUiA=
github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw=
github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo=
github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
github.com/golang/protobuf v1.3.1 h1:YF8+flBXS5eO826T4nzqPrxfhQThhXl0YzfuUPu4SBg=
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/snappy v0.0.1 h1:Qgr9rKW7uDUkrbSmQeiDsGa8SjGyCOGtuasMWwvp2P4=
github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
Expand All @@ -31,6 +42,9 @@ github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g=
github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
github.com/spaolacci/murmur3 v1.1.0 h1:7c1g84S4BPRrfL5Xrdp6fOJ206sU9y293DDHaoy0bLI=
github.com/spaolacci/murmur3 v1.1.0/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ=
github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
github.com/spf13/cobra v0.0.5/go.mod h1:3K3wKZymM7VvHMDS9+Akkh4K60UwM26emMESw8tLCHU=
Expand All @@ -40,8 +54,8 @@ github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DM
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0=
github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q=
golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
Expand All @@ -54,4 +68,7 @@ golang.org/x/sys v0.0.0-20190626221950-04f50cda93cb h1:fgwFCsaw9buMuxNd6+DQfAuSF
golang.org/x/sys v0.0.0-20190626221950-04f50cda93cb/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
2 changes: 1 addition & 1 deletion index.go
Expand Up @@ -9,7 +9,7 @@ import (
"reflect"
"sort"

"github.com/dgraph-io/badger"
"github.com/dgraph-io/badger/v2"
)

const indexPrefix = "_bhIndex"
Expand Down
2 changes: 1 addition & 1 deletion nested_structs_test.go
Expand Up @@ -8,7 +8,7 @@ import (
"reflect"
"testing"

"github.com/timshannon/badgerhold"
"github.com/timshannon/badgerhold/v2"
)

type Nested struct {
Expand Down
2 changes: 1 addition & 1 deletion put.go
Expand Up @@ -8,7 +8,7 @@ import (
"errors"
"reflect"

"github.com/dgraph-io/badger"
"github.com/dgraph-io/badger/v2"
)

// ErrKeyExists is the error returned when data is being Inserted for a Key that already exists
Expand Down
4 changes: 2 additions & 2 deletions put_test.go
Expand Up @@ -9,8 +9,8 @@ import (
"testing"
"time"

"github.com/dgraph-io/badger"
"github.com/timshannon/badgerhold"
"github.com/dgraph-io/badger/v2"
"github.com/timshannon/badgerhold/v2"
)

func TestInsert(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion query.go
Expand Up @@ -12,7 +12,7 @@ import (
"strings"
"unicode"

"github.com/dgraph-io/badger"
"github.com/dgraph-io/badger/v2"
)

const (
Expand Down
2 changes: 1 addition & 1 deletion sort_test.go
Expand Up @@ -8,7 +8,7 @@ import (
"fmt"
"testing"

"github.com/timshannon/badgerhold"
"github.com/timshannon/badgerhold/v2"
)

var sortTests = []test{
Expand Down
2 changes: 1 addition & 1 deletion store.go
Expand Up @@ -9,7 +9,7 @@ import (
"strings"
"sync"

"github.com/dgraph-io/badger"
"github.com/dgraph-io/badger/v2"
)

const (
Expand Down
45 changes: 15 additions & 30 deletions store_test.go
Expand Up @@ -6,37 +6,15 @@ package badgerhold_test

import (
"encoding/json"
"fmt"

// "fmt"
"io/ioutil"
"os"
"testing"

"github.com/timshannon/badgerhold"
"github.com/timshannon/badgerhold/v2"
)

var globalStore *badgerhold.Store

func TestMain(m *testing.M) {
opt := testOptions()
var err error
globalStore, err = badgerhold.Open(opt)
if err != nil {
panic(fmt.Sprintf("Error opening %s: %s", opt.Dir, err))
}

result := m.Run()

err = globalStore.Close()
if err != nil {
panic(fmt.Sprintf("Error closing store: %s", err))
}
err = os.RemoveAll(opt.Dir)
if err != nil {
panic(fmt.Sprintf("Error cleaning up store dir %s: %s", opt.Dir, err))
}
os.Exit(result)
}

func TestOpen(t *testing.T) {
opt := testOptions()
store, err := badgerhold.Open(opt)
Expand Down Expand Up @@ -124,14 +102,21 @@ func TestGetUnknownType(t *testing.T) {

// utilities

// testWrap creates a temporary database for testing and closes and cleans it up when
// completed.
func testWrap(t *testing.T, tests func(store *badgerhold.Store, t *testing.T)) {
tests(globalStore, t)
err := globalStore.Badger().DropAll()
opt := testOptions()
var err error
store, err := badgerhold.Open(opt)
if err != nil {
t.Fatalf("Error clearing badger db: %s", err)
t.Fatalf("Error opening %s: %s", opt.Dir, err)
}

if store == nil {
t.Fatalf("store is null!")
}

tests(store, t)
store.Close()
os.RemoveAll(opt.Dir)
}

type emptyLogger struct{}
Expand Down

0 comments on commit 61de1b6

Please sign in to comment.