Skip to content

Commit

Permalink
apache#79 bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
GuoYL123 committed Mar 3, 2020
1 parent a2e1a9c commit 9d00fd6
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 20 deletions.
2 changes: 1 addition & 1 deletion deployments/db.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ db.createCollection( "polling_detail", {
bsonType: "string",
},
params: {
bsonType: "string"
bsonType: "object"
},
ip: {
bsonType: "string"
Expand Down
21 changes: 6 additions & 15 deletions server/resource/v1/history_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package v1_test

import (
"bytes"
"context"
"encoding/json"
"fmt"
Expand Down Expand Up @@ -87,30 +86,22 @@ func TestHistoryResource_GetRevisions(t *testing.T) {
}

func TestHistoryResource_GetPollingData(t *testing.T) {
t.Run("put kv, label is service", func(t *testing.T) {
kv := &model.KVDoc{
Value: "1s",
Labels: map[string]string{"service": "utService"},
}
j, _ := json.Marshal(kv)
r, _ := http.NewRequest("PUT", "/v1/test/kie/kv/timeout", bytes.NewBuffer(j))
t.Run("list kv by service label, to create a polling data", func(t *testing.T) {
r, _ := http.NewRequest("GET", "/v1/test/kie/kv", nil)
noopH := &handler2.NoopAuthHandler{}
chain, _ := handler.CreateChain(common.Provider, "testchain1", noopH.Name())
r.Header.Set("Content-Type", "application/json")
r.Header.Set("sessionID", "test")
kvr := &v1.KVResource{}
c, _ := restfultest.New(kvr, chain)
c, err := restfultest.New(kvr, chain)
assert.NoError(t, err)
resp := httptest.NewRecorder()
c.ServeHTTP(resp, r)

body, err := ioutil.ReadAll(resp.Body)
assert.NoError(t, err)
data := &model.KVDoc{}
err = json.Unmarshal(body, data)
result := &model.KVResponse{}
err = json.Unmarshal(body, result)
assert.NoError(t, err)
assert.NotEmpty(t, data.ID)
assert.Equal(t, kv.Value, data.Value)
assert.Equal(t, kv.Labels, data.Labels)
})
t.Run("get polling data", func(t *testing.T) {
r, _ := http.NewRequest("GET", "/v1/test/kie/polling_data?sessionId=test", nil)
Expand Down
5 changes: 1 addition & 4 deletions server/resource/v1/kv_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func init() {
ListenPeerAddr: "127.0.0.1:4000",
AdvertiseAddr: "127.0.0.1:4000",
}
config.Configurations.DB.URI = "mongodb://kie:123@127.0.0.1:27017/kie"
config.Configurations.DB.URI = "mongodb://kie:123@192.168.0.5:27017/kie"
err := service.DBInit()
if err != nil {
panic(err)
Expand All @@ -76,7 +76,6 @@ func TestKVResource_Put(t *testing.T) {
noopH := &handler2.NoopAuthHandler{}
chain, _ := handler.CreateChain(common.Provider, "testchain1", noopH.Name())
r.Header.Set("Content-Type", "application/json")
r.Header.Set("sessionID", "test")
kvr := &v1.KVResource{}
c, _ := restfultest.New(kvr, chain)
resp := httptest.NewRecorder()
Expand All @@ -101,7 +100,6 @@ func TestKVResource_Put(t *testing.T) {
noopH := &handler2.NoopAuthHandler{}
chain, _ := handler.CreateChain(common.Provider, "testchain1", noopH.Name())
r.Header.Set("Content-Type", "application/json")
r.Header.Set("sessionID", "test")
kvr := &v1.KVResource{}
c, _ := restfultest.New(kvr, chain)
resp := httptest.NewRecorder()
Expand All @@ -127,7 +125,6 @@ func TestKVResource_Put(t *testing.T) {
noopH := &handler2.NoopAuthHandler{}
chain, _ := handler.CreateChain(common.Provider, "testchain1", noopH.Name())
r.Header.Set("Content-Type", "application/json")
r.Header.Set("sessionID", "test")
kvr := &v1.KVResource{}
c, _ := restfultest.New(kvr, chain)
resp := httptest.NewRecorder()
Expand Down

0 comments on commit 9d00fd6

Please sign in to comment.