From 47cf94ad01b4db8749c55c1a1dca50c9b94daf02 Mon Sep 17 00:00:00 2001 From: bodqhrohro Date: Tue, 12 Nov 2019 20:02:06 +0200 Subject: [PATCH] Tests for log constants --- Makefile | 2 +- log_test.go | 21 +++++++++++++++++++++ telegram/client_test.go | 19 +++++++++++++++++++ 3 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 log_test.go create mode 100644 telegram/client_test.go diff --git a/Makefile b/Makefile index 047de52..9a4145d 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ all: go build -o telegabber test: - go test -v ./config + go test -v ./config ./ ./telegram lint: $(GOPATH)/bin/golint ./... diff --git a/log_test.go b/log_test.go new file mode 100644 index 0000000..906c6dc --- /dev/null +++ b/log_test.go @@ -0,0 +1,21 @@ +package main + +import ( + "testing" + + log "github.com/sirupsen/logrus" +) + +func TestLogInfo(t *testing.T) { + logrusConstant := stringToLogConstant(":info") + if logrusConstant != log.InfoLevel { + t.Errorf("Wrong logrus constant for info") + } +} + +func TestLogInvalid(t *testing.T) { + logrusConstant := stringToLogConstant("ziz") + if logrusConstant != log.FatalLevel { + t.Errorf("Unknown strings should return fatal loglevel") + } +} diff --git a/telegram/client_test.go b/telegram/client_test.go new file mode 100644 index 0000000..4c757e1 --- /dev/null +++ b/telegram/client_test.go @@ -0,0 +1,19 @@ +package telegram + +import ( + "testing" +) + +func TestLogInfo(t *testing.T) { + tdlibConstant := stringToLogConstant(":info") + if tdlibConstant != 3 { + t.Errorf("Wrong TDlib constant for info") + } +} + +func TestLogInvalid(t *testing.T) { + tdlibConstant := stringToLogConstant("ziz") + if tdlibConstant != 0 { + t.Errorf("Unknown strings should return fatal loglevel") + } +}