From 72c9dac62cb6282841d22d877852bcee26bff9dd Mon Sep 17 00:00:00 2001 From: bodqhrohro Date: Tue, 22 Oct 2019 22:55:43 +0300 Subject: Add tests for config package (failing for now) --- config/config.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'config/config.go') diff --git a/config/config.go b/config/config.go index be05cb5..2ec6706 100644 --- a/config/config.go +++ b/config/config.go @@ -1,8 +1,8 @@ package config import ( + "github.com/pkg/errors" "io/ioutil" - "log" "gopkg.in/yaml.v2" ) @@ -47,18 +47,18 @@ type TelegramTdlibClientConfig struct { UseChatInfoDatabase bool `yaml:":use_chat_info_database"` } -func ReadConfig(path string) Config { +func ReadConfig(path string) (Config, error) { var config Config file, err := ioutil.ReadFile(path) if err != nil { - log.Fatalf("Can't open config file: %v", err) + return config, errors.Wrap(err, "Can't open config file") } err = yaml.Unmarshal(file, &config) if err != nil { - log.Fatalf("Error parsing config: %v", err) + return config, errors.Wrap(err, "Error parsing config") } - return config + return config, nil } -- cgit v1.2.3