From 7e50d43a49482168e2a57348c34cd65f8c923e53 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sat, 5 Dec 2026 04:30:34 +0000 Subject: [PATCH 1/2] chore(deps): update postgrest/postgrest docker tag to v16.7 --- testdata/postgrest/docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testdata/postgrest/docker-compose.yml b/testdata/postgrest/docker-compose.yml index cdfd6bb4..0610d2a0 100644 --- a/testdata/postgrest/docker-compose.yml +++ b/testdata/postgrest/docker-compose.yml @@ -20,7 +20,7 @@ services: retries: 60 postgrest: - image: "${POSTGREST_IMAGE:-postgrest/postgrest:v16.6}" + image: "${POSTGREST_IMAGE:-postgrest/postgrest:v16.7}" depends_on: postgres: condition: service_healthy From 5070f3dc95f8034c4938159f10775391d5c81f22 Mon Sep 17 00:00:00 2001 From: trakhimenok <533159+trakhimenok@users.noreply.github.com> Date: Sat, 5 Dec 2026 04:59:00 +0000 Subject: [PATCH 2/2] test(endpoints): make test project IDs unique and valid Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> --- .../exec_run_query_http_errors_test.go | 2 +- .../exec_run_query_http_mode_test.go | 2 +- pkg/server/endpoints/exec_run_query_test.go | 5 +-- pkg/server/endpoints/semantic_fixture_test.go | 44 ++++++++++++++++++- 4 files changed, 47 insertions(+), 6 deletions(-) diff --git a/pkg/server/endpoints/exec_run_query_http_errors_test.go b/pkg/server/endpoints/exec_run_query_http_errors_test.go index 64707971..d9a5f464 100644 --- a/pkg/server/endpoints/exec_run_query_http_errors_test.go +++ b/pkg/server/endpoints/exec_run_query_http_errors_test.go @@ -40,7 +40,7 @@ import ( func writeRunQueryHTTPTestProject(t *testing.T, urlTemplate string) (projectDir, projectID string) { t.Helper() dir := t.TempDir() - projectID = "run-query-http-test-" + strings.NewReplacer("/", "-", " ", "-").Replace(t.Name()) + projectID = testProjectID("run-query-http-test-", t.Name(), dir) filestore.SetProjectPath(projectID, dir) queriesDir := filepath.Join(dir, "queries", "reference") diff --git a/pkg/server/endpoints/exec_run_query_http_mode_test.go b/pkg/server/endpoints/exec_run_query_http_mode_test.go index 9d56e120..dfa5add4 100644 --- a/pkg/server/endpoints/exec_run_query_http_mode_test.go +++ b/pkg/server/endpoints/exec_run_query_http_mode_test.go @@ -478,7 +478,7 @@ func TestExecRunQuery_HTTPSource_UnenforceablePolicyCondition_AccessDenied(t *te defer srv.Close() dir := t.TempDir() - projectID := "run-query-http-capability-test-" + strings.NewReplacer("/", "-", " ", "-").Replace(t.Name()) + projectID := testProjectID("run-query-http-capability-test-", t.Name(), dir) filestore.SetProjectPath(projectID, dir) queriesDir := filepath.Join(dir, "queries", "reference") diff --git a/pkg/server/endpoints/exec_run_query_test.go b/pkg/server/endpoints/exec_run_query_test.go index f126a747..d53471a1 100644 --- a/pkg/server/endpoints/exec_run_query_test.go +++ b/pkg/server/endpoints/exec_run_query_test.go @@ -9,7 +9,6 @@ import ( "net/http" "net/http/httptest" "path/filepath" - "strings" "testing" "github.com/datatug/datatug-cli/pkg/api" @@ -71,7 +70,7 @@ where: func writeRunQueryTestProject(t *testing.T) (projectDir, projectID string) { t.Helper() dir := t.TempDir() - projectID = "run-query-test-" + strings.NewReplacer("/", "-", " ", "-").Replace(t.Name()) + projectID = testProjectID("run-query-test-", t.Name(), dir) filestore.SetProjectPath(projectID, dir) dbPath := copyChinookDB(t, dir) @@ -647,7 +646,7 @@ func TestExecRunQuery_MissingDeclaredRequiredParameter_StillMissingParameter(t * func writeQueryIDConventionTestProject(t *testing.T) (projectDir, projectID string) { t.Helper() dir := t.TempDir() - projectID = "query-id-convention-test-" + strings.NewReplacer("/", "-", " ", "-").Replace(t.Name()) + projectID = testProjectID("query-id-convention-test-", t.Name(), dir) filestore.SetProjectPath(projectID, dir) writePolicies(t, dir) writeMinimalQuery := func(folder string) { diff --git a/pkg/server/endpoints/semantic_fixture_test.go b/pkg/server/endpoints/semantic_fixture_test.go index 4e5ba253..fecda12a 100644 --- a/pkg/server/endpoints/semantic_fixture_test.go +++ b/pkg/server/endpoints/semantic_fixture_test.go @@ -2,12 +2,15 @@ package endpoints import ( "context" + "crypto/sha1" + "encoding/hex" "io" "os" "path/filepath" "strconv" "strings" "testing" + "unicode" "github.com/datatug/datatug-core/pkg/datatug" "github.com/datatug/datatug-core/pkg/storage/filestore" @@ -72,7 +75,7 @@ func writeSemanticTestProjectWithSetup(t *testing.T, setup func(string)) (projec if setup != nil { setup(dir) } - projectID = "semantic-test-" + strings.NewReplacer("/", "-", " ", "-").Replace(t.Name()) + projectID = testProjectID("semantic-test-", t.Name(), dir) filestore.SetProjectPath(projectID, dir) mustWriteFile(t, filepath.Join(dir, "datatug-project.json"), `{"title":"Semantic fixture","created":{"at":"2026-01-01T00:00:00Z"},"access":"private"}`) @@ -88,6 +91,45 @@ func writeSemanticTestProjectWithSetup(t *testing.T, setup func(string)) (projec return dir, projectID } +func testProjectID(prefix, testName, dir string) string { + base := sanitizePlainName(testName) + sum := sha1.Sum([]byte(dir)) + suffix := hex.EncodeToString(sum[:4]) + const maxLen = 128 + keep := maxLen - len(prefix) - 1 - len(suffix) + if keep < 1 { + keep = 1 + } + if len(base) > keep { + base = strings.Trim(base[:keep], "-_.") + if base == "" { + base = "test" + } + } + return prefix + base + "-" + suffix +} + +func sanitizePlainName(v string) string { + var b strings.Builder + b.Grow(len(v)) + for _, r := range v { + switch { + case unicode.IsLetter(r), unicode.IsDigit(r), r == '.', r == '_', r == '-': + b.WriteRune(r) + default: + b.WriteByte('-') + } + } + out := strings.Trim(b.String(), "-_.") + if out == "" { + out = "test" + } + if r := rune(out[0]); !unicode.IsLetter(r) && !unicode.IsDigit(r) { + out = "t" + out + } + return out +} + func writeCustomerEntity(t *testing.T, dir string) { t.Helper() entityDir := filepath.Join(dir, "entities", "Customer")