From 31f5bf714a427443d67540f59ccc567a0ec531cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Du=C5=A1an=20Borov=C4=8Danin?= Date: Tue, 26 Jan 2021 01:07:06 +0100 Subject: [PATCH] NOISSUE - Fix run script and compiler warnings (#1336) * Fix NATS server naming in run script Signed-off-by: dusanb94 * Fix warnings Signed-off-by: dusanb94 * Fix typo Signed-off-by: dusanb94 --- .env | 2 +- logger/level.go | 3 ++- readers/mongodb/messages.go | 3 --- scripts/run.sh | 8 ++++---- twins/mocks/states.go | 5 +++-- 5 files changed, 10 insertions(+), 11 deletions(-) diff --git a/.env b/.env index d1ff3c2d..10d7e3b3 100644 --- a/.env +++ b/.env @@ -86,7 +86,7 @@ MF_MQTT_BROKER_WS_PORT=8080 MF_MQTT_ADAPTER_ES_DB=0 MF_MQTT_ADAPTER_ES_PASS= -### VERMEMQ +### VERNEMQ MF_DOCKER_VERNEMQ_ALLOW_ANONYMOUS=on MF_DOCKER_VERNEMQ_LOG__CONSOLE__LEVEL=error diff --git a/logger/level.go b/logger/level.go index a22acf0a..b1d64d66 100644 --- a/logger/level.go +++ b/logger/level.go @@ -39,8 +39,9 @@ func (lvl Level) isAllowed(logLevel Level) bool { return lvl <= logLevel } +// UnmarshalText returns log Level for the given string representation. func (lvl *Level) UnmarshalText(text string) error { - switch string(strings.ToLower(text)) { + switch strings.ToLower(text) { case "debug": *lvl = Debug case "info": diff --git a/readers/mongodb/messages.go b/readers/mongodb/messages.go index bf32e0f8..264ea249 100644 --- a/readers/mongodb/messages.go +++ b/readers/mongodb/messages.go @@ -82,9 +82,6 @@ func (repo mongoRepository) ReadAll(chanID string, offset, limit uint64, query m if err != nil { return readers.MessagesPage{}, errors.Wrap(errReadMessages, err) } - if total < 0 { - return readers.MessagesPage{}, nil - } return readers.MessagesPage{ Total: uint64(total), diff --git a/scripts/run.sh b/scripts/run.sh index b9615044..9ffc7799 100755 --- a/scripts/run.sh +++ b/scripts/run.sh @@ -21,18 +21,18 @@ function cleanup { ### # NATS ### -gnatsd & +nats-server & counter=1 -until nc -zv localhost 4222 1>/dev/null 2>&1; +until fuser 4222/tcp 1>/dev/null 2>&1; do sleep 0.5 ((counter++)) if [ ${counter} -gt 10 ] then - echo -ne "gnatsd failed to start in 5 sec, exiting" + echo "NATS failed to start in 5 sec, exiting" exit 1 fi - echo -ne "Waiting for gnatsd" + echo "Waiting for NATS server" done ### diff --git a/twins/mocks/states.go b/twins/mocks/states.go index 6e25298a..5266fb9e 100644 --- a/twins/mocks/states.go +++ b/twins/mocks/states.go @@ -6,6 +6,7 @@ package mocks import ( "context" "sort" + "strconv" "strings" "sync" @@ -31,7 +32,7 @@ func (srm *stateRepositoryMock) Save(ctx context.Context, st twins.State) error srm.mu.Lock() defer srm.mu.Unlock() - srm.states[key(st.TwinID, string(st.ID))] = st + srm.states[key(st.TwinID, strconv.FormatInt(st.ID, 10))] = st return nil } @@ -41,7 +42,7 @@ func (srm *stateRepositoryMock) Update(ctx context.Context, st twins.State) erro srm.mu.Lock() defer srm.mu.Unlock() - srm.states[key(st.TwinID, string(st.ID))] = st + srm.states[key(st.TwinID, strconv.FormatInt(st.ID, 10))] = st return nil }