From 32cb651c4a031f0e00238454b6ccdcbcaf5cbbbe Mon Sep 17 00:00:00 2001 From: louis Date: Sun, 29 Oct 2023 17:39:14 +0100 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20Refactor=20Upload=20Config?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cmd/root.go | 2 +- config.yml.dist | 9 +-- docs/configuration.md | 9 +-- docs/quick-install-all.md | 11 ++-- docs/quick-install.md | 11 ++-- internal/api/api_test.go | 6 +- internal/api/features_test.go | 2 +- internal/api/feed_test.go | 6 +- internal/api/init_test.go | 6 +- internal/api/media_test.go | 4 +- internal/api/messages_test.go | 30 ++++----- internal/api/response/message.go | 2 +- internal/api/response/message_test.go | 2 +- internal/api/response/timeline.go | 2 +- internal/api/response/timeline_test.go | 2 +- internal/api/response/upload.go | 2 +- internal/api/response/upload_test.go | 4 +- internal/api/settings_test.go | 18 +++--- internal/api/tickers_test.go | 90 +++++++++++++------------- internal/api/timeline_test.go | 10 +-- internal/api/upload.go | 6 +- internal/api/upload_test.go | 20 +++--- internal/api/user_test.go | 50 +++++++------- internal/bridge/mastodon.go | 2 +- internal/bridge/telegram.go | 2 +- internal/config/config.go | 25 ++++--- internal/config/config_test.go | 8 +-- 27 files changed, 173 insertions(+), 168 deletions(-) diff --git a/cmd/root.go b/cmd/root.go index e685e298..23f1841f 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -52,7 +52,7 @@ func initConfig() { if err != nil { log.WithError(err).Fatal("could not connect to database") } - store = storage.NewSqlStorage(db, cfg.UploadPath) + store = storage.NewSqlStorage(db, cfg.Upload.Path) if err := storage.MigrateDB(db); err != nil { log.WithError(err).Fatal("could not migrate database") } diff --git a/config.yml.dist b/config.yml.dist index 78f157ff..0612ce96 100644 --- a/config.yml.dist +++ b/config.yml.dist @@ -15,7 +15,8 @@ telegram: token: "" # listen port for prometheus metrics exporter metrics_listen: ":8181" -# path where to store the uploaded files -upload_path: "uploads" -# base url for uploaded assets -upload_url: "http://localhost:8080" +upload: + # path where to store the uploaded files + path: "uploads" + # base url for uploaded assets + url: "http://localhost:8080" diff --git a/docs/configuration.md b/docs/configuration.md index 9daf9873..2b8aa081 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -18,10 +18,11 @@ telegram: token: "" # listen port for prometheus metrics exporter metrics_listen: ":8181" -# path where to store the uploaded files -upload_path: "uploads" -# base url for uploaded assets -upload_url: "http://localhost:8080" +upload: + # path where to store the uploaded files + path: "uploads" + # base url for uploaded assets + url: "http://localhost:8080" ``` !!! note diff --git a/docs/quick-install-all.md b/docs/quick-install-all.md index 7eebcf14..2d5a2084 100644 --- a/docs/quick-install-all.md +++ b/docs/quick-install-all.md @@ -68,8 +68,6 @@ Fill your config file with the following content: listen: "localhost:8080" # log_level sets log level for logrus log_level: "error" -# initiator is the email for the first admin user (see password in logs) -initiator: "" # configuration for the database database: type: "sqlite" # postgres, mysql, sqlite @@ -78,10 +76,11 @@ database: secret: " (make it LOOOONG!)" # listen port for prometheus metrics exporter metrics_listen: ":8181" -# path where to store the uploaded files -upload_path: "uploads" -# base url for uploaded assets -upload_url: "https://api.domain.tld" +upload: + # path where to store the uploaded files + path: "uploads" + # base url for uploaded assets + url: "https://api.domain.tld" ``` 2. Create a systemd Task (see [docs/ticker-api.service](assets/ticker-api.service) for reference) diff --git a/docs/quick-install.md b/docs/quick-install.md index 175033a0..2a67a69c 100644 --- a/docs/quick-install.md +++ b/docs/quick-install.md @@ -60,8 +60,6 @@ Fill your config file with the following content: listen: "localhost:8080" # log_level sets log level for logrus log_level: "error" -# initiator is the email for the first admin user (see password in logs) -initiator: "" # configuration for the database database: type: "sqlite" # postgres, mysql, sqlite @@ -70,10 +68,11 @@ database: secret: " (make it LOOOONG!)" # listen port for prometheus metrics exporter metrics_listen: ":8181" -# path where to store the uploaded files -upload_path: "uploads" -# base url for uploaded assets -upload_url: "https://api.domain.tld" +upload: + # path where to store the uploaded files + path: "uploads" + # base url for uploaded assets + url: "https://api.domain.tld" ``` 2. Create a systemd Task (see [docs/ticker-api.service](assets/ticker-api.service) for reference) diff --git a/internal/api/api_test.go b/internal/api/api_test.go index 34b4ac68..e99b4f07 100644 --- a/internal/api/api_test.go +++ b/internal/api/api_test.go @@ -28,7 +28,7 @@ func init() { } func TestHealthz(t *testing.T) { - c := config.NewConfig() + c := config.LoadConfig("") s := &storage.MockStorage{} r := API(c, s, l) @@ -41,7 +41,7 @@ func TestHealthz(t *testing.T) { } func TestLoginNotSuccessful(t *testing.T) { - c := config.NewConfig() + c := config.LoadConfig("") s := &storage.MockStorage{} user := storage.User{} user.UpdatePassword("password") @@ -64,7 +64,7 @@ func TestLoginNotSuccessful(t *testing.T) { } func TestLoginSuccessful(t *testing.T) { - c := config.NewConfig() + c := config.LoadConfig("") s := &storage.MockStorage{} user := storage.User{} user.UpdatePassword("password") diff --git a/internal/api/features_test.go b/internal/api/features_test.go index 19676c4d..1e8d75dc 100644 --- a/internal/api/features_test.go +++ b/internal/api/features_test.go @@ -22,7 +22,7 @@ func TestGetFeatures(t *testing.T) { h := handler{ storage: s, - config: config.NewConfig(), + config: config.LoadConfig(""), } h.GetFeatures(c) diff --git a/internal/api/feed_test.go b/internal/api/feed_test.go index ccd3c966..69695a2c 100644 --- a/internal/api/feed_test.go +++ b/internal/api/feed_test.go @@ -24,7 +24,7 @@ func TestGetFeedTickerNotFound(t *testing.T) { s := &storage.MockStorage{} h := handler{ storage: s, - config: config.NewConfig(), + config: config.LoadConfig(""), } h.GetFeed(c) @@ -42,7 +42,7 @@ func TestGetFeedMessageFetchError(t *testing.T) { h := handler{ storage: s, - config: config.NewConfig(), + config: config.LoadConfig(""), } h.GetFeed(c) @@ -73,7 +73,7 @@ func TestGetFeed(t *testing.T) { h := handler{ storage: s, - config: config.NewConfig(), + config: config.LoadConfig(""), } h.GetFeed(c) diff --git a/internal/api/init_test.go b/internal/api/init_test.go index 23e56add..6a074c05 100644 --- a/internal/api/init_test.go +++ b/internal/api/init_test.go @@ -25,7 +25,7 @@ func TestGetInit(t *testing.T) { h := handler{ storage: s, - config: config.NewConfig(), + config: config.LoadConfig(""), } h.GetInit(c) @@ -43,7 +43,7 @@ func TestGetInitInvalidDomain(t *testing.T) { h := handler{ storage: s, - config: config.NewConfig(), + config: config.LoadConfig(""), } h.GetInit(c) @@ -64,7 +64,7 @@ func TestGetInitInactiveTicker(t *testing.T) { h := handler{ storage: s, - config: config.NewConfig(), + config: config.LoadConfig(""), } h.GetInit(c) diff --git a/internal/api/media_test.go b/internal/api/media_test.go index ef20f7b9..ccfff06e 100644 --- a/internal/api/media_test.go +++ b/internal/api/media_test.go @@ -29,7 +29,7 @@ func TestGetMedia(t *testing.T) { h := handler{ storage: s, - config: config.NewConfig(), + config: config.LoadConfig(""), } h.GetMedia(c) @@ -47,7 +47,7 @@ func TestGetMediaNotFound(t *testing.T) { h := handler{ storage: s, - config: config.NewConfig(), + config: config.LoadConfig(""), } h.GetMedia(c) diff --git a/internal/api/messages_test.go b/internal/api/messages_test.go index a15e760e..68956daf 100644 --- a/internal/api/messages_test.go +++ b/internal/api/messages_test.go @@ -26,7 +26,7 @@ func TestGetMessagesTickerNotFound(t *testing.T) { s := &storage.MockStorage{} h := handler{ storage: s, - config: config.NewConfig(), + config: config.LoadConfig(""), } h.GetMessages(c) @@ -42,7 +42,7 @@ func TestGetMessagesStorageError(t *testing.T) { s.On("FindMessagesByTickerAndPagination", mock.Anything, mock.Anything, mock.Anything).Return([]storage.Message{}, errors.New("storage error")) h := handler{ storage: s, - config: config.NewConfig(), + config: config.LoadConfig(""), } h.GetMessages(c) @@ -58,7 +58,7 @@ func TestGetMessagesEmptyResult(t *testing.T) { s.On("FindMessagesByTickerAndPagination", mock.Anything, mock.Anything, mock.Anything).Return([]storage.Message{}, errors.New("not found")) h := handler{ storage: s, - config: config.NewConfig(), + config: config.LoadConfig(""), } h.GetMessages(c) @@ -74,7 +74,7 @@ func TestGetMessages(t *testing.T) { s.On("FindMessagesByTickerAndPagination", mock.Anything, mock.Anything, mock.Anything).Return([]storage.Message{}, nil) h := handler{ storage: s, - config: config.NewConfig(), + config: config.LoadConfig(""), } h.GetMessages(c) @@ -88,7 +88,7 @@ func TestGetMessageNotFound(t *testing.T) { s := &storage.MockStorage{} h := handler{ storage: s, - config: config.NewConfig(), + config: config.LoadConfig(""), } h.GetMessage(c) @@ -103,7 +103,7 @@ func TestGetMessage(t *testing.T) { s := &storage.MockStorage{} h := handler{ storage: s, - config: config.NewConfig(), + config: config.LoadConfig(""), } h.GetMessage(c) @@ -117,7 +117,7 @@ func TestPostMessageTickerNotFound(t *testing.T) { s := &storage.MockStorage{} h := handler{ storage: s, - config: config.NewConfig(), + config: config.LoadConfig(""), } h.PostMessage(c) @@ -133,7 +133,7 @@ func TestPostMessageFormError(t *testing.T) { s := &storage.MockStorage{} h := handler{ storage: s, - config: config.NewConfig(), + config: config.LoadConfig(""), } h.PostMessage(c) @@ -153,7 +153,7 @@ func TestPostMessageUploadsNotFound(t *testing.T) { s.On("FindUploadsByIDs", mock.Anything).Return([]storage.Upload{}, errors.New("storage error")) h := handler{ storage: s, - config: config.NewConfig(), + config: config.LoadConfig(""), } h.PostMessage(c) @@ -176,7 +176,7 @@ func TestPostMessageStorageError(t *testing.T) { b.On("Send", mock.Anything, mock.Anything).Return(nil) h := handler{ storage: s, - config: config.NewConfig(), + config: config.LoadConfig(""), bridges: bridge.Bridges{"mock": b}, } @@ -199,7 +199,7 @@ func TestPostMessage(t *testing.T) { b.On("Send", mock.Anything, mock.Anything).Return(nil) h := handler{ storage: s, - config: config.NewConfig(), + config: config.LoadConfig(""), bridges: bridge.Bridges{"mock": b}, } @@ -214,7 +214,7 @@ func TestDeleteMessageTickerNotFound(t *testing.T) { s := &storage.MockStorage{} h := handler{ storage: s, - config: config.NewConfig(), + config: config.LoadConfig(""), } h.DeleteMessage(c) @@ -229,7 +229,7 @@ func TestDeleteMessageMessageNotFound(t *testing.T) { s := &storage.MockStorage{} h := handler{ storage: s, - config: config.NewConfig(), + config: config.LoadConfig(""), } h.DeleteMessage(c) @@ -248,7 +248,7 @@ func TestDeleteMessageStorageError(t *testing.T) { b.On("Delete", mock.Anything, mock.Anything).Return(nil) h := handler{ storage: s, - config: config.NewConfig(), + config: config.LoadConfig(""), bridges: bridge.Bridges{"mock": b}, } @@ -268,7 +268,7 @@ func TestDeleteMessage(t *testing.T) { b.On("Delete", mock.Anything, mock.Anything).Return(nil) h := handler{ storage: s, - config: config.NewConfig(), + config: config.LoadConfig(""), bridges: bridge.Bridges{"mock": b}, } diff --git a/internal/api/response/message.go b/internal/api/response/message.go index 645fdb93..17de26b8 100644 --- a/internal/api/response/message.go +++ b/internal/api/response/message.go @@ -30,7 +30,7 @@ func MessageResponse(message storage.Message, config config.Config) Message { for _, attachment := range message.Attachments { name := fmt.Sprintf("%s.%s", attachment.UUID, attachment.Extension) - attachments = append(attachments, MessageAttachment{URL: MediaURL(config.UploadURL, name), ContentType: attachment.ContentType}) + attachments = append(attachments, MessageAttachment{URL: MediaURL(config.Upload.URL, name), ContentType: attachment.ContentType}) } return Message{ diff --git a/internal/api/response/message_test.go b/internal/api/response/message_test.go index a581ffeb..080d61d5 100644 --- a/internal/api/response/message_test.go +++ b/internal/api/response/message_test.go @@ -9,7 +9,7 @@ import ( ) func TestMessagesResponse(t *testing.T) { - config := config.Config{UploadURL: "https://upload.example.com"} + config := config.Config{Upload: config.Upload{URL: "https://upload.example.com"}} message := storage.NewMessage() message.Attachments = []storage.Attachment{{UUID: "uuid", Extension: "jpg"}} diff --git a/internal/api/response/timeline.go b/internal/api/response/timeline.go index 3e1b613c..ea15fe08 100644 --- a/internal/api/response/timeline.go +++ b/internal/api/response/timeline.go @@ -31,7 +31,7 @@ func TimelineResponse(messages []storage.Message, config config.Config) []Timeli var attachments []Attachment for _, attachment := range message.Attachments { name := fmt.Sprintf("%s.%s", attachment.UUID, attachment.Extension) - attachments = append(attachments, Attachment{URL: MediaURL(config.UploadURL, name), ContentType: attachment.ContentType}) + attachments = append(attachments, Attachment{URL: MediaURL(config.Upload.URL, name), ContentType: attachment.ContentType}) } timeline = append(timeline, TimelineEntry{ diff --git a/internal/api/response/timeline_test.go b/internal/api/response/timeline_test.go index b786a27c..1f98e277 100644 --- a/internal/api/response/timeline_test.go +++ b/internal/api/response/timeline_test.go @@ -9,7 +9,7 @@ import ( ) func TestTimelineResponse(t *testing.T) { - config := config.Config{UploadURL: "https://upload.example.com"} + config := config.Config{Upload: config.Upload{URL: "https://upload.example.com"}} message := storage.NewMessage() message.Attachments = []storage.Attachment{{UUID: "uuid", Extension: "jpg"}} diff --git a/internal/api/response/upload.go b/internal/api/response/upload.go index d0ec0944..be11f859 100644 --- a/internal/api/response/upload.go +++ b/internal/api/response/upload.go @@ -20,7 +20,7 @@ func UploadResponse(upload storage.Upload, config config.Config) Upload { ID: upload.ID, UUID: upload.UUID, CreatedAt: upload.CreatedAt, - URL: upload.URL(config.UploadURL), + URL: upload.URL(config.Upload.URL), ContentType: upload.ContentType, } } diff --git a/internal/api/response/upload_test.go b/internal/api/response/upload_test.go index 8fe405c1..3ff7e7b1 100644 --- a/internal/api/response/upload_test.go +++ b/internal/api/response/upload_test.go @@ -12,14 +12,14 @@ import ( var ( u = storage.NewUpload("image.jpg", "image/jpg", 1) c = config.Config{ - UploadURL: "http://localhost:8080", + Upload: config.Upload{URL: "http://localhost:8080"}, } ) func TestUploadResponse(t *testing.T) { response := UploadResponse(u, c) - assert.Equal(t, fmt.Sprintf("%s/media/%s", c.UploadURL, u.FileName()), response.URL) + assert.Equal(t, fmt.Sprintf("%s/media/%s", c.Upload.URL, u.FileName()), response.URL) } func TestUploadsResponse(t *testing.T) { diff --git a/internal/api/settings_test.go b/internal/api/settings_test.go index 7af56b7f..5f307144 100644 --- a/internal/api/settings_test.go +++ b/internal/api/settings_test.go @@ -27,7 +27,7 @@ func TestGetSettingWithoutParam(t *testing.T) { s := &storage.MockStorage{} h := handler{ storage: s, - config: config.NewConfig(), + config: config.LoadConfig(""), } h.GetSetting(c) @@ -44,7 +44,7 @@ func TestGetSettingInactiveSetting(t *testing.T) { s.On("GetInactiveSettings").Return(storage.InactiveSettings{}) h := handler{ storage: s, - config: config.NewConfig(), + config: config.LoadConfig(""), } h.GetSetting(c) @@ -61,7 +61,7 @@ func TestGetSettingRefreshIntervalSetting(t *testing.T) { s.On("GetRefreshIntervalSettings").Return(storage.RefreshIntervalSettings{}) h := handler{ storage: s, - config: config.NewConfig(), + config: config.LoadConfig(""), } h.GetSetting(c) @@ -79,7 +79,7 @@ func TestPutInactiveSettingsMissingBody(t *testing.T) { s := &storage.MockStorage{} h := handler{ storage: s, - config: config.NewConfig(), + config: config.LoadConfig(""), } h.PutInactiveSettings(c) @@ -100,7 +100,7 @@ func TestPutInactiveSettingsStorageError(t *testing.T) { s.On("SaveInactiveSettings", mock.Anything).Return(errors.New("storage error")) h := handler{ storage: s, - config: config.NewConfig(), + config: config.LoadConfig(""), } h.PutInactiveSettings(c) @@ -122,7 +122,7 @@ func TestPutInactiveSettings(t *testing.T) { s.On("GetInactiveSettings").Return(setting) h := handler{ storage: s, - config: config.NewConfig(), + config: config.LoadConfig(""), } h.PutInactiveSettings(c) @@ -140,7 +140,7 @@ func TestPutRefreshIntervalSettingsMissingBody(t *testing.T) { s := &storage.MockStorage{} h := handler{ storage: s, - config: config.NewConfig(), + config: config.LoadConfig(""), } h.PutRefreshInterval(c) @@ -160,7 +160,7 @@ func TestPutRefreshIntervalSettingsStorageError(t *testing.T) { s.On("SaveRefreshIntervalSettings", mock.Anything).Return(errors.New("storage error")) h := handler{ storage: s, - config: config.NewConfig(), + config: config.LoadConfig(""), } h.PutRefreshInterval(c) @@ -182,7 +182,7 @@ func TestPutRefreshIntervalSettings(t *testing.T) { s.On("GetRefreshIntervalSettings").Return(setting) h := handler{ storage: s, - config: config.NewConfig(), + config: config.LoadConfig(""), } h.PutRefreshInterval(c) diff --git a/internal/api/tickers_test.go b/internal/api/tickers_test.go index b12a34e5..3c9dea46 100644 --- a/internal/api/tickers_test.go +++ b/internal/api/tickers_test.go @@ -27,7 +27,7 @@ func TestGetTickersForbidden(t *testing.T) { s := &storage.MockStorage{} h := handler{ storage: s, - config: config.NewConfig(), + config: config.LoadConfig(""), } h.GetTickers(c) @@ -43,7 +43,7 @@ func TestGetTickersStorageError(t *testing.T) { s.On("FindTickersByUser", mock.Anything, mock.Anything).Return([]storage.Ticker{}, errors.New("storage error")) h := handler{ storage: s, - config: config.NewConfig(), + config: config.LoadConfig(""), } h.GetTickers(c) @@ -59,7 +59,7 @@ func TestGetTickers(t *testing.T) { s.On("FindTickersByUser", mock.Anything, mock.Anything).Return([]storage.Ticker{}, nil) h := handler{ storage: s, - config: config.NewConfig(), + config: config.LoadConfig(""), } h.GetTickers(c) @@ -73,7 +73,7 @@ func TestGetTickerNotFound(t *testing.T) { s := &storage.MockStorage{} h := handler{ storage: s, - config: config.NewConfig(), + config: config.LoadConfig(""), } h.GetTicker(c) @@ -88,7 +88,7 @@ func TestGetTicker(t *testing.T) { s := &storage.MockStorage{} h := handler{ storage: s, - config: config.NewConfig(), + config: config.LoadConfig(""), } h.GetTicker(c) @@ -102,7 +102,7 @@ func TestGetTickerUsersTickerNotFound(t *testing.T) { s := &storage.MockStorage{} h := handler{ storage: s, - config: config.NewConfig(), + config: config.LoadConfig(""), } h.GetTickerUsers(c) @@ -118,7 +118,7 @@ func TestGetTickerUsers(t *testing.T) { s.On("FindUsersByTicker", mock.Anything, mock.Anything).Return([]storage.User{}, nil) h := handler{ storage: s, - config: config.NewConfig(), + config: config.LoadConfig(""), } h.GetTickerUsers(c) @@ -134,7 +134,7 @@ func TestPostTickerFormError(t *testing.T) { s := &storage.MockStorage{} h := handler{ storage: s, - config: config.NewConfig(), + config: config.LoadConfig(""), } h.PostTicker(c) @@ -153,7 +153,7 @@ func TestPostTickerStorageError(t *testing.T) { s.On("SaveTicker", mock.Anything).Return(errors.New("storage error")) h := handler{ storage: s, - config: config.NewConfig(), + config: config.LoadConfig(""), } h.PostTicker(c) @@ -172,7 +172,7 @@ func TestPostTicker(t *testing.T) { s.On("SaveTicker", mock.Anything).Return(nil) h := handler{ storage: s, - config: config.NewConfig(), + config: config.LoadConfig(""), } h.PostTicker(c) @@ -186,7 +186,7 @@ func TestPutTickerNotFound(t *testing.T) { s := &storage.MockStorage{} h := handler{ storage: s, - config: config.NewConfig(), + config: config.LoadConfig(""), } h.PutTicker(c) @@ -203,7 +203,7 @@ func TestPutTickerFormError(t *testing.T) { s := &storage.MockStorage{} h := handler{ storage: s, - config: config.NewConfig(), + config: config.LoadConfig(""), } h.PutTicker(c) @@ -222,7 +222,7 @@ func TestPutTickerStorageError(t *testing.T) { s.On("SaveTicker", mock.Anything).Return(errors.New("storage error")) h := handler{ storage: s, - config: config.NewConfig(), + config: config.LoadConfig(""), } h.PutTicker(c) @@ -241,7 +241,7 @@ func TestPutTicker(t *testing.T) { s.On("SaveTicker", mock.Anything).Return(nil) h := handler{ storage: s, - config: config.NewConfig(), + config: config.LoadConfig(""), } h.PutTicker(c) @@ -255,7 +255,7 @@ func TestPutTickerUsersNotFound(t *testing.T) { s := &storage.MockStorage{} h := handler{ storage: s, - config: config.NewConfig(), + config: config.LoadConfig(""), } h.PutTickerUsers(c) @@ -272,7 +272,7 @@ func TestPutTickerUsersFormError(t *testing.T) { s := &storage.MockStorage{} h := handler{ storage: s, - config: config.NewConfig(), + config: config.LoadConfig(""), } h.PutTickerUsers(c) @@ -292,7 +292,7 @@ func TestPutTickerUsersStorageError(t *testing.T) { s.On("SaveTicker", mock.Anything).Return(errors.New("storage error")) h := handler{ storage: s, - config: config.NewConfig(), + config: config.LoadConfig(""), } h.PutTickerUsers(c) @@ -313,7 +313,7 @@ func TestPutTickerUsers(t *testing.T) { s.On("SaveTicker", mock.Anything).Return(nil) h := handler{ storage: s, - config: config.NewConfig(), + config: config.LoadConfig(""), } h.PutTickerUsers(c) @@ -327,7 +327,7 @@ func TestPutTickerTelegramTickerNotFound(t *testing.T) { s := &storage.MockStorage{} h := handler{ storage: s, - config: config.NewConfig(), + config: config.LoadConfig(""), } h.PutTickerTelegram(c) @@ -344,7 +344,7 @@ func TestPutTickerTelegramFormError(t *testing.T) { s := &storage.MockStorage{} h := handler{ storage: s, - config: config.NewConfig(), + config: config.LoadConfig(""), } h.PutTickerTelegram(c) @@ -363,7 +363,7 @@ func TestPutTickerTelegramStorageError(t *testing.T) { s.On("SaveTicker", mock.Anything).Return(errors.New("storage error")) h := handler{ storage: s, - config: config.NewConfig(), + config: config.LoadConfig(""), } h.PutTickerTelegram(c) @@ -382,7 +382,7 @@ func TestPutTickerTelegram(t *testing.T) { s.On("SaveTicker", mock.Anything).Return(nil) h := handler{ storage: s, - config: config.NewConfig(), + config: config.LoadConfig(""), } h.PutTickerTelegram(c) @@ -396,7 +396,7 @@ func TestDeleteTickerTelegramTickerNotFound(t *testing.T) { s := &storage.MockStorage{} h := handler{ storage: s, - config: config.NewConfig(), + config: config.LoadConfig(""), } h.DeleteTickerTelegram(c) @@ -412,7 +412,7 @@ func TestDeleteTickerTelegramStorageError(t *testing.T) { s.On("SaveTicker", mock.Anything).Return(errors.New("storage error")) h := handler{ storage: s, - config: config.NewConfig(), + config: config.LoadConfig(""), } h.DeleteTickerTelegram(c) @@ -428,7 +428,7 @@ func TestDeleteTickerTelegram(t *testing.T) { s.On("SaveTicker", mock.Anything).Return(nil) h := handler{ storage: s, - config: config.NewConfig(), + config: config.LoadConfig(""), } h.DeleteTickerTelegram(c) @@ -442,7 +442,7 @@ func TestPutTickerMastodonTickerNotFound(t *testing.T) { s := &storage.MockStorage{} h := handler{ storage: s, - config: config.NewConfig(), + config: config.LoadConfig(""), } h.PutTickerMastodon(c) @@ -459,7 +459,7 @@ func TestPutTickerMastodonFormError(t *testing.T) { s := &storage.MockStorage{} h := handler{ storage: s, - config: config.NewConfig(), + config: config.LoadConfig(""), } h.PutTickerMastodon(c) @@ -478,7 +478,7 @@ func TestPutTickerMastodonConnectError(t *testing.T) { s.On("SaveTicker", mock.Anything).Return(nil) h := handler{ storage: s, - config: config.NewConfig(), + config: config.LoadConfig(""), } h.PutTickerMastodon(c) @@ -503,7 +503,7 @@ func TestPutTickerMastodonStorageError(t *testing.T) { s.On("SaveTicker", mock.Anything).Return(errors.New("storage error")) h := handler{ storage: s, - config: config.NewConfig(), + config: config.LoadConfig(""), } h.PutTickerMastodon(c) @@ -528,7 +528,7 @@ func TestPutTickerMastodon(t *testing.T) { s.On("SaveTicker", mock.Anything).Return(nil) h := handler{ storage: s, - config: config.NewConfig(), + config: config.LoadConfig(""), } h.PutTickerMastodon(c) @@ -542,7 +542,7 @@ func TestDeleteTickerMastodonTickerNotFound(t *testing.T) { s := &storage.MockStorage{} h := handler{ storage: s, - config: config.NewConfig(), + config: config.LoadConfig(""), } h.DeleteTickerMastodon(c) @@ -558,7 +558,7 @@ func TestDeleteTickerMastodonStorageError(t *testing.T) { s.On("SaveTicker", mock.Anything).Return(errors.New("storage error")) h := handler{ storage: s, - config: config.NewConfig(), + config: config.LoadConfig(""), } h.DeleteTickerMastodon(c) @@ -574,7 +574,7 @@ func TestDeleteTickerMastodon(t *testing.T) { s.On("SaveTicker", mock.Anything).Return(nil) h := handler{ storage: s, - config: config.NewConfig(), + config: config.LoadConfig(""), } h.DeleteTickerMastodon(c) @@ -588,7 +588,7 @@ func TestDeleteTickerTickerNotFound(t *testing.T) { s := &storage.MockStorage{} h := handler{ storage: s, - config: config.NewConfig(), + config: config.LoadConfig(""), } h.DeleteTicker(c) @@ -606,7 +606,7 @@ func TestDeleteTickerStorageError(t *testing.T) { s.On("DeleteTicker", mock.Anything).Return(errors.New("storage error")) h := handler{ storage: s, - config: config.NewConfig(), + config: config.LoadConfig(""), } h.DeleteTicker(c) @@ -624,7 +624,7 @@ func TestDeleteTicker(t *testing.T) { s.On("DeleteTicker", mock.Anything).Return(nil) h := handler{ storage: s, - config: config.NewConfig(), + config: config.LoadConfig(""), } h.DeleteTicker(c) @@ -638,7 +638,7 @@ func TestDeleteTickerUserTickerNotFound(t *testing.T) { s := &storage.MockStorage{} h := handler{ storage: s, - config: config.NewConfig(), + config: config.LoadConfig(""), } h.DeleteTickerUser(c) @@ -653,7 +653,7 @@ func TestDeleteTickerUserMissingUserParam(t *testing.T) { s := &storage.MockStorage{} h := handler{ storage: s, - config: config.NewConfig(), + config: config.LoadConfig(""), } h.DeleteTickerUser(c) @@ -670,7 +670,7 @@ func TestDeleteTickerUserUserNotFound(t *testing.T) { s.On("FindUserByID", mock.Anything).Return(storage.User{}, errors.New("not found")) h := handler{ storage: s, - config: config.NewConfig(), + config: config.LoadConfig(""), } h.DeleteTickerUser(c) @@ -688,7 +688,7 @@ func TestDeleteTickerUserStorageError(t *testing.T) { s.On("DeleteTickerUser", mock.Anything, mock.Anything).Return(errors.New("storage error")) h := handler{ storage: s, - config: config.NewConfig(), + config: config.LoadConfig(""), } h.DeleteTickerUser(c) @@ -707,7 +707,7 @@ func TestDeleteTickerUser(t *testing.T) { s.On("FindUsersByTicker", mock.Anything).Return([]storage.User{}, nil) h := handler{ storage: s, - config: config.NewConfig(), + config: config.LoadConfig(""), } h.DeleteTickerUser(c) @@ -721,7 +721,7 @@ func TestResetTickerUserTickerNotFound(t *testing.T) { s := &storage.MockStorage{} h := handler{ storage: s, - config: config.NewConfig(), + config: config.LoadConfig(""), } h.ResetTicker(c) @@ -739,7 +739,7 @@ func TestResetTickerStorageError(t *testing.T) { s.On("SaveTicker", mock.Anything).Return(errors.New("storage error")) h := handler{ storage: s, - config: config.NewConfig(), + config: config.LoadConfig(""), } h.ResetTicker(c) @@ -758,7 +758,7 @@ func TestResetTickerStorageError2(t *testing.T) { s.On("DeleteTickerUsers", mock.Anything).Return(errors.New("storage error")) h := handler{ storage: s, - config: config.NewConfig(), + config: config.LoadConfig(""), } h.ResetTicker(c) @@ -777,7 +777,7 @@ func TestResetTicker(t *testing.T) { s.On("DeleteTickerUsers", mock.Anything).Return(nil) h := handler{ storage: s, - config: config.NewConfig(), + config: config.LoadConfig(""), } h.ResetTicker(c) diff --git a/internal/api/timeline_test.go b/internal/api/timeline_test.go index 7ef071be..d70b0b42 100644 --- a/internal/api/timeline_test.go +++ b/internal/api/timeline_test.go @@ -25,7 +25,7 @@ func TestGetTimelineMissingDomain(t *testing.T) { s := &storage.MockStorage{} h := handler{ storage: s, - config: config.NewConfig(), + config: config.LoadConfig(""), } h.GetTimeline(c) @@ -44,7 +44,7 @@ func TestGetTimelineTickerNotFound(t *testing.T) { s.On("FindTickerByDomain", mock.Anything).Return(storage.Ticker{}, errors.New("not found")) h := handler{ storage: s, - config: config.NewConfig(), + config: config.LoadConfig(""), } h.GetTimeline(c) @@ -61,7 +61,7 @@ func TestGetTimelineTickerInactive(t *testing.T) { h := handler{ storage: s, - config: config.NewConfig(), + config: config.LoadConfig(""), } h.GetTimeline(c) @@ -78,7 +78,7 @@ func TestGetTimelineMessageFetchError(t *testing.T) { h := handler{ storage: s, - config: config.NewConfig(), + config: config.LoadConfig(""), } h.GetTimeline(c) @@ -96,7 +96,7 @@ func TestGetTimeline(t *testing.T) { h := handler{ storage: s, - config: config.NewConfig(), + config: config.LoadConfig(""), } h.GetTimeline(c) diff --git a/internal/api/upload.go b/internal/api/upload.go index 5c64b519..0121e86a 100644 --- a/internal/api/upload.go +++ b/internal/api/upload.go @@ -85,7 +85,7 @@ func (h *handler) PostUpload(c *gin.Context) { } if u.ContentType == "image/gif" { - err = c.SaveUploadedFile(fileHeader, u.FullPath(h.config.UploadPath)) + err = c.SaveUploadedFile(fileHeader, u.FullPath(h.config.Upload.Path)) if err != nil { c.JSON(http.StatusInternalServerError, response.ErrorResponse(response.CodeDefault, response.FormError)) return @@ -98,7 +98,7 @@ func (h *handler) PostUpload(c *gin.Context) { return } - err = util.SaveImage(image, u.FullPath(h.config.UploadPath)) + err = util.SaveImage(image, u.FullPath(h.config.Upload.Path)) if err != nil { c.JSON(http.StatusInternalServerError, response.ErrorResponse(response.CodeDefault, response.FormError)) return @@ -112,7 +112,7 @@ func (h *handler) PostUpload(c *gin.Context) { } func preparePath(upload storage.Upload, config config.Config) error { - path := upload.FullPath(config.UploadPath) + path := upload.FullPath(config.Upload.Path) fs := config.FileBackend return fs.MkdirAll(filepath.Dir(path), 0750) } diff --git a/internal/api/upload_test.go b/internal/api/upload_test.go index 5362ed67..39a76159 100644 --- a/internal/api/upload_test.go +++ b/internal/api/upload_test.go @@ -27,7 +27,7 @@ func TestPostUploadForbidden(t *testing.T) { s := &storage.MockStorage{} h := handler{ storage: s, - config: config.NewConfig(), + config: config.LoadConfig(""), } h.PostUpload(c) @@ -43,7 +43,7 @@ func TestPostUploadMultipartError(t *testing.T) { s := &storage.MockStorage{} h := handler{ storage: s, - config: config.NewConfig(), + config: config.LoadConfig(""), } h.PostUpload(c) @@ -64,7 +64,7 @@ func TestPostUploadMissingTickerValue(t *testing.T) { s := &storage.MockStorage{} h := handler{ storage: s, - config: config.NewConfig(), + config: config.LoadConfig(""), } h.PostUpload(c) @@ -85,7 +85,7 @@ func TestPostUploadTickerValueWrong(t *testing.T) { s := &storage.MockStorage{} h := handler{ storage: s, - config: config.NewConfig(), + config: config.LoadConfig(""), } h.PostUpload(c) @@ -107,7 +107,7 @@ func TestPostUploadTickerNotFound(t *testing.T) { s.On("FindTickerByUserAndID", mock.Anything, mock.Anything).Return(storage.Ticker{}, errors.New("not found")) h := handler{ storage: s, - config: config.NewConfig(), + config: config.LoadConfig(""), } h.PostUpload(c) @@ -129,7 +129,7 @@ func TestPostUploadMissingFiles(t *testing.T) { s.On("FindTickerByUserAndID", mock.Anything, mock.Anything).Return(storage.Ticker{}, nil) h := handler{ storage: s, - config: config.NewConfig(), + config: config.LoadConfig(""), } h.PostUpload(c) @@ -162,7 +162,7 @@ func TestPostUpload(t *testing.T) { s.On("SaveUpload", mock.Anything).Return(nil) h := handler{ storage: s, - config: config.NewConfig(), + config: config.LoadConfig(""), } h.PostUpload(c) @@ -195,7 +195,7 @@ func TestPostUploadGIF(t *testing.T) { s.On("SaveUpload", mock.Anything).Return(nil) h := handler{ storage: s, - config: config.NewConfig(), + config: config.LoadConfig(""), } h.PostUpload(c) @@ -229,7 +229,7 @@ func TestPostUploadTooMuchFiles(t *testing.T) { s.On("SaveUpload", mock.Anything).Return(nil) h := handler{ storage: s, - config: config.NewConfig(), + config: config.LoadConfig(""), } h.PostUpload(c) @@ -262,7 +262,7 @@ func TestPostUploadForbiddenFileType(t *testing.T) { s.On("SaveUpload", mock.Anything).Return(nil) h := handler{ storage: s, - config: config.NewConfig(), + config: config.LoadConfig(""), } h.PostUpload(c) diff --git a/internal/api/user_test.go b/internal/api/user_test.go index ece7eadf..2d16fbcc 100644 --- a/internal/api/user_test.go +++ b/internal/api/user_test.go @@ -26,7 +26,7 @@ func TestGetUsersStorageError(t *testing.T) { s.On("FindUsers", mock.Anything).Return([]storage.User{}, errors.New("storage error")) h := handler{ storage: s, - config: config.NewConfig(), + config: config.LoadConfig(""), } h.GetUsers(c) @@ -43,7 +43,7 @@ func TestGetUsers(t *testing.T) { h := handler{ storage: s, - config: config.NewConfig(), + config: config.LoadConfig(""), } h.GetUsers(c) @@ -57,7 +57,7 @@ func TestGetUserMissingParam(t *testing.T) { s := &storage.MockStorage{} h := handler{ storage: s, - config: config.NewConfig(), + config: config.LoadConfig(""), } h.GetUser(c) @@ -74,7 +74,7 @@ func TestGetUserInsufficentPermission(t *testing.T) { s := &storage.MockStorage{} h := handler{ storage: s, - config: config.NewConfig(), + config: config.LoadConfig(""), } h.GetUser(c) @@ -92,7 +92,7 @@ func TestGetUserStorageError(t *testing.T) { s.On("FindUserByID", mock.Anything, mock.Anything).Return(storage.User{}, errors.New("storage error")) h := handler{ storage: s, - config: config.NewConfig(), + config: config.LoadConfig(""), } h.GetUser(c) @@ -109,7 +109,7 @@ func TestGetUserMissingPermission(t *testing.T) { s := &storage.MockStorage{} h := handler{ storage: s, - config: config.NewConfig(), + config: config.LoadConfig(""), } h.GetUser(c) @@ -126,7 +126,7 @@ func TestGetUser(t *testing.T) { s := &storage.MockStorage{} h := handler{ storage: s, - config: config.NewConfig(), + config: config.LoadConfig(""), } h.GetUser(c) @@ -142,7 +142,7 @@ func TestPostUserMissingBody(t *testing.T) { s := &storage.MockStorage{} h := handler{ storage: s, - config: config.NewConfig(), + config: config.LoadConfig(""), } h.PostUser(c) @@ -160,7 +160,7 @@ func TestPostUserTooLongPassword(t *testing.T) { s := &storage.MockStorage{} h := handler{ storage: s, - config: config.NewConfig(), + config: config.LoadConfig(""), } h.PostUser(c) @@ -179,7 +179,7 @@ func TestPostUserStorageError(t *testing.T) { s.On("SaveUser", mock.Anything).Return(errors.New("storage error")) h := handler{ storage: s, - config: config.NewConfig(), + config: config.LoadConfig(""), } h.PostUser(c) @@ -198,7 +198,7 @@ func TestPostUser(t *testing.T) { s.On("SaveUser", mock.Anything).Return(nil) h := handler{ storage: s, - config: config.NewConfig(), + config: config.LoadConfig(""), } h.PostUser(c) @@ -213,7 +213,7 @@ func TestPutUserNotFound(t *testing.T) { s := &storage.MockStorage{} h := handler{ storage: s, - config: config.NewConfig(), + config: config.LoadConfig(""), } h.PutUser(c) @@ -232,7 +232,7 @@ func TestPutUserMissingBody(t *testing.T) { s := &storage.MockStorage{} h := handler{ storage: s, - config: config.NewConfig(), + config: config.LoadConfig(""), } h.PutUser(c) @@ -253,7 +253,7 @@ func TestPutUserStorageError(t *testing.T) { s.On("SaveUser", mock.Anything).Return(errors.New("storage error")) h := handler{ storage: s, - config: config.NewConfig(), + config: config.LoadConfig(""), } h.PutUser(c) @@ -274,7 +274,7 @@ func TestPutUserStorageError2(t *testing.T) { s.On("SaveUser", mock.Anything).Return(errors.New("storage error")) h := handler{ storage: s, - config: config.NewConfig(), + config: config.LoadConfig(""), } h.PutUser(c) @@ -295,7 +295,7 @@ func TestPutUser(t *testing.T) { s.On("SaveUser", mock.Anything).Return(nil) h := handler{ storage: s, - config: config.NewConfig(), + config: config.LoadConfig(""), } h.PutUser(c) @@ -310,7 +310,7 @@ func TestDeleteUserMissingParam(t *testing.T) { s := &storage.MockStorage{} h := handler{ storage: s, - config: config.NewConfig(), + config: config.LoadConfig(""), } h.DeleteUser(c) @@ -326,7 +326,7 @@ func TestDeleteUserSelfUser(t *testing.T) { s := &storage.MockStorage{} h := handler{ storage: s, - config: config.NewConfig(), + config: config.LoadConfig(""), } h.DeleteUser(c) @@ -343,7 +343,7 @@ func TestDeleteUserStorageError(t *testing.T) { s.On("DeleteUser", mock.Anything).Return(errors.New("storage error")) h := handler{ storage: s, - config: config.NewConfig(), + config: config.LoadConfig(""), } h.DeleteUser(c) @@ -360,7 +360,7 @@ func TestDeleteUser(t *testing.T) { s.On("DeleteUser", mock.Anything).Return(nil) h := handler{ storage: s, - config: config.NewConfig(), + config: config.LoadConfig(""), } h.DeleteUser(c) @@ -378,7 +378,7 @@ func TestPutMeUnauthenticated(t *testing.T) { s.On("SaveUser", mock.Anything).Return(nil) h := handler{ storage: s, - config: config.NewConfig(), + config: config.LoadConfig(""), } h.PutMe(c) assert.Equal(t, http.StatusForbidden, w.Code) @@ -395,7 +395,7 @@ func TestPutMeFormError(t *testing.T) { s.On("SaveUser", mock.Anything).Return(nil) h := handler{ storage: s, - config: config.NewConfig(), + config: config.LoadConfig(""), } h.PutMe(c) assert.Equal(t, http.StatusBadRequest, w.Code) @@ -412,7 +412,7 @@ func TestPutMeWrongPassword(t *testing.T) { s.On("SaveUser", mock.Anything).Return(nil) h := handler{ storage: s, - config: config.NewConfig(), + config: config.LoadConfig(""), } h.PutMe(c) assert.Equal(t, http.StatusBadRequest, w.Code) @@ -429,7 +429,7 @@ func TestPutMeStorageError(t *testing.T) { s.On("SaveUser", mock.Anything).Return(errors.New("storage error")) h := handler{ storage: s, - config: config.NewConfig(), + config: config.LoadConfig(""), } h.PutMe(c) assert.Equal(t, http.StatusBadRequest, w.Code) @@ -446,7 +446,7 @@ func TestPutMeOk(t *testing.T) { s.On("SaveUser", mock.Anything).Return(nil) h := handler{ storage: s, - config: config.NewConfig(), + config: config.LoadConfig(""), } h.PutMe(c) assert.Equal(t, http.StatusOK, w.Code) diff --git a/internal/bridge/mastodon.go b/internal/bridge/mastodon.go index e8f37dd6..507f82c7 100644 --- a/internal/bridge/mastodon.go +++ b/internal/bridge/mastodon.go @@ -31,7 +31,7 @@ func (mb *MastodonBridge) Send(ticker storage.Ticker, message *storage.Message) continue } - media, err := client.UploadMedia(ctx, upload.FullPath(mb.config.UploadPath)) + media, err := client.UploadMedia(ctx, upload.FullPath(mb.config.Upload.Path)) if err != nil { log.WithError(err).Error("unable to upload the attachment") continue diff --git a/internal/bridge/telegram.go b/internal/bridge/telegram.go index 712bbc08..a7e64c76 100644 --- a/internal/bridge/telegram.go +++ b/internal/bridge/telegram.go @@ -37,7 +37,7 @@ func (tb *TelegramBridge) Send(ticker storage.Ticker, message *storage.Message) continue } - media := tgbotapi.FilePath(upload.FullPath(tb.config.UploadPath)) + media := tgbotapi.FilePath(upload.FullPath(tb.config.Upload.Path)) if upload.ContentType == "image/gif" { photo := tgbotapi.NewInputMediaDocument(media) if i == 0 { diff --git a/internal/config/config.go b/internal/config/config.go index 1ee97037..8114cace 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -21,8 +21,7 @@ type Config struct { Database Database `yaml:"database"` Telegram Telegram `yaml:"telegram"` MetricsListen string `yaml:"metrics_listen"` - UploadPath string `yaml:"upload_path"` - UploadURL string `yaml:"upload_url"` + Upload Upload `yaml:"upload"` FileBackend afero.Fs } @@ -36,8 +35,12 @@ type Telegram struct { User tgbotapi.User } -// NewConfig returns config with default values. -func NewConfig() Config { +type Upload struct { + Path string `yaml:"path"` + URL string `yaml:"url"` +} + +func defaultConfig() Config { secret, _ := password.Generate(64, 12, 12, false, true) return Config{ @@ -47,9 +50,11 @@ func NewConfig() Config { Secret: secret, Database: Database{Type: "sqlite", DSN: "ticker.db"}, MetricsListen: ":8181", - UploadPath: "uploads", - UploadURL: "http://localhost:8080", - FileBackend: afero.NewOsFs(), + Upload: Upload{ + Path: "uploads", + URL: "http://localhost:8080", + }, + FileBackend: afero.NewOsFs(), } } @@ -60,7 +65,7 @@ func (t *Telegram) Enabled() bool { // LoadConfig loads config from file. func LoadConfig(path string) Config { - c := NewConfig() + c := defaultConfig() c.FileBackend = afero.NewOsFs() if path != "" { @@ -95,10 +100,10 @@ func LoadConfig(path string) Config { c.MetricsListen = os.Getenv("TICKER_METRICS_LISTEN") } if os.Getenv("TICKER_UPLOAD_PATH") != "" { - c.UploadPath = os.Getenv("TICKER_UPLOAD_PATH") + c.Upload.Path = os.Getenv("TICKER_UPLOAD_PATH") } if os.Getenv("TICKER_UPLOAD_URL") != "" { - c.UploadURL = os.Getenv("TICKER_UPLOAD_URL") + c.Upload.URL = os.Getenv("TICKER_UPLOAD_URL") } if os.Getenv("TICKER_TELEGRAM_TOKEN") != "" { c.Telegram.Token = os.Getenv("TICKER_TELEGRAM_TOKEN") diff --git a/internal/config/config_test.go b/internal/config/config_test.go index 37ec0892..3341e41a 100644 --- a/internal/config/config_test.go +++ b/internal/config/config_test.go @@ -47,8 +47,8 @@ var _ = Describe("Config", func() { Expect(c.Database.Type).To(Equal("sqlite")) Expect(c.Database.DSN).To(Equal("ticker.db")) Expect(c.MetricsListen).To(Equal(":8181")) - Expect(c.UploadPath).To(Equal("uploads")) - Expect(c.UploadURL).To(Equal("http://localhost:8080")) + Expect(c.Upload.Path).To(Equal("uploads")) + Expect(c.Upload.URL).To(Equal("http://localhost:8080")) Expect(c.Telegram.Token).To(BeEmpty()) Expect(c.Telegram.Enabled()).To(BeFalse()) }) @@ -67,8 +67,8 @@ var _ = Describe("Config", func() { Expect(c.Database.Type).To(Equal(envs["TICKER_DATABASE_TYPE"])) Expect(c.Database.DSN).To(Equal(envs["TICKER_DATABASE_DSN"])) Expect(c.MetricsListen).To(Equal(envs["TICKER_METRICS_LISTEN"])) - Expect(c.UploadPath).To(Equal(envs["TICKER_UPLOAD_PATH"])) - Expect(c.UploadURL).To(Equal(envs["TICKER_UPLOAD_URL"])) + Expect(c.Upload.Path).To(Equal(envs["TICKER_UPLOAD_PATH"])) + Expect(c.Upload.URL).To(Equal(envs["TICKER_UPLOAD_URL"])) Expect(c.Telegram.Token).To(Equal(envs["TICKER_TELEGRAM_TOKEN"])) Expect(c.Telegram.Enabled()).To(BeTrue()) })