add AddString() and AddBytes() helpers

This commit is contained in:
rick 2013-10-18 17:25:30 -06:00 committed by Rick Olson
parent ddda5a3615
commit 37cae35da3
2 changed files with 10 additions and 2 deletions

@ -4,6 +4,7 @@
package queuedir
import (
"bytes"
"github.com/streadway/simpleuuid"
"io"
"os"
@ -49,3 +50,11 @@ func (q *Queue) Add(reader io.Reader) (string, error) {
}
return id, err
}
func (q *Queue) AddString(body string) (string, error) {
return q.Add(bytes.NewBufferString(body))
}
func (q *Queue) AddBytes(body []byte) (string, error) {
return q.Add(bytes.NewBuffer(body))
}

@ -1,7 +1,6 @@
package queuedir
import (
"bytes"
"io/ioutil"
"os"
"path/filepath"
@ -12,7 +11,7 @@ func TestAdd(t *testing.T) {
q := Setup(t)
defer q.Teardown()
id, err := q.Queue.Add(bytes.NewBufferString("BOOM"))
id, err := q.Queue.AddString("BOOM")
if err != nil {
t.Fatalf("Cannot add to queue: %s", err)
}