From 7b3a09d8acdd3d3459ba2626b47026126f7dc09b Mon Sep 17 00:00:00 2001 From: crapStone Date: Sun, 19 Nov 2023 23:56:56 +0100 Subject: [PATCH] fix tests --- config/setup_test.go | 27 ++++++++++++++------------- example_config.toml | 6 ++++-- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/config/setup_test.go b/config/setup_test.go index f0cab3a..ba1241f 100644 --- a/config/setup_test.go +++ b/config/setup_test.go @@ -74,21 +74,19 @@ func TestReadConfigShouldReturnConfigFromFileWhenConfigArgPresent(t *testing.T) runApp( t, func(ctx *cli.Context) error { - content, err := os.ReadFile("assets/test_config.toml") - if err != nil { - return err - } - - expectedConfig := &Config{} - err = toml.Unmarshal(content, expectedConfig) - if err != nil { - return err - } - cfg, err := ReadConfig(ctx) + if err != nil { + return err + } + + expectedConfig, err := readTestConfig() + if err != nil { + return err + } + assert.Equal(t, expectedConfig, cfg) - return err + return nil }, []string{"--config-file", "assets/test_config.toml"}, ) @@ -99,6 +97,9 @@ func TestValuesReadFromConfigFileShouldBeOverwrittenByArgs(t *testing.T) { t, func(ctx *cli.Context) error { cfg, err := ReadConfig(ctx) + if err != nil { + return err + } MergeConfig(ctx, cfg) @@ -115,7 +116,7 @@ func TestValuesReadFromConfigFileShouldBeOverwrittenByArgs(t *testing.T) { assert.Equal(t, expectedConfig, cfg) - return err + return nil }, []string{ "--config-file", "assets/test_config.toml", diff --git a/example_config.toml b/example_config.toml index 4ef817f..e02984c 100644 --- a/example_config.toml +++ b/example_config.toml @@ -1,13 +1,15 @@ +# specify at which log level should be logged +# Possible options: trace, debug, info, warn, error logLevel = 'debug' [server] host = '127.0.0.1' port = 443 httpPort = 80 -httpServerEnabled = false +httpServerEnabled = true mainDomain = '' rawDomain = '' -allowedCorsDomains = ['asdf', 'jkl;'] +allowedCorsDomains = [] blacklistedPaths = [] [gitea]