Commit 70540a69 authored by Steven Allen's avatar Steven Allen

chore: fix lint errors

parent 6e6008d2
......@@ -490,7 +490,7 @@ func (fs *Datastore) putMany(data map[datastore.Key][]byte) error {
defer func() {
for fi := range files {
val, _ := ops[fi]
val := ops[fi]
switch val {
case 0:
_ = fi.Close()
......@@ -667,7 +667,7 @@ func (fs *Datastore) Query(q query.Query) (query.Results, error) {
case <-p.Closing():
}
})
go b.Process.CloseAfterChildren()
go b.Process.CloseAfterChildren() //nolint
return b.Results(), nil
}
......@@ -1045,20 +1045,20 @@ func (fs *Datastore) walk(path string, result *query.ResultBuilder) error {
// Deactivate closes background maintenance threads, most write
// operations will fail but readonly operations will continue to
// function
func (fs *Datastore) deactivate() error {
func (fs *Datastore) deactivate() {
fs.shutdownLock.Lock()
defer fs.shutdownLock.Unlock()
if fs.shutdown {
return nil
return
}
fs.shutdown = true
close(fs.checkpointCh)
<-fs.done
return nil
}
func (fs *Datastore) Close() error {
return fs.deactivate()
fs.deactivate()
return nil
}
type flatfsBatch struct {
......@@ -1091,7 +1091,7 @@ func (bt *flatfsBatch) Commit() error {
return err
}
for k, _ := range bt.deletes {
for k := range bt.deletes {
if err := bt.ds.Delete(k); err != nil {
return err
}
......
......@@ -561,7 +561,7 @@ func testDiskUsageDoubleCount(dirFunc mkShardFunc, t *testing.T) {
v := []byte("10bytes---")
err := fs.Put(testKey, v)
if err != nil {
t.Fatalf("Put fail: %v\n", err)
t.Errorf("Put fail: %v\n", err)
}
}
}
......@@ -571,7 +571,7 @@ func testDiskUsageDoubleCount(dirFunc mkShardFunc, t *testing.T) {
for i := 0; i < count; i++ {
err := fs.Delete(testKey)
if err != nil && !strings.Contains(err.Error(), "key not found") {
t.Fatalf("Delete fail: %v\n", err)
t.Errorf("Delete fail: %v\n", err)
}
}
}
......@@ -624,7 +624,10 @@ func testDiskUsageBatch(dirFunc mkShardFunc, t *testing.T) {
}
defer fs.Close()
fsBatch, _ := fs.Batch()
fsBatch, err := fs.Batch()
if err != nil {
t.Fatal(err)
}
count := 200
var wg sync.WaitGroup
......@@ -636,14 +639,17 @@ func testDiskUsageBatch(dirFunc mkShardFunc, t *testing.T) {
put := func() {
for i := 0; i < count; i++ {
fsBatch.Put(testKeys[i], []byte("10bytes---"))
err := fsBatch.Put(testKeys[i], []byte("10bytes---"))
if err != nil {
t.Error(err)
}
}
}
commit := func() {
defer wg.Done()
err := fsBatch.Commit()
if err != nil {
t.Fatalf("Batch Put fail: %v\n", err)
t.Errorf("Batch Put fail: %v\n", err)
}
}
......@@ -652,7 +658,7 @@ func testDiskUsageBatch(dirFunc mkShardFunc, t *testing.T) {
for _, k := range testKeys {
err := fs.Delete(k)
if err != nil && !strings.Contains(err.Error(), "key not found") {
t.Fatalf("Delete fail: %v\n", err)
t.Errorf("Delete fail: %v\n", err)
}
}
}
......@@ -662,9 +668,15 @@ func testDiskUsageBatch(dirFunc mkShardFunc, t *testing.T) {
wg.Add(2)
put()
commit()
du, _ := fs.DiskUsage()
du, err := fs.DiskUsage()
if err != nil {
t.Fatal(err)
}
del()
du2, _ := fs.DiskUsage()
du2, err := fs.DiskUsage()
if err != nil {
t.Fatal(err)
}
if du-uint64(10*count) != du2 {
t.Errorf("should have deleted exactly %d bytes: %d %d", 10*count, du, du2)
}
......@@ -676,11 +688,17 @@ func testDiskUsageBatch(dirFunc mkShardFunc, t *testing.T) {
go del()
wg.Wait()
du3, _ := fs.DiskUsage()
du3, err := fs.DiskUsage()
if err != nil {
t.Fatal(err)
}
// Now query how many keys we have
results, err := fs.Query(query.Query{
KeysOnly: true,
})
if err != nil {
t.Fatal(err)
}
rest, err := results.Rest()
if err != nil {
t.Fatal(err)
......@@ -862,6 +880,7 @@ func TestSHARDINGFile(t *testing.T) {
fs, err = flatfs.CreateOrOpen(tempdir, flatfs.Prefix(5), false)
if err == nil {
fs.Close()
t.Fatalf("Was able to open repo with incompatible sharding function")
}
}
......@@ -877,9 +896,12 @@ func TestNonDatastoreDir(t *testing.T) {
tempdir, cleanup := tempdir(t)
defer cleanup()
ioutil.WriteFile(filepath.Join(tempdir, "afile"), []byte("Some Content"), 0644)
err := ioutil.WriteFile(filepath.Join(tempdir, "afile"), []byte("Some Content"), 0644)
if err != nil {
t.Fatal(err)
}
err := flatfs.Create(tempdir, flatfs.NextToLast(2))
err = flatfs.Create(tempdir, flatfs.NextToLast(2))
if err == nil {
t.Fatalf("Expected an error when creating a datastore in a non-empty directory")
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment