add AddString() and AddBytes() helpers
This commit is contained in:
parent
ddda5a3615
commit
37cae35da3
@ -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)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user