From b365a2ce570ffc734dfd421e5a893269220db43f Mon Sep 17 00:00:00 2001 From: Michael Mayer Date: Fri, 21 Dec 2018 03:19:25 +0100 Subject: [PATCH] Rename Config.GetDatabaseDsn() to DatabaseDsn(), see #50 --- internal/commands/config.go | 2 +- internal/context/config.go | 6 +++--- internal/context/config_test.go | 2 +- internal/photoprism/config.go | 2 +- internal/photoprism/config_test.go | 2 +- internal/test/config.go | 6 +++--- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/internal/commands/config.go b/internal/commands/config.go index 85925f74f..8af82d4cd 100644 --- a/internal/commands/config.go +++ b/internal/commands/config.go @@ -27,7 +27,7 @@ func configAction(ctx *cli.Context) error { fmt.Printf("cache-path %s\n", conf.GetCachePath()) fmt.Printf("assets-path %s\n", conf.GetAssetsPath()) fmt.Printf("database-driver %s\n", conf.DatabaseDriver()) - fmt.Printf("database-dsn %s\n", conf.GetDatabaseDsn()) + fmt.Printf("database-dsn %s\n", conf.DatabaseDsn()) return nil } diff --git a/internal/context/config.go b/internal/context/config.go index d39cfb4f7..e300c52a9 100644 --- a/internal/context/config.go +++ b/internal/context/config.go @@ -249,7 +249,7 @@ func (c *Config) CreateDirectories() error { // It tries to do this 12 times with a 5 second sleep interval in between. func (c *Config) connectToDatabase() error { dbDriver := c.DatabaseDriver() - dbDsn := c.GetDatabaseDsn() + dbDsn := c.DatabaseDsn() isTiDB := false initSuccess := false @@ -371,8 +371,8 @@ func (c *Config) DatabaseDriver() string { return c.databaseDriver } -// GetDatabaseDsn returns the database data source name (DSN). -func (c *Config) GetDatabaseDsn() string { +// DatabaseDsn returns the database data source name (DSN). +func (c *Config) DatabaseDsn() string { return c.databaseDsn } diff --git a/internal/context/config_test.go b/internal/context/config_test.go index 383d2ee22..8bcd21255 100644 --- a/internal/context/config_test.go +++ b/internal/context/config_test.go @@ -35,5 +35,5 @@ func TestConfig_SetValuesFromFile(t *testing.T) { assert.Equal(t, "/srv/photoprism/photos/import", c.GetImportPath()) assert.Equal(t, "/srv/photoprism/photos/export", c.GetExportPath()) assert.Equal(t, "tidb", c.DatabaseDriver()) - assert.Equal(t, "root:@tcp(localhost:4000)/photoprism?parseTime=true", c.GetDatabaseDsn()) + assert.Equal(t, "root:@tcp(localhost:4000)/photoprism?parseTime=true", c.DatabaseDsn()) } diff --git a/internal/photoprism/config.go b/internal/photoprism/config.go index a0ea302a1..ca2f380dc 100644 --- a/internal/photoprism/config.go +++ b/internal/photoprism/config.go @@ -30,7 +30,7 @@ type Config interface { HttpServerMode() string DatabaseDriver() string - GetDatabaseDsn() string + DatabaseDsn() string GetOriginalsPath() string GetImportPath() string GetExportPath() string diff --git a/internal/photoprism/config_test.go b/internal/photoprism/config_test.go index a8a641969..0109edbad 100644 --- a/internal/photoprism/config_test.go +++ b/internal/photoprism/config_test.go @@ -59,7 +59,7 @@ func TestContextConfig_SetValuesFromFile(t *testing.T) { assert.Equal(t, "/srv/photoprism/photos/import", c.GetImportPath()) assert.Equal(t, "/srv/photoprism/photos/export", c.GetExportPath()) assert.Equal(t, "tidb", c.DatabaseDriver()) - assert.Equal(t, "root:@tcp(localhost:4000)/photoprism?parseTime=true", c.GetDatabaseDsn()) + assert.Equal(t, "root:@tcp(localhost:4000)/photoprism?parseTime=true", c.DatabaseDsn()) } func TestTestConfig_ConnectToDatabase(t *testing.T) { diff --git a/internal/test/config.go b/internal/test/config.go index b51c07528..bde356f3e 100644 --- a/internal/test/config.go +++ b/internal/test/config.go @@ -128,7 +128,7 @@ func (c *Config) CreateDirectories() error { // It tries to do this 12 times with a 5 second sleep intervall in between. func (c *Config) connectToDatabase() error { dbDriver := c.DatabaseDriver() - dbDsn := c.GetDatabaseDsn() + dbDsn := c.DatabaseDsn() db, err := gorm.Open(dbDriver, dbDsn) @@ -228,8 +228,8 @@ func (c *Config) DatabaseDriver() string { return DatabaseDriver } -// GetDatabaseDsn returns the database data source name (DSN). -func (c *Config) GetDatabaseDsn() string { +// DatabaseDsn returns the database data source name (DSN). +func (c *Config) DatabaseDsn() string { return DatabaseDsn }