diff --git a/config.go b/config.go index 99bc646..7def826 100644 --- a/config.go +++ b/config.go @@ -12,6 +12,7 @@ const configFilename = "hal.yaml" type Config struct { HomeAssistant HomeAssistantConfig `yaml:"homeAssistant"` Location LocationConfig `yaml:"location"` + DatabasePath string `yaml:"databasePath"` } type HomeAssistantConfig struct { diff --git a/connection.go b/connection.go index 55c95d6..ae23c96 100644 --- a/connection.go +++ b/connection.go @@ -40,7 +40,12 @@ type ConnectionBinder interface { } func NewConnection(cfg Config) *Connection { - db, err := store.Open("sqlite.db") + dbPath := cfg.DatabasePath + if dbPath == "" { + dbPath = "sqlite.db" + } + + db, err := store.Open(dbPath) if err != nil { panic(err) } diff --git a/testutil/testutil.go b/testutil/testutil.go index 4ce5c38..555517c 100644 --- a/testutil/testutil.go +++ b/testutil/testutil.go @@ -32,6 +32,7 @@ func NewClientServer(t *testing.T) (*hal.Connection, *hassws.Server, func()) { Token: "test-token", UserID: TestUserID, }, + DatabasePath: ":memory:", }) // Create test entity and register it