1
0
Fork 1
mirror of https://github.com/vbatts/tar-split.git synced 2024-11-15 12:58:38 +00:00
tar-split/tar/asm/getter_test.go

34 lines
580 B
Go
Raw Normal View History

2015-02-28 17:47:55 +00:00
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))
}
}
}