experimental-cli/project/blob_test.go

40 lines
783 B
Go
Raw Permalink Normal View History

package main
import (
2020-12-08 13:18:45 +00:00
"bytes"
2020-09-30 12:56:20 +00:00
"fmt"
"path"
"testing"
)
func TestPathForBlob(t *testing.T) {
mhash := "FILE.FV0FJ0YZADY7C5JTTFYPKDBHTZJ5JVVP5TCKP0605WWXYJG4VMRG"
2020-09-30 12:56:20 +00:00
expected := path.Join(pigeonBlobDir(),
"FV0FJ0Y",
"ZADY7C5",
"JTTFYPK",
"DBHTZJ5",
"JVVP5TC",
"KP0605W",
"WXYJG4V.MRG")
p, f := pathAndFilename(mhash)
actual := path.Join(p, f)
if actual != expected {
fmt.Printf("Expected %s\n", expected)
fmt.Printf("Got %s\n", actual)
t.Fail()
}
}
2020-12-08 13:18:45 +00:00
func TestAddBlobFromPipe(t *testing.T) {
reader := bytes.NewBufferString("lol\n")
actual := addBlobFromPipe(reader)
expected := "FILE.MGJ4N91XVNQ3XYF69EW0YKQ9ABV84CNA026KVAE7HRXP4ZJPEQ40"
if actual != expected {
fmt.Printf("Expected %s\n", expected)
fmt.Printf("Got %s\n", actual)
t.Fail()
}
}