-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconnection_test.go
49 lines (42 loc) · 1005 Bytes
/
connection_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
package main
import (
"encoding/json"
"errors"
"io/ioutil"
"os"
"testing"
)
func TestDownload(t *testing.T) {
testParams := Params{}
skip, err := testParams.getTestParams()
if skip {
return
}
if err != nil {
t.Error(err)
}
dir, _ := os.Getwd()
testParams.Dir = dir
_, err = download(testParams)
if err != nil {
t.Error(err)
}
}
func (p *Params) getTestParams() (bool, error) {
// See sampleTestConnectionParams.json for a test configuration file
// Load it as an environment variable, e.g.:
// export SHIBDL_CONNECTION_PARAMS=/var/tmp/params.json"
config := os.Getenv("SHIBDL_CONNECTION_PARAMS")
if config == "" {
return true, nil
}
raw, err := ioutil.ReadFile(config)
if err != nil {
return false, errors.New("Can not read the json configuration provided ($SHIBDL_CONNECTION_PARAMS)")
}
err = json.Unmarshal(raw, p)
if err != nil {
return false, errors.New("Can not parse the json configuration provided ($SHIBDL_CONNECTION_PARAMS)")
}
return false, nil
}