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