files2.0: fix AddPosInfo test
License: MIT Signed-off-by: Łukasz Magiera <magik6k@gmail.com>
Łukasz Magiera committed
Nov 5, 2018 at 17:33 UTC
a43f2f85b8a9fae6ac57d7b5aa942d77d1df95de
1 file changed
+4
-3
core/coreunix/add_test.go
+4
-3
@@ -7,6 +7,7 @@ import (
7
"io/ioutil"
8
"math/rand"
9
"os"
10
+ "path/filepath"
11
"testing"
12
"time"
13
@@ -176,7 +177,7 @@ func testAddWPosInfo(t *testing.T, rawLeaves bool) {
177
t.Fatal(err)
178
}
179
179
- bs := &testBlockstore{GCBlockstore: node.Blockstore, expectedPath: "/tmp/foo.txt", t: t}
180
+ bs := &testBlockstore{GCBlockstore: node.Blockstore, expectedPath: filepath.Join(os.TempDir(), "foo.txt"), t: t}
181
bserv := blockservice.New(bs, node.Exchange)
182
dserv := dag.NewDAGService(bserv)
183
adder, err := NewAdder(context.Background(), node.Pinning, bs, dserv)
@@ -193,7 +194,7 @@ func testAddWPosInfo(t *testing.T, rawLeaves bool) {
194
rand.New(rand.NewSource(2)).Read(data) // Rand.Read never returns an error
195
fileData := ioutil.NopCloser(bytes.NewBuffer(data))
196
fileInfo := dummyFileInfo{"foo.txt", int64(len(data)), time.Now()}
196
- file := files.NewReaderFile(fileData, &fileInfo)
197
+ file, _ := files.NewReaderPathFile(filepath.Join(os.TempDir(), "foo.txt"), fileData, &fileInfo)
198
199
go func() {
200
defer close(adder.Out)
@@ -212,7 +213,7 @@ func testAddWPosInfo(t *testing.T, rawLeaves bool) {
213
nonOffZero = 19
214
}
215
if bs.countAtOffsetZero != exp {
215
- t.Fatalf("expected %d blocks with an offset at zero (one root and one leafh), got %d", exp, bs.countAtOffsetZero)
216
+ t.Fatalf("expected %d blocks with an offset at zero (one root and one leaf), got %d", exp, bs.countAtOffsetZero)
217
}
218
if bs.countAtOffsetNonZero != nonOffZero {
219
// note: the exact number will depend on the size and the sharding algo. used