This repository has been archived on 2020-09-27. You can view files and clone it, but cannot push or open issues or pull requests.
thrempp/component/threema/file_test.go

30 lines
614 B
Go
Raw Normal View History

package threema
import (
"testing"
2019-06-28 03:03:38 +02:00
"gosrc.io/xmpp/stanza"
2019-06-05 04:30:00 +02:00
"github.com/stretchr/testify/assert"
)
func TestFileToXMPP(t *testing.T) {
assert := assert.New(t)
a := createDummyAccount()
a.threema = &Threema{
httpUploadURL: "a",
httpUploadPath: "/tmp",
}
msg, err := a.FileToXMPP("", 1, "jpg", []byte("hallo"))
assert.NoError(err)
2019-06-28 03:03:38 +02:00
oob := msg.Extensions[0].(stanza.OOB)
2019-06-05 04:30:00 +02:00
assert.Equal("a/1.jpg", oob.URL)
a.threema.httpUploadPath = "/gibt/es/nicht"
msg, err = a.FileToXMPP("", 1, "jpg", []byte("hallo"))
assert.Error(err)
assert.Equal("unable to save file on transport to forward", msg.Body)
}