-
Notifications
You must be signed in to change notification settings - Fork 78
/
trigger_test.go
executable file
·75 lines (58 loc) · 1.26 KB
/
trigger_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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
package coap
import "io/ioutil"
//"encoding/json"
//"net/http"
//"testing"
//"net/http"
//"github.com/TIBCOSoftware/flogo-lib/core/trigger"
var jsonTestMetadata = getTestJsonMetadata()
func getTestJsonMetadata() string {
jsonMetadataBytes, err := ioutil.ReadFile("trigger.json")
if err != nil {
panic("No Json Metadata found for trigger.json path")
}
return string(jsonMetadataBytes)
}
const testConfig string = `{
"id": "flogo-coap",
"ref": "github.com/TIBCOSoftware/flogo-contrib/trigger/coap",
"settings": {
"port": "5683"
},
"handlers": [
{
"actionId": "my_test_flow",
"settings": {
"method": "POST",
"path": "/device/:id/reset"
}
}
]
}
`
/*
// TODO Fix this test
func TestHandlerOk(t *testing.T) {
config := trigger.Config{}
json.Unmarshal([]byte(testConfig), &config)
// New factory
f := &CoapFactory{}
tgr := f.New(&config)
runner := &TestRunner{}
tgr.Init(runner)
tgr.Start()
defer tgr.Stop()
uri := "http://127.0.0.1:5683/device/12345/reset"
req, err := http.NewRequest("POST", uri, nil)
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
log.Debug("response Status:", resp.Status)
if resp.StatusCode >= 300 {
t.Fail()
}
}
*/