1
0
Fork 1
mirror of https://github.com/vbatts/tar-split.git synced 2024-11-15 04:58:36 +00:00
tar-split/tar/asm/getter_test.go
Vincent Batts 4e27d04b0b tar/asm: DiscardFilePutter and stub disassemble
Have a bit-bucket FilePutter, for when it does not matter.

Beginning thoughts on disassembly, but it has things that need thought.
Mostly comments in the function for now.
2015-03-02 15:25:03 -05:00

47 lines
902 B
Go

package asm
import (
"bytes"
"io/ioutil"
"testing"
)
func TestGetter(t *testing.T) {
fgp := NewBufferFileGetPutter()
files := map[string][]byte{
"file1.txt": []byte("foo"),
"file2.txt": []byte("bar"),
}
for n, b := range files {
if err := fgp.Put(n, bytes.NewBuffer(b)); err != nil {
t.Error(err)
}
}
for n, b := range files {
r, err := fgp.Get(n)
if err != nil {
t.Error(err)
}
buf, err := ioutil.ReadAll(r)
if err != nil {
t.Error(err)
}
if string(b) != string(buf) {
t.Errorf("expected %q, got %q", string(b), string(buf))
}
}
}
func TestPutter(t *testing.T) {
fp := NewDiscardFilePutter()
files := map[string][]byte{
"file1.txt": []byte("foo"),
"file2.txt": []byte("bar"),
"file3.txt": []byte("baz"),
"file4.txt": []byte("bif"),
}
for n, b := range files {
if err := fp.Put(n, bytes.NewBuffer(b)); err != nil {
t.Error(err)
}
}
}