mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
fix tests
This commit is contained in:
parent
42cb05c088
commit
36b632ebcb
|
@ -1,6 +1,7 @@
|
||||||
package leveldb
|
package leveldb
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"github.com/chrislusf/seaweedfs/weed/filer2"
|
"github.com/chrislusf/seaweedfs/weed/filer2"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
|
@ -18,6 +19,8 @@ func TestCreateAndFind(t *testing.T) {
|
||||||
|
|
||||||
fullpath := filer2.FullPath("/home/chris/this/is/one/file1.jpg")
|
fullpath := filer2.FullPath("/home/chris/this/is/one/file1.jpg")
|
||||||
|
|
||||||
|
ctx := context.Background()
|
||||||
|
|
||||||
entry1 := &filer2.Entry{
|
entry1 := &filer2.Entry{
|
||||||
FullPath: fullpath,
|
FullPath: fullpath,
|
||||||
Attr: filer2.Attr{
|
Attr: filer2.Attr{
|
||||||
|
@ -27,12 +30,12 @@ func TestCreateAndFind(t *testing.T) {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := filer.CreateEntry(entry1); err != nil {
|
if err := filer.CreateEntry(ctx, entry1); err != nil {
|
||||||
t.Errorf("create entry %v: %v", entry1.FullPath, err)
|
t.Errorf("create entry %v: %v", entry1.FullPath, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
entry, err := filer.FindEntry(fullpath)
|
entry, err := filer.FindEntry(ctx, fullpath)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("find entry: %v", err)
|
t.Errorf("find entry: %v", err)
|
||||||
|
@ -45,14 +48,14 @@ func TestCreateAndFind(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// checking one upper directory
|
// checking one upper directory
|
||||||
entries, _ := filer.ListDirectoryEntries(filer2.FullPath("/home/chris/this/is/one"), "", false, 100)
|
entries, _ := filer.ListDirectoryEntries(ctx, filer2.FullPath("/home/chris/this/is/one"), "", false, 100)
|
||||||
if len(entries) != 1 {
|
if len(entries) != 1 {
|
||||||
t.Errorf("list entries count: %v", len(entries))
|
t.Errorf("list entries count: %v", len(entries))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// checking one upper directory
|
// checking one upper directory
|
||||||
entries, _ = filer.ListDirectoryEntries(filer2.FullPath("/"), "", false, 100)
|
entries, _ = filer.ListDirectoryEntries(ctx, filer2.FullPath("/"), "", false, 100)
|
||||||
if len(entries) != 1 {
|
if len(entries) != 1 {
|
||||||
t.Errorf("list entries count: %v", len(entries))
|
t.Errorf("list entries count: %v", len(entries))
|
||||||
return
|
return
|
||||||
|
@ -70,7 +73,7 @@ func TestEmptyRoot(t *testing.T) {
|
||||||
filer.DisableDirectoryCache()
|
filer.DisableDirectoryCache()
|
||||||
|
|
||||||
// checking one upper directory
|
// checking one upper directory
|
||||||
entries, err := filer.ListDirectoryEntries(filer2.FullPath("/"), "", false, 100)
|
entries, err := filer.ListDirectoryEntries(ctx, filer2.FullPath("/"), "", false, 100)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("list entries: %v", err)
|
t.Errorf("list entries: %v", err)
|
||||||
return
|
return
|
||||||
|
|
|
@ -13,6 +13,8 @@ func TestCreateAndFind(t *testing.T) {
|
||||||
filer.SetStore(store)
|
filer.SetStore(store)
|
||||||
filer.DisableDirectoryCache()
|
filer.DisableDirectoryCache()
|
||||||
|
|
||||||
|
ctx := context.Background()
|
||||||
|
|
||||||
fullpath := filer2.FullPath("/home/chris/this/is/one/file1.jpg")
|
fullpath := filer2.FullPath("/home/chris/this/is/one/file1.jpg")
|
||||||
|
|
||||||
entry1 := &filer2.Entry{
|
entry1 := &filer2.Entry{
|
||||||
|
@ -24,12 +26,12 @@ func TestCreateAndFind(t *testing.T) {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := filer.CreateEntry(entry1); err != nil {
|
if err := filer.CreateEntry(ctx, entry1); err != nil {
|
||||||
t.Errorf("create entry %v: %v", entry1.FullPath, err)
|
t.Errorf("create entry %v: %v", entry1.FullPath, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
entry, err := filer.FindEntry(fullpath)
|
entry, err := filer.FindEntry(ctx, fullpath)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("find entry: %v", err)
|
t.Errorf("find entry: %v", err)
|
||||||
|
|
Loading…
Reference in a new issue