-
Notifications
You must be signed in to change notification settings - Fork 6
/
pinboard_test.go
54 lines (44 loc) · 1.25 KB
/
pinboard_test.go
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package pinboard
import (
"fmt"
"os"
"testing"
"time"
)
var optAdd *PostsAddOptions
// Can't test anything without proper authentication.
func TestMain(m *testing.M) {
tokenEnv, ok := os.LookupEnv("PINBOARD_TOKEN")
if !ok {
fmt.Println("PINBOARD_TOKEN env not set")
os.Exit(1)
}
SetToken(tokenEnv)
opt, err := testPostAddOptions()
if err != nil {
fmt.Println("could not create test post options")
os.Exit(1)
}
optAdd = opt
os.Exit(m.Run())
}
func testPostAddOptions() (*PostsAddOptions, error) {
dt, err := time.Parse(time.RFC3339, "2010-12-11T19:48:02Z")
if err != nil {
return nil, err
}
// Post for testing functions. Usually this will be added and
// removed within each test. Make sure Replace is true
// otherwise "item already exists" errors will ensue.
testPost := PostsAddOptions{
URL: "https://github.com/imwally/pinboard",
Description: "Testing Pinboard Go Package",
Extended: []byte("This is a test from imwally's golang pinboard package. For more information please refer to the pinned URL."),
Tags: []string{"pin", "pinboard", "test", "testing", "pinboard_1_testing", "pinboard_testing"},
Dt: dt,
Toread: true,
Shared: true,
Replace: true,
}
return &testPost, nil
}