Test upkeep. Currently 71.3%

This commit is contained in:
Netscape Navigator 2020-12-08 07:18:45 -06:00
parent 6087e221a7
commit d870c23740
4 changed files with 15 additions and 9 deletions

View File

@ -39,12 +39,6 @@ Email `contact@vaporsoft.xyz` if you have any questions.
- [ ] Add a note about "shallow" vs. "deep" verification.
- [ ] Finish all the things below
# Protocol Changes?
- [X] Just ditch `lipmaa` altogether in the name of time?
- [ ] Don't enforce a structure on how blobs are packed into bundles- the client is forced to determine the SHA checksum regardless. Forced structure just complicates protocol design.
- [ ] Mandate usage of ZIP files so that bundles are always a single file?
|Done?|Noun |Verb | Flag / arg 1 | Flag 2 |
|-----|------------|-----------|---------------|-----------|
| |bundle |ingest | | |

View File

@ -62,8 +62,8 @@ func addBlob(mhash string, data []byte) string {
return mhash
}
func addBlobFromPipe() string {
reader := bufio.NewReader(os.Stdin)
func addBlobFromPipe(stdio io.Reader) string {
reader := bufio.NewReader(stdio) // os.Stdin
var output []byte
for {

View File

@ -1,6 +1,7 @@
package main
import (
"bytes"
"fmt"
"path"
"testing"
@ -25,3 +26,14 @@ func TestPathForBlob(t *testing.T) {
t.Fail()
}
}
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()
}
}

View File

@ -124,7 +124,7 @@ var blobAddCommand = &cobra.Command{
tpl := "%s\n"
var output string
if len(args) == 0 {
output = addBlobFromPipe()
output = addBlobFromPipe(os.Stdin)
} else {
mhash, data := getMhashForFile(args[0])
output = addBlob(mhash, data)