Fix tests for scopeStore.
Update all our tests to use the PG_TEST_DB environment variable if set, and use
that to control whether or not the postgres tests get run. testing.Short() just
wasn't working.
Update ErrScopeNotFound and ErrScopeAlreadyExists to be variables instead of
types, because PostgreSQL (annoyingly) offers no way to determine which specific
row insertion caused the problem, and I anticipate this being a problem that is
ongoing. So it's really just not worth it.
Stop getScopes from returning an ErrScopeNotFound. Let's return what we find,
and let the absence of what we didn't find speak for itself.
Fix an error with generating the SQL for the postgres.createScopes call. We used
to generate it in a way that was invalid (not joining values with ",") when more
than one set of values was supplied. Hooray, testing!
Update the postgres scopeStore to return ErrScopeNotFound and
ErrScopeAlreadyExists errors, as appropriate.
Update our tests to reflect that ErrScopeNotFound and ErrScopeAlreadyExists are
now variables, not types.
1 CREATE TABLE IF NOT EXISTS profiles (
2 id VARCHAR(36) PRIMARY KEY,
3 name VARCHAR(64) NOT NULL,
4 passphrase VARCHAR(64) NOT NULL,
5 iterations INTEGER NOT NULL,
6 salt VARCHAR(64) NOT NULL,
7 passphrase_scheme INTEGER NOT NULL,
8 compromised BOOLEAN NOT NULL,
9 locked_until TIMESTAMPTZ NOT NULL,
10 passphrase_reset VARCHAR(64) NOT NULL,
11 passphrase_reset_created TIMESTAMPTZ NOT NULL,
12 created TIMESTAMPTZ NOT NULL,
13 last_seen TIMESTAMPTZ NOT NULL,
14 deleted BOOLEAN NOT NULL
17 CREATE TABLE IF NOT EXISTS logins (
18 type VARCHAR(16) NOT NULL,
19 value VARCHAR(64) PRIMARY KEY,
20 profile_id VARCHAR(36) NOT NULL,
21 created TIMESTAMPTZ NOT NULL,
22 last_used TIMESTAMPTZ NOT NULL
25 CREATE TABLE IF NOT EXISTS clients (
26 id VARCHAR(36) PRIMARY KEY,
27 secret VARCHAR(64) NOT NULL,
28 owner_id VARCHAR(36) NOT NULL,
29 name VARCHAR(32) NOT NULL,
30 logo VARCHAR(512) NOT NULL,
31 website VARCHAR(140) NOT NULL,
32 type VARCHAR(16) NOT NULL,
33 deleted BOOLEAN NOT NULL
36 CREATE TABLE IF NOT EXISTS endpoints (
37 id VARCHAR(36) PRIMARY KEY,
38 client_id VARCHAR(36) NOT NULL,
39 uri VARCHAR(512) NOT NULL,
40 normalized_uri VARCHAR(512) NOT NULL,
41 added TIMESTAMPTZ NOT NULL
44 CREATE TABLE IF NOT EXISTS scopes (
45 id VARCHAR(64) PRIMARY KEY,
46 name VARCHAR(64) NOT NULL,
47 description TEXT NOT NULL