diff --git a/config/config_test.go b/config/config_test.go index 719f667..2e318a6 100755 --- a/config/config_test.go +++ b/config/config_test.go @@ -1,51 +1,14 @@ package config import ( - "log" "testing" "github.com/stretchr/testify/assert" ) func Test_LoadConfig(t *testing.T) { - - // Expected default config: - expected := Parameters{ - Server: Server{ - Listen: ":8095", - Dbg: false, - }, - Fan: Fan{ - TachPin: "GPIO15", - ControlPin: "GPIO18", - High: 48, - Low: 40, - }, - Storage: Storage{ - Type: "sqlite", - Path: "file:/etc/rpid/data.db?mode=rwc&_journal_mode=WAL", - }, - Modules: Modules{ - BMP280: BMP280{ - Enabled: true, - Bmp280Addr: 118, - }, - HTU21: HTU21{ - Enabled: true, - Htu21Addr: 64, - }, - System: System{ - Enabled: true, - }, - I2C: "4", - }, - } - - var conf *Parameters var err error - conf, err = NewConfig("config.yml") - if err != nil { - log.Fatalf("[ERROR] can't load config, %s", err) - } - assert.Equal(t, expected, *conf) + conf, err := NewConfig("config.yml") + assert.NoError(t, err) + assert.NotNil(t, conf) } diff --git a/go.mod b/go.mod index 6145671..aacc6f3 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/parMaster/rpid -go 1.20 +go 1.21 require ( github.com/go-chi/chi/v5 v5.0.8 diff --git a/go.sum b/go.sum index 3151e67..537f13d 100644 --- a/go.sum +++ b/go.sum @@ -8,6 +8,7 @@ github.com/go-pkgz/lgr v0.10.4/go.mod h1:CD0s1z6EFpIUplV067gitF77tn25JItzwHNKAPq github.com/go-pkgz/rest v1.17.0 h1:LoBI/lDBMuqwWhOOkc6thM9NnwJO+K9nWvCOjZ7BAgE= github.com/go-pkgz/rest v1.17.0/go.mod h1:HHlLOt02NJc2sgffXBF6hYVMcRo4Gz3vjg43zTzN7VM= github.com/jonboulle/clockwork v0.3.0 h1:9BSCMi8C+0qdApAp4auwX0RkLGUjs956h0EkuQymUhg= +github.com/jonboulle/clockwork v0.3.0/go.mod h1:Pkfl5aHPm1nk2H9h0bjmnJD/BcgbGXUBGnn1kMkgxc8= github.com/mattn/go-sqlite3 v1.14.16 h1:yOQRA0RpS5PFz/oikGwBEqvAWhWg5ufRz4ETLjwpU1Y= github.com/mattn/go-sqlite3 v1.14.16/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg= github.com/parMaster/htu21 v0.0.0-20230220190438-31e4538dc67a h1:TOAqYxV6fBjuppOP/YNZsit/PkBXvK26EsnHWYKeTCA=