From 0efc04e5cd1ce7952d80a66c9d21ad28e387d090 Mon Sep 17 00:00:00 2001 From: Dmitry Verkhoturov Date: Tue, 27 Jul 2021 11:32:25 +0200 Subject: [PATCH] fix deprecated flag, improve tests --- backend/app/cmd/server.go | 2 +- backend/app/cmd/server_test.go | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/backend/app/cmd/server.go b/backend/app/cmd/server.go index 22414ae1..5dc95c27 100644 --- a/backend/app/cmd/server.go +++ b/backend/app/cmd/server.go @@ -359,7 +359,7 @@ func (s *ServerCommand) HandleDeprecatedFlags() (result []DeprecatedFlag) { } const telegramDefaultDuration = time.Second * 5 if s.Notify.Telegram.Timeout != telegramDefaultDuration && s.Telegram.Timeout == telegramDefaultDuration { - s.Telegram.Token = s.Notify.Telegram.Token + s.Telegram.Timeout = s.Notify.Telegram.Timeout result = append(result, DeprecatedFlag{Old: "notify.telegram.timeout", New: "telegram.timeout", Version: "1.9"}) } if s.Notify.Telegram.API != "https://api.telegram.org/bot" { diff --git a/backend/app/cmd/server_test.go b/backend/app/cmd/server_test.go index 0edee841..34644d1d 100644 --- a/backend/app/cmd/server_test.go +++ b/backend/app/cmd/server_test.go @@ -417,6 +417,8 @@ func TestServerApp_DeprecatedArgs(t *testing.T) { "--auth.email.passwd=test_password", "--auth.email.timeout=15s", "--auth.email.template=file.tmpl", + "--notify.telegram.token=abcd", + "--notify.telegram.timeout=3m", } assert.Empty(t, s.SMTP.Host) assert.Empty(t, s.SMTP.Port) @@ -437,6 +439,8 @@ func TestServerApp_DeprecatedArgs(t *testing.T) { {Old: "auth.email.timeout", New: "smtp.timeout", Version: "1.5"}, {Old: "auth.email.template", Version: "1.5"}, {Old: "notify.type", New: "notify.(users|admins)", Version: "1.9"}, + {Old: "notify.telegram.token", New: "telegram.token", Version: "1.9"}, + {Old: "notify.telegram.timeout", New: "telegram.timeout", Version: "1.9"}, }, deprecatedFlags) assert.Equal(t, "smtp.example.org", s.SMTP.Host)