mirror of
https://github.com/syncthing/syncthing.git
synced 2024-11-17 02:48:57 -07:00
65aaa607ab
Change made by: - running "gvt fetch" on each of the packages mentioned in Godeps/Godeps.json - `rm -rf Godeps` - tweaking the build scripts to not mention Godeps - tweaking the build scripts to test `./lib/...`, `./cmd/...` explicitly (to avoid testing vendor) - tweaking the build scripts to not juggle GOPATH for Godeps and instead set GO15VENDOREXPERIMENT. This also results in some updated packages at the same time I bet. Building with Go 1.3 and 1.4 still *works* but won't use our vendored dependencies - the user needs to have the actual packages in their GOPATH then, which they'll get with a normal "go get". Building with Go 1.6+ will get our vendored dependencies by default even when not using our build script, which is nice. By doing this we gain some freedom in that we can pick and choose manually what to include in vendor, as it's not based on just dependency analysis of our own code. This is also a risk as we might pick up dependencies we are unaware of, as the build may work locally with those packages present in GOPATH. On the other hand the build server will detect this as it has no packages in it's GOPATH beyond what is included in the repo. Recommended tool to manage dependencies is github.com/FiloSottile/gvt.
118 lines
3.0 KiB
Go
118 lines
3.0 KiB
Go
// Copyright (c) 2014, Suryandaru Triandana <syndtr@gmail.com>
|
|
// All rights reserved.
|
|
//
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
package leveldb
|
|
|
|
import (
|
|
. "github.com/onsi/ginkgo"
|
|
. "github.com/onsi/gomega"
|
|
|
|
"github.com/syndtr/goleveldb/leveldb/opt"
|
|
"github.com/syndtr/goleveldb/leveldb/testutil"
|
|
)
|
|
|
|
var _ = testutil.Defer(func() {
|
|
Describe("Leveldb external", func() {
|
|
o := &opt.Options{
|
|
DisableBlockCache: true,
|
|
BlockRestartInterval: 5,
|
|
BlockSize: 80,
|
|
Compression: opt.NoCompression,
|
|
OpenFilesCacheCapacity: -1,
|
|
Strict: opt.StrictAll,
|
|
WriteBuffer: 1000,
|
|
CompactionTableSize: 2000,
|
|
}
|
|
|
|
Describe("write test", func() {
|
|
It("should do write correctly", func(done Done) {
|
|
db := newTestingDB(o, nil, nil)
|
|
t := testutil.DBTesting{
|
|
DB: db,
|
|
Deleted: testutil.KeyValue_Generate(nil, 500, 1, 50, 5, 5).Clone(),
|
|
}
|
|
testutil.DoDBTesting(&t)
|
|
db.TestClose()
|
|
done <- true
|
|
}, 20.0)
|
|
})
|
|
|
|
Describe("read test", func() {
|
|
testutil.AllKeyValueTesting(nil, nil, func(kv testutil.KeyValue) testutil.DB {
|
|
// Building the DB.
|
|
db := newTestingDB(o, nil, nil)
|
|
kv.IterateShuffled(nil, func(i int, key, value []byte) {
|
|
err := db.TestPut(key, value)
|
|
Expect(err).NotTo(HaveOccurred())
|
|
})
|
|
|
|
return db
|
|
}, func(db testutil.DB) {
|
|
db.(*testingDB).TestClose()
|
|
})
|
|
})
|
|
|
|
Describe("transaction test", func() {
|
|
It("should do transaction correctly", func(done Done) {
|
|
db := newTestingDB(o, nil, nil)
|
|
|
|
By("creating first transaction")
|
|
var err error
|
|
tr := &testingTransaction{}
|
|
tr.Transaction, err = db.OpenTransaction()
|
|
Expect(err).NotTo(HaveOccurred())
|
|
t0 := &testutil.DBTesting{
|
|
DB: tr,
|
|
Deleted: testutil.KeyValue_Generate(nil, 200, 1, 50, 5, 5).Clone(),
|
|
}
|
|
testutil.DoDBTesting(t0)
|
|
testutil.TestGet(tr, t0.Present)
|
|
testutil.TestHas(tr, t0.Present)
|
|
|
|
By("committing first transaction")
|
|
err = tr.Commit()
|
|
Expect(err).NotTo(HaveOccurred())
|
|
testutil.TestIter(db, nil, t0.Present)
|
|
testutil.TestGet(db, t0.Present)
|
|
testutil.TestHas(db, t0.Present)
|
|
|
|
By("manipulating DB without transaction")
|
|
t0.DB = db
|
|
testutil.DoDBTesting(t0)
|
|
|
|
By("creating second transaction")
|
|
tr.Transaction, err = db.OpenTransaction()
|
|
Expect(err).NotTo(HaveOccurred())
|
|
t1 := &testutil.DBTesting{
|
|
DB: tr,
|
|
Deleted: t0.Deleted.Clone(),
|
|
Present: t0.Present.Clone(),
|
|
}
|
|
testutil.DoDBTesting(t1)
|
|
testutil.TestIter(db, nil, t0.Present)
|
|
|
|
By("discarding second transaction")
|
|
tr.Discard()
|
|
testutil.TestIter(db, nil, t0.Present)
|
|
|
|
By("creating third transaction")
|
|
tr.Transaction, err = db.OpenTransaction()
|
|
Expect(err).NotTo(HaveOccurred())
|
|
t0.DB = tr
|
|
testutil.DoDBTesting(t0)
|
|
|
|
By("committing third transaction")
|
|
err = tr.Commit()
|
|
Expect(err).NotTo(HaveOccurred())
|
|
testutil.TestIter(db, nil, t0.Present)
|
|
|
|
db.TestClose()
|
|
done <- true
|
|
}, 30.0)
|
|
})
|
|
})
|
|
})
|