mirror of
https://github.com/vbatts/dedupe-linker.git
synced 2024-12-26 16:46:32 +00:00
base: fix test, minimize base root path
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
This commit is contained in:
parent
aa4b5f4c39
commit
c67d7baba3
2 changed files with 14 additions and 7 deletions
|
@ -15,13 +15,12 @@ import (
|
|||
)
|
||||
|
||||
func NewBase(path string, hashName string) (*Base, error) {
|
||||
root := filepath.Join(path, "dedup")
|
||||
for _, p := range []string{"blobs/" + hashName, "state", "tmp"} {
|
||||
if err := os.MkdirAll(filepath.Join(root, p), 0755); err != nil && !os.IsExist(err) {
|
||||
if err := os.MkdirAll(filepath.Join(path, p), 0755); err != nil && !os.IsExist(err) {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return &Base{Path: root, HashName: hashName, Hash: cryptomap.DetermineHash(hashName)}, nil
|
||||
return &Base{Path: path, HashName: hashName, Hash: cryptomap.DetermineHash(hashName)}, nil
|
||||
}
|
||||
|
||||
type Base struct {
|
||||
|
|
|
@ -2,7 +2,6 @@ package base
|
|||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path"
|
||||
|
@ -50,7 +49,7 @@ func TestGetPut(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
|
||||
rHash := "deadbeaf"
|
||||
rHash := "8f074e76e82ae6156c451019840a6f857bbe5157"
|
||||
rMsg := "this is the dead beef"
|
||||
|
||||
r := bytes.NewReader([]byte(rMsg))
|
||||
|
@ -58,12 +57,18 @@ func TestGetPut(t *testing.T) {
|
|||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
if sum != rHash {
|
||||
t.Errorf("expected %q; got %q", rHash, sum)
|
||||
}
|
||||
|
||||
fi, err := b.Stat(rHash)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
fmt.Printf("%#v\n", fi.Sys())
|
||||
if fi == nil {
|
||||
t.Fatal("did not find the blob " + rHash)
|
||||
}
|
||||
//fmt.Printf("%#v\n", fi.Sys())
|
||||
|
||||
if err = b.LinkTo(path.Join(srcDir, "beef1.txt"), rHash); err != nil {
|
||||
t.Error(err)
|
||||
|
@ -72,7 +77,10 @@ func TestGetPut(t *testing.T) {
|
|||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
fmt.Printf("%#v\n", fi2.Sys())
|
||||
if fi2 == nil {
|
||||
t.Fatal("did not find the linked file " + path.Join(srcDir, "beef1.txt"))
|
||||
}
|
||||
//fmt.Printf("%#v\n", fi2.Sys())
|
||||
|
||||
if err = b.LinkTo(path.Join(srcDir, "beef1.txt"), rHash); err != nil && !os.IsExist(err) {
|
||||
t.Error(err)
|
||||
|
|
Loading…
Reference in a new issue