Add lint and test workflows
Tests / Test (Go) (push) Successful in 1m46s
Tests / Test (Python) (push) Successful in 14s
Lint / Lint (Go) (push) Successful in 21s
Lint / Lint (Python) (push) Successful in 10s
Tests / Test (Node/Svelte) (push) Successful in 12s
Lint / Lint (Node/Svelte) (push) Successful in 40s
Tests / Test (Go) (push) Successful in 1m46s
Tests / Test (Python) (push) Successful in 14s
Lint / Lint (Go) (push) Successful in 21s
Lint / Lint (Python) (push) Successful in 10s
Tests / Test (Node/Svelte) (push) Successful in 12s
Lint / Lint (Node/Svelte) (push) Successful in 40s
This commit is contained in:
1 parent
838a97d344
commit
fbbdab49bc
8 files changed
+242
-2
No files matched your search
@@ -16,3 +16,10 @@ dependencies = [
|
||||
|
||||
[tool.setuptools.packages.find]
|
||||
where = ["src"]
|
||||
|
||||
[tool.ruff]
|
||||
target-version = "py310"
|
||||
line-length = 100
|
||||
|
||||
[tool.ruff.lint]
|
||||
select = ["E", "F", "I"]
|
||||
@@ -22,7 +22,8 @@ CREATE TABLE IF NOT EXISTS auth_users (
|
||||
ALTER TABLE auth_users ADD COLUMN IF NOT EXISTS email TEXT NOT NULL DEFAULT '';
|
||||
ALTER TABLE auth_users ADD COLUMN IF NOT EXISTS created_at TIMESTAMPTZ NOT NULL DEFAULT now();
|
||||
ALTER TABLE auth_users ADD COLUMN IF NOT EXISTS updated_at TIMESTAMPTZ NOT NULL DEFAULT now();
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS auth_users_email_idx ON auth_users (lower(email)) WHERE email <> '';
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS auth_users_email_idx
|
||||
ON auth_users (lower(email)) WHERE email <> '';
|
||||
CREATE TABLE IF NOT EXISTS auth_sessions (
|
||||
id BIGSERIAL PRIMARY KEY,
|
||||
user_id BIGINT NOT NULL REFERENCES auth_users(id) ON DELETE CASCADE,
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from contextlib import asynccontextmanager
|
||||
from typing import Any, AsyncIterator, Awaitable, Callable, Sequence
|
||||
from typing import Any, AsyncIterator, Awaitable, Callable
|
||||
|
||||
import asyncpg
|
||||
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
import os
|
||||
import unittest
|
||||
|
||||
from shared_backend.auth import hash_password, verify_password
|
||||
from shared_backend.config import DatabaseConfig
|
||||
from shared_backend.tokens import hash_token, new_session_token
|
||||
|
||||
|
||||
class SharedBackendTests(unittest.TestCase):
|
||||
def test_password_round_trip(self):
|
||||
password_hash = hash_password("correct horse battery staple")
|
||||
self.assertTrue(verify_password("correct horse battery staple", password_hash))
|
||||
self.assertFalse(verify_password("wrong password", password_hash))
|
||||
|
||||
def test_session_token_hash(self):
|
||||
token, token_hash = new_session_token()
|
||||
self.assertNotEqual(token, token_hash)
|
||||
self.assertEqual(hash_token(token), token_hash)
|
||||
|
||||
def test_database_config_from_environment(self):
|
||||
config = DatabaseConfig.from_env(
|
||||
{
|
||||
**os.environ,
|
||||
"DATABASE_URL": "postgresql://user:password@localhost:5432/app",
|
||||
"DATABASE_MAX_CONNS": "7",
|
||||
"DATABASE_MIN_CONNS": "2",
|
||||
}
|
||||
)
|
||||
self.assertEqual(config.max_size, 7)
|
||||
self.assertEqual(config.min_size, 2)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in new issue
Block a user