diff --git a/README.md b/README.md index a0ebebe..72b11a7 100644 --- a/README.md +++ b/README.md @@ -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 | | | diff --git a/project/blob.go b/project/blob.go index 2efe60c..a7eb06c 100644 --- a/project/blob.go +++ b/project/blob.go @@ -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 { diff --git a/project/blob_test.go b/project/blob_test.go index 90bae8b..1cb1391 100644 --- a/project/blob_test.go +++ b/project/blob_test.go @@ -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() + } +} diff --git a/project/cli.go b/project/cli.go index cdb8578..776f6e7 100644 --- a/project/cli.go +++ b/project/cli.go @@ -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)