Commit ce77b1df authored by Kevin Atkinson's avatar Kevin Atkinson

Tweak TestStorage tests.

parent ef9568aa
...@@ -2,7 +2,6 @@ package flatfs_test ...@@ -2,7 +2,6 @@ package flatfs_test
import ( import (
"encoding/base32" "encoding/base32"
"fmt"
"io/ioutil" "io/ioutil"
"math" "math"
"math/rand" "math/rand"
...@@ -153,10 +152,9 @@ func testGetNotFoundError(dirFunc string, t *testing.T) { ...@@ -153,10 +152,9 @@ func testGetNotFoundError(dirFunc string, t *testing.T) {
func TestGetNotFoundError(t *testing.T) { tryAllShardFuncs(t, testGetNotFoundError) } func TestGetNotFoundError(t *testing.T) { tryAllShardFuncs(t, testGetNotFoundError) }
type params struct { type params struct {
what string shard string
dir string dir string
key string key string
dirFunc string
} }
func testStorage(p *params, t *testing.T) { func testStorage(p *params, t *testing.T) {
...@@ -164,7 +162,7 @@ func testStorage(p *params, t *testing.T) { ...@@ -164,7 +162,7 @@ func testStorage(p *params, t *testing.T) {
defer cleanup() defer cleanup()
target := p.dir + string(os.PathSeparator) + p.key + ".data" target := p.dir + string(os.PathSeparator) + p.key + ".data"
fs, err := flatfs.New(temp, fmt.Sprintf("%s/%d", p.dirFunc, len(p.dir)), false) fs, err := flatfs.New(temp, p.shard, false)
if err != nil { if err != nil {
t.Fatalf("New fail: %v\n", err) t.Fatalf("New fail: %v\n", err)
} }
...@@ -195,7 +193,7 @@ func testStorage(p *params, t *testing.T) { ...@@ -195,7 +193,7 @@ func testStorage(p *params, t *testing.T) {
haveREADME = true haveREADME = true
case p.dir: case p.dir:
if !fi.IsDir() { if !fi.IsDir() {
t.Errorf("%s directory is not a file? %v", p.what, fi.Mode()) t.Errorf("directory is not a file? %v", fi.Mode())
} }
// we know it's there if we see the file, nothing more to // we know it's there if we see the file, nothing more to
// do here // do here
...@@ -230,26 +228,23 @@ func testStorage(p *params, t *testing.T) { ...@@ -230,26 +228,23 @@ func testStorage(p *params, t *testing.T) {
func TestStorage(t *testing.T) { func TestStorage(t *testing.T) {
t.Run("prefix", func(t *testing.T) { t.Run("prefix", func(t *testing.T) {
testStorage(&params{ testStorage(&params{
what: "prefix", shard: "v1/prefix/2",
dir: "qu", dir: "qu",
key: "quux", key: "quux",
dirFunc: "prefix",
}, t) }, t)
}) })
t.Run("suffix", func(t *testing.T) { t.Run("suffix", func(t *testing.T) {
testStorage(&params{ testStorage(&params{
what: "suffix", shard: "v1/suffix/2",
dir: "ux", dir: "ux",
key: "quux", key: "quux",
dirFunc: "suffix",
}, t) }, t)
}) })
t.Run("next-to-last", func(t *testing.T) { t.Run("next-to-last", func(t *testing.T) {
testStorage(&params{ testStorage(&params{
what: "next-to-last", shard: flatfs.IPFS_DEF_SHARD,
dir: "uu", dir: "uu",
key: "quux", key: "quux",
dirFunc: "next-to-last",
}, t) }, t)
}) })
} }
......
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