Files
ziadarafatandClaude Opus 5.5 ae08961a38 Dogebot: Red-DiscordBot with self-updating music, deployed with quadlets
- Red 3.5.24 (Postgres storage) with the dogesetup cog, which installs,
  loads and daily updates the cogs listed in src/dogebot/manifest.py and
  points Audio at our Lavalink
- Lavalink: Red's 3.7 build plus youtube-source (OAuth, TV/WEB clients) and
  yt-cipher; dogebot-update builds new versions, smoke tests them next to
  the live server and swaps them in with rollback, falling back from the
  plugin release to its newest snapshot
- Rootless podman quadlets for Red, Lavalink, yt-cipher and Postgres, a daily
  update timer, and deploy/install.sh
- mise for tools and tasks, uv for Python 3.11 and dependencies, ruff with
  the lptn settings, ty type checking, 37 pytest tests including a contract
  test for the Red internals dogesetup uses

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GUebqhE8dK19vyn4Ct5g1L
2026-11-04 17:35:28 -07:00

62 lines
2.2 KiB
Python

"""Version resolution and state for the Lavalink update job."""
from pathlib import Path
import pytest
from dogebot import update
def test_latest_lavalink_picks_newest_red_build() -> None:
"""Prereleases and non-Red builds are skipped."""
releases = [
{"tag_name": "4.0.0", "prerelease": False},
{"tag_name": "3.7.14+red.1", "prerelease": True},
{"tag_name": "3.7.13+red.5", "prerelease": False},
{"tag_name": "3.7.13+red.3", "prerelease": False},
]
assert update.latest_lavalink(releases) == "3.7.13+red.5"
def test_latest_lavalink_needs_a_release() -> None:
"""No usable release is an error, not a silent downgrade."""
with pytest.raises(LookupError):
update.latest_lavalink([{"tag_name": "4.0.0"}])
def test_build_args_point_at_maven() -> None:
"""The plugin repository is a full Maven URL."""
args = update.Versions(
"3.7.13+red.5", "abc123", "snapshots"
).build_args()
assert "--build-arg=YOUTUBE_PLUGIN_VERSION=abc123" in args
assert (
"--build-arg=YOUTUBE_PLUGIN_REPO=https://maven.lavalink.dev/snapshots"
in args
)
def test_plugin_jar_url() -> None:
"""Jar URLs follow Maven's layout."""
assert update.plugin_jar_url("1.18.2", "releases") == (
"https://maven.lavalink.dev/releases/dev/lavalink/youtube/"
"youtube-plugin/1.18.2/youtube-plugin-1.18.2.jar"
)
def test_state_round_trip(
tmp_path: Path, monkeypatch: pytest.MonkeyPatch
) -> None:
"""Recorded versions read back the same; a missing file is None."""
monkeypatch.setenv("XDG_STATE_HOME", str(tmp_path))
assert update.read_state() is None
versions = update.Versions("3.7.13+red.5", "1.18.2", "releases")
update.write_state(versions)
assert update.read_state() == versions
def test_containerfile_dir_exists() -> None:
"""The build context the job uses is in the repo."""
assert (update.CONTAINERFILE_DIR / "Containerfile").is_file()
assert (update.CONTAINERFILE_DIR / "application.yml").is_file()