-
Notifications
You must be signed in to change notification settings - Fork 6
/
datastore_management_service_test.go
56 lines (45 loc) · 1.23 KB
/
datastore_management_service_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
package ds2bq
import (
"bytes"
"net/http"
"net/http/httptest"
"testing"
"time"
"github.com/favclip/testerator"
"github.com/favclip/ucon"
"github.com/favclip/ucon/swagger"
)
func TestDatastoreManagementService_Post(t *testing.T) {
t.SkipNow()
inst, _, err := testerator.SpinUp()
if err != nil {
t.Fatal(err.Error())
}
defer testerator.SpinDown()
bkMux := ucon.DefaultMux
defer func() {
ucon.DefaultMux = bkMux
}()
ucon.DefaultMux = ucon.NewServeMux()
s := NewDatastoreManagementService(
ManagementWithURLs("/api/datastore-management", "/tq/datastore-management", "/tq/datastore-management/unit"),
ManagementWithQueueName("datastore-management"),
ManagementWithExpireDuration(30*24*time.Hour),
)
s.SetupWithUconSwagger(swagger.NewPlugin(nil))
ucon.Middleware(UseAppengineContext)
ucon.Orthodox()
ucon.DefaultMux.Prepare()
http.Handle("/", ucon.DefaultMux)
body := bytes.NewReader([]byte(`{}`))
r, err := inst.NewRequest("POST", "/api/gcs/object-change-notification", body)
if err != nil {
t.Fatal(err)
}
r.Header.Set("Content-Type", "application/json;charset=utf-8")
w := httptest.NewRecorder()
http.DefaultServeMux.ServeHTTP(w, r)
if w.Code != 200 {
t.Fatalf("unexpected %d, expected 200", w.Code)
}
}