forked from omigo/weixin
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmaterial_test.go
More file actions
40 lines (33 loc) · 737 Bytes
/
material_test.go
File metadata and controls
40 lines (33 loc) · 737 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package weixin
import (
"io/ioutil"
"os"
"testing"
)
func TestUploadTemporaryMaterial(t *testing.T) {
img, err := os.Open("/Users/migo/Pictures/psb.jpeg")
if err != nil {
t.Log(err)
t.FailNow()
}
mediaId, createAt, err := UploadTemporaryMaterial(MediaTypeImage, img)
if err != nil {
t.Log(err)
t.FailNow()
}
t.Logf("%#v %#v", mediaId, createAt)
}
func TestGetTemporaryMaterial(t *testing.T) {
mediaId := "Oyn8IWz0DhriA2-7C7DeLPSYdBjRmF2N89rZ1ZL68frE2wmLmp99SXz3rRE0ZJo8"
filename, content, err := GetTemporaryMaterial(mediaId)
if err != nil {
t.Log(err)
t.FailNow()
}
err = ioutil.WriteFile(filename, content, 0777)
if err != nil {
t.Log(err)
t.FailNow()
}
t.Logf("write file to %s", filename)
}