From 125d6af44b48cd0c1b615e8728d104fed8e6cb6f Mon Sep 17 00:00:00 2001 From: unkin-agent Date: Tue, 17 Nov 2026 23:27:56 +1100 Subject: [PATCH] Use neutral names in comments, examples and fixtures --- Makefile | 4 ++-- pg/dsn.go | 6 +++--- pg/dsn_test.go | 6 +++--- pg/migrate_test.go | 18 +++++++++--------- pg/pg.go | 2 +- pg/pgtest/pgtest.go | 6 +++--- 6 files changed, 21 insertions(+), 21 deletions(-) diff --git a/Makefile b/Makefile index 37ad41d..ff60560 100644 --- a/Makefile +++ b/Makefile @@ -24,7 +24,7 @@ build: go build ./... # Unit tests. The container-backed integration tests skip themselves under -# -short, which is how CI runs them: the Kubernetes runners have no Docker. +# -short, which is how CI runs them: the runners have no Docker. test: go test -race -count=1 -short ./... @@ -61,7 +61,7 @@ clean: rm -f cover.out cover.filtered.out # Bump helpers — read the latest semver tag and create the next one. Consumers -# pin the resulting v* tag with `go get git.unkin.net/unkin/golib@vX.Y.Z`. +# pin the resulting v* tag with `go get github.com/IUCLabs/golib@vX.Y.Z`. _LATEST := $(shell git tag --sort=-v:refname | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$$' | head -1) _BASE := $(if $(_LATEST),$(_LATEST),v0.0.0) _MAJ := $(shell echo $(_BASE) | sed 's/^v//' | cut -d. -f1) diff --git a/pg/dsn.go b/pg/dsn.go index bbb30ac..b07c975 100644 --- a/pg/dsn.go +++ b/pg/dsn.go @@ -41,8 +41,8 @@ var ( // DSNFromEnv builds a libpq/pgx connection string from the environment. // // prefix is prepended to every custom variable name, so a service can namespace -// its settings ("ENCAPI_" reads ENCAPI_DBHOST); an empty prefix reads the bare -// names the estate's services already use (DBHOST, DBPORT, ...). +// its settings ("MYAPP_" reads MYAPP_DBHOST); an empty prefix reads the bare +// names (DBHOST, DBPORT, ...). // // Precedence, highest first: // @@ -161,7 +161,7 @@ func connPartsFromEnv(prefix string) (connParts, error) { return p, nil } -// DSN renders the estate's standard connection string. User and password are +// DSN renders the standard connection string. User and password are // percent-escaped, so a password containing "@" or "/" does not truncate the // host; for values without reserved characters the result is byte-identical to // the fmt.Sprintf builders this replaces. diff --git a/pg/dsn_test.go b/pg/dsn_test.go index 47e4491..456c985 100644 --- a/pg/dsn_test.go +++ b/pg/dsn_test.go @@ -49,11 +49,11 @@ func TestDSNFromEnv(t *testing.T) { name: "bare custom vars with an empty prefix", prefix: "", env: map[string]string{ - "DBHOST": "pg", "DBPORT": "5432", "DBUSER": "encapi", - "DBPASS": "encapi", "DBNAME": "encapi", "DBSSL": "disable", + "DBHOST": "pg", "DBPORT": "5432", "DBUSER": "myapp", + "DBPASS": "myapp", "DBNAME": "myapp", "DBSSL": "disable", }, // Byte-identical to the fmt.Sprintf builder this replaces. - want: "postgres://encapi:encapi@pg:5432/encapi?sslmode=disable", + want: "postgres://myapp:myapp@pg:5432/myapp?sslmode=disable", }, { name: "libpq vars fill in", diff --git a/pg/migrate_test.go b/pg/migrate_test.go index ce6ba26..ba8be2f 100644 --- a/pg/migrate_test.go +++ b/pg/migrate_test.go @@ -132,18 +132,18 @@ func (f *fakeDB) discardCount() int { return f.discards } -// arrproxy pinned its advisory lock key as a literal derived from -// FNV-1a/64("arrproxy-migrations"). LockKey must reproduce it exactly, or -// adopting this package would silently stop excluding the old deployment. -func TestLockKey_MatchesTheEstatesPinnedKey(t *testing.T) { - const arrproxyKey int64 = 7816645656172167846 - if got := LockKey("arrproxy-migrations"); got != arrproxyKey { - t.Fatalf("LockKey(%q) = %d, want %d", "arrproxy-migrations", got, arrproxyKey) +// A service that hardcoded its advisory lock key as FNV-1a/64 of its lock name +// must keep getting the same key from LockKey, or adopting this package would +// silently stop excluding the old deployment. +func TestLockKey_MatchesPinnedKey(t *testing.T) { + const pinnedKey int64 = -8597821083387989636 + if got := LockKey("myapp-migrations"); got != pinnedKey { + t.Fatalf("LockKey(%q) = %d, want %d", "myapp-migrations", got, pinnedKey) } } func TestLockKey_IsFNV1a64(t *testing.T) { - for _, name := range []string{"", "encapi-migrations", "a much longer lock name"} { + for _, name := range []string{"", "myapp-migrations", "a much longer lock name"} { h := fnv.New64a() if _, err := h.Write([]byte(name)); err != nil { t.Fatalf("hash: %v", err) @@ -157,7 +157,7 @@ func TestLockKey_IsFNV1a64(t *testing.T) { // Distinct names must not collide, or two services sharing a cluster would // serialise against each other by accident. func TestLockKey_DistinctNamesDistinctKeys(t *testing.T) { - if LockKey("encapi-migrations") == LockKey("artifactapi-migrations") { + if LockKey("myapp-migrations") == LockKey("otherapp-migrations") { t.Fatal("two different lock names produced the same key") } } diff --git a/pg/pg.go b/pg/pg.go index 74c9cdb..a178606 100644 --- a/pg/pg.go +++ b/pg/pg.go @@ -1,4 +1,4 @@ -// Package pg holds the estate's shared Postgres plumbing: environment-driven +// Package pg holds shared Postgres plumbing: environment-driven // DSN construction, pgxpool construction, read/write splitting across a primary // and a read replica, and the migration runner every service uses to bring its // own schema up to date at startup. diff --git a/pg/pgtest/pgtest.go b/pg/pgtest/pgtest.go index 7c4b9c8..07e6373 100644 --- a/pg/pgtest/pgtest.go +++ b/pg/pgtest/pgtest.go @@ -2,8 +2,8 @@ // tests. Import it only from _test.go files so testcontainers never reaches a // production binary. // -// The estate's CI runs on Kubernetes with no Docker socket, so tests that need -// a container must skip themselves under -short. SkipIfShort does exactly that, +// CI without a Docker socket runs tests with -short, so tests that need a +// container must skip themselves under -short. SkipIfShort does exactly that, // and StartPostgres reports a plain error when no container runtime is // reachable, leaving it to the caller whether that is a skip or a failure. package pgtest @@ -20,7 +20,7 @@ import ( "github.com/testcontainers/testcontainers-go/wait" ) -// Image is the Postgres the estate targets; every service runs the same major. +// Image is the Postgres image the container runs. const Image = "postgres:17-alpine" const (