From dfaa5cd49050f4cf13f632aa957929433e92205c Mon Sep 17 00:00:00 2001 From: James Mills <1290234+prologic@users.noreply.github.com> Date: Mon, 27 Mar 2023 00:46:09 +1000 Subject: [PATCH] Fix tests and squelch warning if config file not found --- main.go | 4 +++- testdata/extensions/.test/index.html | 2 +- testdata/ignore/.test/index.html | 2 +- testdata/simple/.test/index.html | 2 +- testdata/variables/.test/index.html | 2 +- 5 files changed, 7 insertions(+), 5 deletions(-) diff --git a/main.go b/main.go index 03aa1ba..3df8d58 100644 --- a/main.go +++ b/main.go @@ -709,7 +709,9 @@ func initConfig() { // If a config file is found, read it in. if err := viper.ReadInConfig(); err != nil { - log.WithError(err).Warnf("error reading config %s (using defaults)", viper.ConfigFileUsed()) + if _, ok := err.(viper.ConfigFileNotFoundError); !ok { + log.WithError(err).Warnf("error reading config %s (using defaults)", viper.ConfigFileUsed()) + } } } diff --git a/testdata/extensions/.test/index.html b/testdata/extensions/.test/index.html index ef8cfca..a25e79f 100644 --- a/testdata/extensions/.test/index.html +++ b/testdata/extensions/.test/index.html @@ -2,7 +2,7 @@ Hello World -

Hello World

+

Hello World

Hello World!

diff --git a/testdata/ignore/.test/index.html b/testdata/ignore/.test/index.html index 417c430..a237b11 100644 --- a/testdata/ignore/.test/index.html +++ b/testdata/ignore/.test/index.html @@ -1,5 +1,5 @@ -

Simple

+

Simple

Simple page

diff --git a/testdata/simple/.test/index.html b/testdata/simple/.test/index.html index 417c430..a237b11 100644 --- a/testdata/simple/.test/index.html +++ b/testdata/simple/.test/index.html @@ -1,5 +1,5 @@ -

Simple

+

Simple

Simple page

diff --git a/testdata/variables/.test/index.html b/testdata/variables/.test/index.html index 25dfc33..42d7892 100644 --- a/testdata/variables/.test/index.html +++ b/testdata/variables/.test/index.html @@ -2,7 +2,7 @@ Simple -

Simple

+

Simple

Simple page