From fba00a843c5656bd8df598a0bb5965c19403ade6 Mon Sep 17 00:00:00 2001 From: Michael Mayer Date: Sat, 4 Oct 2025 15:59:34 +0200 Subject: [PATCH] Config: Add "test-hub" target to Makefile and improve log messages Signed-off-by: Michael Mayer --- Makefile | 4 ++++ internal/service/hub/config.go | 8 ++++---- internal/service/hub/hub_test.go | 6 +++--- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index d7e717c7e..db1ea76af 100644 --- a/Makefile +++ b/Makefile @@ -73,6 +73,7 @@ build-all: build-go build-js pull: docker-pull test: test-js test-go test-go: run-test-go +test-hub: run-test-hub test-pkg: run-test-pkg test-ai: run-test-ai test-api: run-test-api @@ -403,6 +404,9 @@ run-test-short: run-test-go: $(info Running all Go tests...) $(GOTEST) -parallel 1 -count 1 -cpu 1 -tags="slow,develop" -timeout 20m ./pkg/... ./internal/... +run-test-hub: + $(info Running all Go tests with hub requests...) + env PHOTOPRISM_TEST_HUB="true" $(GOTEST) -parallel 1 -count 1 -cpu 1 -tags="slow,develop,debug" -timeout 20m ./pkg/... ./internal/... run-test-mariadb: $(info Running all Go tests on MariaDB...) PHOTOPRISM_TEST_DRIVER="mysql" PHOTOPRISM_TEST_DSN="root:photoprism@tcp(mariadb:4001)/acceptance?charset=utf8mb4,utf8&collation=utf8mb4_unicode_ci&parseTime=true" $(GOTEST) -parallel 1 -count 1 -cpu 1 -tags="slow,develop" -timeout 20m ./pkg/... ./internal/... diff --git a/internal/service/hub/config.go b/internal/service/hub/config.go index db0600735..a06ae9879 100644 --- a/internal/service/hub/config.go +++ b/internal/service/hub/config.go @@ -226,7 +226,7 @@ func (c *Config) ReSync(token string) (err error) { // Return if no endpoint URL is set. if endpointUrl == "" { - log.Debugf("config: unable to obtain API key for maps and places (service disabled)") + log.Debugf("config: unable to obtain key for maps and places (service disabled)") return nil } @@ -235,10 +235,10 @@ func (c *Config) ReSync(token string) (err error) { if c.Key == "" { method = http.MethodPost - log.Tracef("config: requesting new API key for maps and places") + log.Tracef("config: requesting new key for maps and places") } else { method = http.MethodPut - log.Tracef("config: requesting API key for maps and places") + log.Tracef("config: requesting key for maps and places") } // Create JSON request. @@ -275,7 +275,7 @@ func (c *Config) ReSync(token string) (err error) { if err != nil { return err } else if r.StatusCode >= 400 { - err = fmt.Errorf("requesting api key from %s failed (error %d)", GetServiceHost(), r.StatusCode) + err = fmt.Errorf("failed to request key from %s (error %d)", GetServiceHost(), r.StatusCode) return err } diff --git a/internal/service/hub/hub_test.go b/internal/service/hub/hub_test.go index 7ce6b03c7..9aee2c97f 100644 --- a/internal/service/hub/hub_test.go +++ b/internal/service/hub/hub_test.go @@ -90,7 +90,7 @@ func TestConfig_Refresh(t *testing.T) { if sess, err := c.DecodeSession(false); err != nil { t.Fatal(err) } else if sess.Expired() { - t.Fatalf("session expired: %+v", sess) + t.Fatalf("(1) session expired: %+v", sess) } else { t.Logf("(1) session: %#v", sess) } @@ -114,9 +114,9 @@ func TestConfig_Refresh(t *testing.T) { if sess, err := c.DecodeSession(false); err != nil { t.Fatal(err) } else if sess.Expired() { - t.Fatal("session expired") + t.Fatal("(2) session expired") } else { - t.Logf("session: %#v", sess) + t.Logf("(2) session: %#v", sess) } if err := c.Save(); err != nil {