Part I of bundle import tests
This commit is contained in:
parent
f38ed31279
commit
df61290c12
|
@ -42,17 +42,25 @@ func createBlobDirectory(mhash string) string {
|
||||||
return path.Join(dirPath, fileName)
|
return path.Join(dirPath, fileName)
|
||||||
}
|
}
|
||||||
|
|
||||||
// func fileExists(filename string) bool {
|
func fileExists(filename string) bool {
|
||||||
// info, err := os.Stat(filename)
|
info, err := os.Stat(filename)
|
||||||
// if os.IsNotExist(err) {
|
if os.IsNotExist(err) {
|
||||||
// return false
|
return false
|
||||||
// }
|
}
|
||||||
// return !info.IsDir()
|
return !info.IsDir()
|
||||||
// }
|
}
|
||||||
|
|
||||||
// func blobExists(mhash string) bool {
|
func blobExists(mhash string) bool {
|
||||||
// return fileExists(createBlobDirectory(mhash))
|
p1, fname := pathAndFilename(mhash)
|
||||||
// }
|
p2 := path.Join(p1, fname)
|
||||||
|
result := fileExists(p2)
|
||||||
|
if result {
|
||||||
|
fmt.Printf("$$$$$ GOT IT %s\n", p2)
|
||||||
|
} else {
|
||||||
|
fmt.Printf("$$$$$ NOPE %s\n", p2)
|
||||||
|
}
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
func addBlob(mhash string, data []byte) string {
|
func addBlob(mhash string, data []byte) string {
|
||||||
size := len(data)
|
size := len(data)
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"os/exec"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -28,6 +29,8 @@ func resetDB() {
|
||||||
if tx.Commit() != nil {
|
if tx.Commit() != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
exec.Command("rm", "-rf", pigeonBlobDir())
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSetUpTeardown(t *testing.T) {
|
func TestSetUpTeardown(t *testing.T) {
|
||||||
|
|
|
@ -6,16 +6,34 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestImportBundle(t *testing.T) {
|
func TestImportBundle(t *testing.T) {
|
||||||
|
resetDB()
|
||||||
|
files := []string{
|
||||||
|
"FILE.622PRNJ7C0S05XR2AHDPKWMG051B1QW5SXMN2RQHF2AND6J8VGPG",
|
||||||
|
"FILE.FV0FJ0YZADY7C5JTTFYPKDBHTZJ5JVVP5TCKP0605WWXYJG4VMRG",
|
||||||
|
"FILE.YPF11E5N9JFVB6KB1N1WDVVT9DXMCHE0XJWBZHT2CQ29S5SEPCSG",
|
||||||
|
}
|
||||||
author := "USER.09XBQDDGZPEKFBFBY67XNR5QA0TRWAKYKYNEDNQTZJV0F1JB0DGG"
|
author := "USER.09XBQDDGZPEKFBFBY67XNR5QA0TRWAKYKYNEDNQTZJV0F1JB0DGG"
|
||||||
addPeer(author, following)
|
addPeer(author, following)
|
||||||
error := importBundle("../fixtures/has_blobs/messages.pgn")
|
error := importBundle("../fixtures/has_blobs/messages.pgn")
|
||||||
check(error, "Error while importing: %s", error)
|
check(error, "Error while importing: %s", error)
|
||||||
|
|
||||||
fmt.Println("NEXT STEP: Assert that we have the following assets:")
|
fmt.Println("NEXT STEP: Assert that we have the following assets:")
|
||||||
fmt.Println("FILE.622PRNJ7C0S05XR2AHDPKWMG051B1QW5SXMN2RQHF2AND6J8VGPG")
|
|
||||||
fmt.Println("FILE.FV0FJ0YZADY7C5JTTFYPKDBHTZJ5JVVP5TCKP0605WWXYJG4VMRG")
|
for _, mhash := range files {
|
||||||
fmt.Println("FILE.YPF11E5N9JFVB6KB1N1WDVVT9DXMCHE0XJWBZHT2CQ29S5SEPCSG")
|
if !blobExists(mhash) {
|
||||||
fmt.Println("TEXT.RGKRHC0APNN9FCJTVBN1NR1ZYQ9ZY34PYYASSMJ6016S30ZTWHR0")
|
t.Fatalf("### Can't find blob: %s", mhash)
|
||||||
fmt.Println("TEXT.V52B1GH1XS8K1QKJG3AK127XYA23E82J0A2ZQTJ08TF8NZN2A1Y0")
|
}
|
||||||
fmt.Println("TEXT.Z3QS1HPX756E22XWKXAXH7NTSTJGY0AHEM9KQNATTC6HHCACZGN0")
|
}
|
||||||
|
|
||||||
|
t.Fatal("Next step: uncomment code below")
|
||||||
|
// messages := []string{
|
||||||
|
// "TEXT.RGKRHC0APNN9FCJTVBN1NR1ZYQ9ZY34PYYASSMJ6016S30ZTWHR0",
|
||||||
|
// "TEXT.V52B1GH1XS8K1QKJG3AK127XYA23E82J0A2ZQTJ08TF8NZN2A1Y0",
|
||||||
|
// "TEXT.Z3QS1HPX756E22XWKXAXH7NTSTJGY0AHEM9KQNATTC6HHCACZGN0",
|
||||||
|
// }
|
||||||
|
// for _, mhash := range messages {
|
||||||
|
// if !messageExists(mhash) {
|
||||||
|
// t.Fatalf("Can't find message: %s", mhash)
|
||||||
|
// }
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue