-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgisqus_common_test.go
59 lines (45 loc) · 953 Bytes
/
gisqus_common_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
55
56
57
58
59
// Copyright Piero de Salvia.
// All Rights Reserved
package gisqus
import (
"context"
"fmt"
"io/ioutil"
"net/url"
"os"
"testing"
"github.com/pierods/gisqus/mock"
)
var mockServer *mock.Server
var testErr error
var testGisqus Gisqus
var testCtx context.Context
var testValues url.Values
var testDataDir string
func init() {
testValues = url.Values{}
testGisqus = NewGisqus("secret")
testCtx, _ = context.WithCancel(context.TODO())
mockServer = mock.NewMockServer()
goPath := os.Getenv("GOPATH")
testDataDir = goPath + "/src/github.com/pierods/gisqus/testdata/"
}
func TestMain(m *testing.M) {
defer mockServer.Close()
retCode := m.Run()
os.Exit(retCode)
}
func readTestFile(fileName string) string {
f, err := os.Open(testDataDir + fileName)
defer f.Close()
if err != nil {
fmt.Println(err)
os.Exit(-1)
}
bytes, err := ioutil.ReadAll(f)
if err != nil {
fmt.Println(err)
os.Exit(-1)
}
return string(bytes)
}