-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
55 lines (41 loc) · 971 Bytes
/
main.go
File metadata and controls
55 lines (41 loc) · 971 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package main
import (
"log"
"net/http"
"reflect"
"github.com/akaritrading/libs/db"
"github.com/akaritrading/libs/util"
"github.com/akaritrading/systemtests/tests"
)
var DB *db.DB
func main() {
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json")
err := tests.Login()
if err != nil {
util.ErrorJSON(w, err)
return
}
util.WriteJSON(w, runTests())
})
http.ListenAndServe(":8080", nil)
}
func initDB() *db.DB {
db, err := db.DefaultOpen()
if err != nil {
log.Fatal(err)
}
return db
}
func runTests() []*tests.TestRun {
var ret []*tests.TestRun
testsValue := reflect.ValueOf(tests.Test{})
testsType := reflect.TypeOf(tests.Test{})
for i := 0; i < testsValue.NumMethod(); i++ {
method := testsValue.Method(i)
run := &tests.TestRun{Name: testsType.Method(i).Name}
method.Call([]reflect.Value{reflect.ValueOf(run)})
ret = append(ret, run)
}
return ret
}