Fix formatting
continuous-integration/drone/push Build is failing
Details
continuous-integration/drone/push Build is failing
Details
parent
3ff4759790
commit
b273ee9390
17
.drone.yml
17
.drone.yml
|
@ -1,4 +1,19 @@
|
||||||
kind: pipeline
|
kind: pipeline
|
||||||
|
name: tests-fmt
|
||||||
|
steps:
|
||||||
|
- name: go
|
||||||
|
image: golang:1.13
|
||||||
|
commands:
|
||||||
|
- make test_fmt
|
||||||
|
trigger:
|
||||||
|
branch:
|
||||||
|
- master
|
||||||
|
- develop
|
||||||
|
event:
|
||||||
|
- push
|
||||||
|
- pull_request
|
||||||
|
---
|
||||||
|
kind: pipeline
|
||||||
name: tests-integration
|
name: tests-integration
|
||||||
steps:
|
steps:
|
||||||
- name: wait
|
- name: wait
|
||||||
|
@ -36,7 +51,7 @@ kind: pipeline
|
||||||
name: tests-unit
|
name: tests-unit
|
||||||
steps:
|
steps:
|
||||||
- name: go
|
- name: go
|
||||||
image: golang:1.12
|
image: golang:1.13
|
||||||
commands:
|
commands:
|
||||||
- make test_unit
|
- make test_unit
|
||||||
trigger:
|
trigger:
|
||||||
|
|
4
Makefile
4
Makefile
|
@ -3,6 +3,7 @@ GORUN=$(GOCMD) run
|
||||||
GOBUILD=$(GOCMD) build
|
GOBUILD=$(GOCMD) build
|
||||||
GOCLEAN=$(GOCMD) clean
|
GOCLEAN=$(GOCMD) clean
|
||||||
GOTEST=$(GOCMD) test
|
GOTEST=$(GOCMD) test
|
||||||
|
GOFMT_PROG=gofmt
|
||||||
DOCKERCOMPOSE=docker-compose
|
DOCKERCOMPOSE=docker-compose
|
||||||
|
|
||||||
|
|
||||||
|
@ -18,6 +19,9 @@ build:
|
||||||
|
|
||||||
test: test_unit test_integration
|
test: test_unit test_integration
|
||||||
|
|
||||||
|
test_fmt:
|
||||||
|
$(GOFMT_PROG) -l .
|
||||||
|
|
||||||
test_unit:
|
test_unit:
|
||||||
$(GOTEST) -tags=unit -v -cover
|
$(GOTEST) -tags=unit -v -cover
|
||||||
|
|
||||||
|
|
|
@ -56,13 +56,13 @@ func (h *Handler) CreateContact(w http.ResponseWriter, r *http.Request, p httpro
|
||||||
|
|
||||||
// Publish NATs
|
// Publish NATs
|
||||||
if h.nc != nil {
|
if h.nc != nil {
|
||||||
contact := Contact {
|
contact := Contact{
|
||||||
UserA: userID,
|
UserA: userID,
|
||||||
UserB: contact.ID,
|
UserB: contact.ID,
|
||||||
}
|
}
|
||||||
contactString, err := json.Marshal(&contact)
|
contactString, err := json.Marshal(&contact)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
updateMsg := UpdateMsg {
|
updateMsg := UpdateMsg{
|
||||||
Type: "add",
|
Type: "add",
|
||||||
Data: string(contactString),
|
Data: string(contactString),
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,7 +61,7 @@ func (h *Handler) CreateConversation(w http.ResponseWriter, r *http.Request, p h
|
||||||
if h.nc != nil {
|
if h.nc != nil {
|
||||||
conversationString, err := json.Marshal(&conversation)
|
conversationString, err := json.Marshal(&conversation)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
updateMsg := UpdateMsg {
|
updateMsg := UpdateMsg{
|
||||||
Type: "add",
|
Type: "add",
|
||||||
Data: string(conversationString),
|
Data: string(conversationString),
|
||||||
}
|
}
|
||||||
|
@ -200,7 +200,7 @@ func (h *Handler) UpdateConversation(w http.ResponseWriter, r *http.Request, p h
|
||||||
if h.nc != nil {
|
if h.nc != nil {
|
||||||
conversationString, err := json.Marshal(&conversation)
|
conversationString, err := json.Marshal(&conversation)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
updateMsg := UpdateMsg {
|
updateMsg := UpdateMsg{
|
||||||
Type: "update",
|
Type: "update",
|
||||||
Data: string(conversationString),
|
Data: string(conversationString),
|
||||||
}
|
}
|
||||||
|
@ -268,12 +268,12 @@ func (h *Handler) DeleteConversation(w http.ResponseWriter, r *http.Request, p h
|
||||||
|
|
||||||
// Publish NATs
|
// Publish NATs
|
||||||
if h.nc != nil {
|
if h.nc != nil {
|
||||||
conversation := Conversation {
|
conversation := Conversation{
|
||||||
ID: conversationID,
|
ID: conversationID,
|
||||||
}
|
}
|
||||||
conversationString, err := json.Marshal(&conversation)
|
conversationString, err := json.Marshal(&conversation)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
updateMsg := UpdateMsg {
|
updateMsg := UpdateMsg{
|
||||||
Type: "delete",
|
Type: "delete",
|
||||||
Data: string(conversationString),
|
Data: string(conversationString),
|
||||||
}
|
}
|
||||||
|
@ -380,14 +380,14 @@ func (h *Handler) CreateConversationMember(w http.ResponseWriter, r *http.Reques
|
||||||
|
|
||||||
// Publish NATs
|
// Publish NATs
|
||||||
if h.nc != nil {
|
if h.nc != nil {
|
||||||
member := Member {
|
member := Member{
|
||||||
User: member.ID,
|
User: member.ID,
|
||||||
Conversation: conversationID,
|
Conversation: conversationID,
|
||||||
Pinned: false, // default
|
Pinned: false, // default
|
||||||
}
|
}
|
||||||
memberString, err := json.Marshal(&member)
|
memberString, err := json.Marshal(&member)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
updateMsg := UpdateMsg {
|
updateMsg := UpdateMsg{
|
||||||
Type: "add",
|
Type: "add",
|
||||||
Data: string(memberString),
|
Data: string(memberString),
|
||||||
}
|
}
|
||||||
|
@ -467,14 +467,14 @@ func (h *Handler) PinConversation(w http.ResponseWriter, r *http.Request, p http
|
||||||
|
|
||||||
// Publish NATs
|
// Publish NATs
|
||||||
if h.nc != nil {
|
if h.nc != nil {
|
||||||
member := Member {
|
member := Member{
|
||||||
User: userID,
|
User: userID,
|
||||||
Conversation: conversationID,
|
Conversation: conversationID,
|
||||||
Pinned: true,
|
Pinned: true,
|
||||||
}
|
}
|
||||||
memberString, err := json.Marshal(&member)
|
memberString, err := json.Marshal(&member)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
updateMsg := UpdateMsg {
|
updateMsg := UpdateMsg{
|
||||||
Type: "update",
|
Type: "update",
|
||||||
Data: string(memberString),
|
Data: string(memberString),
|
||||||
}
|
}
|
||||||
|
|
2
main.go
2
main.go
|
@ -7,8 +7,8 @@ import (
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/joho/godotenv"
|
"github.com/joho/godotenv"
|
||||||
"github.com/nats-io/go-nats"
|
|
||||||
_ "github.com/lib/pq"
|
_ "github.com/lib/pq"
|
||||||
|
"github.com/nats-io/go-nats"
|
||||||
)
|
)
|
||||||
|
|
||||||
var listen string
|
var listen string
|
||||||
|
|
|
@ -53,9 +53,9 @@ func Subscribe(channels map[string]chan []byte, w http.ResponseWriter, r *http.R
|
||||||
case msg := <-recv:
|
case msg := <-recv:
|
||||||
fmt.Fprintf(w, "data: %s\n\n", msg)
|
fmt.Fprintf(w, "data: %s\n\n", msg)
|
||||||
flusher.Flush()
|
flusher.Flush()
|
||||||
case <- ticker.C:
|
case <-ticker.C:
|
||||||
w.Write([]byte(":\n\n"))
|
w.Write([]byte(":\n\n"))
|
||||||
case <- resClosed:
|
case <-resClosed:
|
||||||
ticker.Stop()
|
ticker.Stop()
|
||||||
delete(channels, id)
|
delete(channels, id)
|
||||||
return
|
return
|
||||||
|
|
4
user.go
4
user.go
|
@ -54,7 +54,7 @@ func (h *Handler) CreateUser(w http.ResponseWriter, r *http.Request, _ httproute
|
||||||
if h.nc != nil {
|
if h.nc != nil {
|
||||||
userString, err := json.Marshal(&user)
|
userString, err := json.Marshal(&user)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
updateMsg := UpdateMsg {
|
updateMsg := UpdateMsg{
|
||||||
Type: "add",
|
Type: "add",
|
||||||
Data: string(userString),
|
Data: string(userString),
|
||||||
}
|
}
|
||||||
|
@ -185,7 +185,7 @@ func (h *Handler) UpdateUser(w http.ResponseWriter, r *http.Request, p httproute
|
||||||
if h.nc != nil {
|
if h.nc != nil {
|
||||||
userString, err := json.Marshal(&user)
|
userString, err := json.Marshal(&user)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
updateMsg := UpdateMsg {
|
updateMsg := UpdateMsg{
|
||||||
Type: "update",
|
Type: "update",
|
||||||
Data: string(userString),
|
Data: string(userString),
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue