Skip to content

Commit

Permalink
Adding slash between topic prefix and sufix
Browse files Browse the repository at this point in the history
  • Loading branch information
Guilherme Souza committed Mar 15, 2017
1 parent a9689ba commit 0df27d2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion app/histories.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func HistoriesHandler(app *App) func(c echo.Context) error {
from, err := strconv.Atoi(c.QueryParam("from"))
limit, err := strconv.Atoi(c.QueryParam("limit"))
for i, topicSuffix := range topicsSuffix {
topics[i] = topicPrefix + topicSuffix
topics[i] = topicPrefix + "/" + topicSuffix
}
if limit == 0 {
limit = 10
Expand Down
18 changes: 9 additions & 9 deletions app/histories_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ func TestHistoriesHandler(t *testing.T) {
a := GetDefaultTestApp()
testId := strings.Replace(uuid.NewV4().String(), "-", "", -1)
testId2 := strings.Replace(uuid.NewV4().String(), "-", "", -1)
topic := fmt.Sprintf("chat/test_%s", testId)
topic2 := fmt.Sprintf("chat/test_%s", testId2)
topic := fmt.Sprintf("chat/test/%s", testId)
topic2 := fmt.Sprintf("chat/test/%s", testId2)
authStr := fmt.Sprintf("test:test-%s", topic)
authStr2 := fmt.Sprintf("test:test-%s", topic2)
rc := redisclient.GetRedisClient("localhost", 4444, "")
Expand Down Expand Up @@ -78,7 +78,7 @@ func TestHistoriesHandler(t *testing.T) {
Expect(err).To(BeNil())

refreshIndex()
path := fmt.Sprintf("/histories/chat/test_?userid=test:test&topics=%s,%s", testId, testId2)
path := fmt.Sprintf("/histories/chat/test?userid=test:test&topics=%s,%s", testId, testId2)
status, body := Get(a, path, t)
g.Assert(status).Equal(http.StatusOK)

Expand All @@ -93,8 +93,8 @@ func TestHistoriesHandler(t *testing.T) {
a := GetDefaultTestApp()
testId := strings.Replace(uuid.NewV4().String(), "-", "", -1)
testId2 := strings.Replace(uuid.NewV4().String(), "-", "", -1)
topic := fmt.Sprintf("chat/test_%s", testId)
topic2 := fmt.Sprintf("chat/test_%s", testId2)
topic := fmt.Sprintf("chat/test/%s", testId)
topic2 := fmt.Sprintf("chat/test/%s", testId2)
authStr := fmt.Sprintf("test:test-%s", topic)
rc := redisclient.GetRedisClient("localhost", 4444, "")
_, err := rc.Pool.Get().Do("set", "test:test", "lalala")
Expand All @@ -120,7 +120,7 @@ func TestHistoriesHandler(t *testing.T) {
Expect(err).To(BeNil())

refreshIndex()
path := fmt.Sprintf("/histories/chat/test_?userid=test:test&topics=%s,%s", testId, testId2)
path := fmt.Sprintf("/histories/chat/test?userid=test:test&topics=%s,%s", testId, testId2)
status, body := Get(a, path, t)
g.Assert(status).Equal(http.StatusOK)

Expand All @@ -135,8 +135,8 @@ func TestHistoriesHandler(t *testing.T) {
a := GetDefaultTestApp()
testId := strings.Replace(uuid.NewV4().String(), "-", "", -1)
testId2 := strings.Replace(uuid.NewV4().String(), "-", "", -1)
topic := fmt.Sprintf("chat/test_%s", testId)
topic2 := fmt.Sprintf("chat/test_%s", testId2)
topic := fmt.Sprintf("chat/test/%s", testId)
topic2 := fmt.Sprintf("chat/test/%s", testId2)
rc := redisclient.GetRedisClient("localhost", 4444, "")
_, err := rc.Pool.Get().Do("set", "test:test", "lalala")
Expect(err).To(BeNil())
Expand All @@ -160,7 +160,7 @@ func TestHistoriesHandler(t *testing.T) {
Expect(err).To(BeNil())

refreshIndex()
path := fmt.Sprintf("/histories/chat/test_?userid=test:test&topics=%s,%s", testId, testId2)
path := fmt.Sprintf("/histories/chat/test?userid=test:test&topics=%s,%s", testId, testId2)
status, _ := Get(a, path, t)
g.Assert(status).Equal(http.StatusUnauthorized)
})
Expand Down

0 comments on commit 0df27d2

Please sign in to comment.