Compare commits
41 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 0532d59746 | |||
| e0fcbc71e1 | |||
| c072c57bbb | |||
| aadd6c8abf | |||
| 316ed64315 | |||
| 7084ca1be2 | |||
| 317daddb8e | |||
| 8ef291efd8 | |||
| 92be9c50bf | |||
| f0e5ecd5de | |||
| e2c44583e8 | |||
| 5da741f3a9 | |||
| 35c5eb65cb | |||
| 7e53a26e5f | |||
| 436b3f85d0 | |||
| 9c1a9cc3c5 | |||
| 82f30f126d | |||
| 9599ac28ca | |||
| e71a699ed8 | |||
| ff4eb8ca98 | |||
| b69973b9af | |||
| 3e133fa147 | |||
| ae506789ab | |||
| c3fa689617 | |||
| b51e42b4b2 | |||
| d4bea91186 | |||
| d47dadeb88 | |||
| b807904c6c | |||
| ee1bee22eb | |||
| f6c4c1623f | |||
| 49fd086b92 | |||
| 35dce0bf01 | |||
| 71240373c0 | |||
| 659023d561 | |||
| a0073b65ad | |||
| cba53e0841 | |||
| e50fb88bfc | |||
| ad58912baf | |||
| c4e8d64710 | |||
| ca4319001c | |||
| ebc58b831d |
@@ -7,8 +7,5 @@ echo "Running pre-push hook:"
|
|||||||
echo "Executing: cargo fmt"
|
echo "Executing: cargo fmt"
|
||||||
cargo fmt
|
cargo fmt
|
||||||
|
|
||||||
echo "Executing: make lint"
|
echo "Executing: cargo clippy --all"
|
||||||
make lint
|
cargo clippy --all
|
||||||
|
|
||||||
echo "Executing: cargo test"
|
|
||||||
cargo test
|
|
||||||
|
|||||||
@@ -7,8 +7,8 @@ echo "Running pre-push hook:"
|
|||||||
echo "Executing: cargo fmt --check"
|
echo "Executing: cargo fmt --check"
|
||||||
cargo fmt --check
|
cargo fmt --check
|
||||||
|
|
||||||
echo "Executing: make lint"
|
echo "Executing: cargo clippy --all"
|
||||||
make lint
|
cargo clippy --all
|
||||||
|
|
||||||
echo "Executing: cargo test"
|
echo "Executing: cargo test --all"
|
||||||
cargo test
|
cargo test --all
|
||||||
|
|||||||
@@ -8,9 +8,9 @@ on:
|
|||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
inputs:
|
inputs:
|
||||||
bump_type:
|
bump_type:
|
||||||
description: "Specify the type of version bump"
|
description: 'Specify the type of version bump'
|
||||||
required: true
|
required: true
|
||||||
default: "patch"
|
default: 'patch'
|
||||||
type: choice
|
type: choice
|
||||||
options:
|
options:
|
||||||
- patch
|
- patch
|
||||||
@@ -46,12 +46,12 @@ jobs:
|
|||||||
- name: Set up Python
|
- name: Set up Python
|
||||||
uses: actions/setup-python@v4
|
uses: actions/setup-python@v4
|
||||||
with:
|
with:
|
||||||
python-version: "3.10"
|
python-version: '3.10'
|
||||||
|
|
||||||
- name: Install Commitizen
|
- name: Install Commitizen
|
||||||
run: |
|
run: |
|
||||||
python -m pip install --upgrade pip
|
python3 -m pip install --upgrade pip
|
||||||
pip install commitizen
|
pip3 install commitizen==4.8.3
|
||||||
npm install -g conventional-changelog-cli
|
npm install -g conventional-changelog-cli
|
||||||
|
|
||||||
- name: Configure Git user
|
- name: Configure Git user
|
||||||
@@ -126,12 +126,90 @@ jobs:
|
|||||||
echo "No changes to commit (already at $VERSION)"
|
echo "No changes to commit (already at $VERSION)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
- name: Bump validate_theme_derive/Cargo.toml version
|
||||||
|
shell: bash
|
||||||
|
working-directory: ${{ github.workspace }}/proc_macros/validate_theme_derive
|
||||||
|
env:
|
||||||
|
VERSION: ${{ env.version }}
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
: "${VERSION:?env.version is empty}"
|
||||||
|
|
||||||
|
# Ignore Act's local artifact dir noise
|
||||||
|
echo artifacts/ >> .git/info/exclude || true
|
||||||
|
|
||||||
|
# Edit the version line right after name="managarr"
|
||||||
|
sed -E -i '
|
||||||
|
/^[[:space:]]*name[[:space:]]*=[[:space:]]*"managarr"[[:space:]]*$/ {
|
||||||
|
n
|
||||||
|
s|^[[:space:]]*version[[:space:]]*=[[:space:]]*"[^"]*"|version = "'"$VERSION"'"|
|
||||||
|
}
|
||||||
|
' Cargo.toml
|
||||||
|
|
||||||
|
cargo update || true
|
||||||
|
|
||||||
|
# Git config that helps in containers (Act)
|
||||||
|
git config user.name "github-actions[bot]"
|
||||||
|
git config user.email "github-actions[bot]@users.noreply.github.com"
|
||||||
|
git config --global --add safe.directory "$GITHUB_WORKSPACE"
|
||||||
|
|
||||||
|
# Debug: show what changed
|
||||||
|
git status --porcelain
|
||||||
|
git diff --name-only -- Cargo.toml || true
|
||||||
|
|
||||||
|
# Only commit if one of these files actually changed
|
||||||
|
if ! git diff --quiet -- Cargo.toml; then
|
||||||
|
# Stage only modifications of already tracked files (won't pick up artifacts/)
|
||||||
|
git add -u -- Cargo.toml
|
||||||
|
git commit -m "chore: bump validate_theme_derive Cargo.toml to $VERSION"
|
||||||
|
else
|
||||||
|
echo "No changes to commit (already at $VERSION)"
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Bump enum_display_style_derive/Cargo.toml version
|
||||||
|
shell: bash
|
||||||
|
working-directory: ${{ github.workspace }}/proc_macros/enum_display_style_derive
|
||||||
|
env:
|
||||||
|
VERSION: ${{ env.version }}
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
: "${VERSION:?env.version is empty}"
|
||||||
|
|
||||||
|
# Ignore Act's local artifact dir noise
|
||||||
|
echo artifacts/ >> .git/info/exclude || true
|
||||||
|
|
||||||
|
# Edit the version line right after name="managarr"
|
||||||
|
sed -E -i '
|
||||||
|
/^[[:space:]]*name[[:space:]]*=[[:space:]]*"managarr"[[:space:]]*$/ {
|
||||||
|
n
|
||||||
|
s|^[[:space:]]*version[[:space:]]*=[[:space:]]*"[^"]*"|version = "'"$VERSION"'"|
|
||||||
|
}
|
||||||
|
' Cargo.toml
|
||||||
|
|
||||||
|
cargo update || true
|
||||||
|
|
||||||
|
# Git config that helps in containers (Act)
|
||||||
|
git config user.name "github-actions[bot]"
|
||||||
|
git config user.email "github-actions[bot]@users.noreply.github.com"
|
||||||
|
git config --global --add safe.directory "$GITHUB_WORKSPACE"
|
||||||
|
|
||||||
|
# Debug: show what changed
|
||||||
|
git status --porcelain
|
||||||
|
git diff --name-only -- Cargo.toml || true
|
||||||
|
|
||||||
|
# Only commit if one of these files actually changed
|
||||||
|
if ! git diff --quiet -- Cargo.toml; then
|
||||||
|
# Stage only modifications of already tracked files (won't pick up artifacts/)
|
||||||
|
git add -u -- Cargo.toml
|
||||||
|
git commit -m "chore: bump enum_display_style_derive Cargo.toml to $VERSION"
|
||||||
|
else
|
||||||
|
echo "No changes to commit (already at $VERSION)"
|
||||||
|
fi
|
||||||
|
|
||||||
- name: Generate changelog for the version bump
|
- name: Generate changelog for the version bump
|
||||||
id: changelog
|
id: changelog
|
||||||
run: |
|
run: |
|
||||||
changelog=$(conventional-changelog -p angular -i CHANGELOG.md -s --from ${{ env.prev_version }} --to ${{ env.version }})
|
conventional-changelog -p angular -i CHANGELOG.md --from ${{ env.prev_version }} --to v${{ env.version }} > artifacts/changelog.md
|
||||||
echo "$changelog" > artifacts/changelog.md
|
|
||||||
echo "changelog_body=$(cat artifacts/changelog.md)" >> $GITHUB_ENV
|
|
||||||
|
|
||||||
- name: Push changes
|
- name: Push changes
|
||||||
if: env.ACT != 'true'
|
if: env.ACT != 'true'
|
||||||
@@ -153,6 +231,8 @@ jobs:
|
|||||||
path: |
|
path: |
|
||||||
Cargo.toml
|
Cargo.toml
|
||||||
Cargo.lock
|
Cargo.lock
|
||||||
|
proc_macros/validate_theme_derive/Cargo.toml
|
||||||
|
proc_macros/enum_display_style_derive/Cargo.toml
|
||||||
|
|
||||||
build-release-artifacts:
|
build-release-artifacts:
|
||||||
name: build-release
|
name: build-release
|
||||||
@@ -333,13 +413,11 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
release_version="$(cat ./artifacts/release-version)"
|
release_version="$(cat ./artifacts/release-version)"
|
||||||
echo "RELEASE_VERSION=$release_version" >> $GITHUB_ENV
|
echo "RELEASE_VERSION=$release_version" >> $GITHUB_ENV
|
||||||
changelog_body="$(cat ./artifacts/changelog.md)"
|
|
||||||
echo "changelog_body=$(cat artifacts/changelog.md)" >> $GITHUB_ENV
|
|
||||||
|
|
||||||
- name: Validate release environment variables
|
- name: Validate release environment variables
|
||||||
run: |
|
run: |
|
||||||
echo "Release version: ${{ env.RELEASE_VERSION }}"
|
echo "Release version: ${{ env.RELEASE_VERSION }}"
|
||||||
echo "Changelog body: ${{ env.changelog_body }}"
|
echo "Changelog body: $(cat artifacts/changelog.md)"
|
||||||
|
|
||||||
- name: Create a GitHub Release
|
- name: Create a GitHub Release
|
||||||
if: env.ACT != 'true'
|
if: env.ACT != 'true'
|
||||||
@@ -373,8 +451,8 @@ jobs:
|
|||||||
artifacts/managarr-armv7-musl.tar.gz
|
artifacts/managarr-armv7-musl.tar.gz
|
||||||
artifacts/managarr-armv7-musl.sha256
|
artifacts/managarr-armv7-musl.sha256
|
||||||
tag_name: v${{ env.RELEASE_VERSION }}
|
tag_name: v${{ env.RELEASE_VERSION }}
|
||||||
name: "v${{ env.RELEASE_VERSION }}"
|
name: 'v${{ env.RELEASE_VERSION }}'
|
||||||
body: ${{ env.changelog_body }}
|
body_path: artifacts/changelog.md
|
||||||
draft: false
|
draft: false
|
||||||
prerelease: false
|
prerelease: false
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
[keys.normal.backspace]
|
||||||
|
b = ":sh zellij run -x '4%%' --width '92%%' -f -n Build -- just build"
|
||||||
|
r = ":sh zellij run -x '3%%' -y '8%%' --width '95%%' --height '90%%' -fc -n 'Run' -- just run"
|
||||||
|
t = ":sh zellij run -x '4%%' --width '92%%' -f -n Tests -- just test"
|
||||||
|
l = ":sh zellij run -x '4%%' --width '92%%' -f -n Lint -- just lint"
|
||||||
@@ -5,6 +5,22 @@ All notable changes to this project will be documented in this file.
|
|||||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||||
|
|
||||||
|
## v0.6.3 (2025-12-13)
|
||||||
|
|
||||||
|
### Fix
|
||||||
|
|
||||||
|
- Wrapped all Sonarr use of Language with Option to fix the 'null' array issue in the new Sonarr API
|
||||||
|
|
||||||
|
## v0.6.2 (2025-12-12)
|
||||||
|
|
||||||
|
### Fix
|
||||||
|
|
||||||
|
- Fixed breaking Sonarr Episode file API calls after recent Sonarr API update
|
||||||
|
|
||||||
|
### Refactor
|
||||||
|
|
||||||
|
- Replaced all modulo usages of tick_until_poll with is_multiple_of
|
||||||
|
|
||||||
## v0.6.1 (2025-09-02)
|
## v0.6.1 (2025-09-02)
|
||||||
|
|
||||||
### Fix
|
### Fix
|
||||||
|
|||||||
+2
-1
@@ -65,7 +65,8 @@ cz commit
|
|||||||
1. Clone this repo
|
1. Clone this repo
|
||||||
2. Run `cargo test` to set up hooks
|
2. Run `cargo test` to set up hooks
|
||||||
3. Make changes
|
3. Make changes
|
||||||
4. Run the application using `make run` or `cargo run`
|
4. Run the application using `just run` or `just run`
|
||||||
|
- Install `just` (`cargo install just`) if you haven't already to use the [justfile](./justfile) in this project.
|
||||||
5. Commit changes. This will trigger pre-commit hooks that will run format, test and lint. If there are errors or warnings from Clippy, please fix them.
|
5. Commit changes. This will trigger pre-commit hooks that will run format, test and lint. If there are errors or warnings from Clippy, please fix them.
|
||||||
6. Push your code to a new branch named after the feature/bug/etc. you're adding. This will trigger pre-push hooks that will run lint and test.
|
6. Push your code to a new branch named after the feature/bug/etc. you're adding. This will trigger pre-push hooks that will run lint and test.
|
||||||
7. Create a PR
|
7. Create a PR
|
||||||
|
|||||||
Generated
+748
-500
File diff suppressed because it is too large
Load Diff
+5
-3
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "managarr"
|
name = "managarr"
|
||||||
version = "0.6.1"
|
version = "0.6.3"
|
||||||
authors = ["Alex Clarke <alex.j.tusa@gmail.com>"]
|
authors = ["Alex Clarke <alex.j.tusa@gmail.com>"]
|
||||||
description = "A TUI and CLI to manage your Servarrs"
|
description = "A TUI and CLI to manage your Servarrs"
|
||||||
keywords = ["managarr", "ratatui", "dashboard", "servarr", "tui"]
|
keywords = ["managarr", "ratatui", "dashboard", "servarr", "tui"]
|
||||||
@@ -8,7 +8,7 @@ documentation = "https://github.com/Dark-Alex-17/managarr"
|
|||||||
repository = "https://github.com/Dark-Alex-17/managarr"
|
repository = "https://github.com/Dark-Alex-17/managarr"
|
||||||
homepage = "https://github.com/Dark-Alex-17/managarr"
|
homepage = "https://github.com/Dark-Alex-17/managarr"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
edition = "2021"
|
edition = "2024"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
rust-version = "1.89.0"
|
rust-version = "1.89.0"
|
||||||
exclude = [".github", "CONTRIBUTING.md", "*.log", "tags"]
|
exclude = [".github", "CONTRIBUTING.md", "*.log", "tags"]
|
||||||
@@ -63,7 +63,6 @@ managarr-tree-widget = "0.24.0"
|
|||||||
indicatif = "0.17.9"
|
indicatif = "0.17.9"
|
||||||
derive_setters = "0.1.6"
|
derive_setters = "0.1.6"
|
||||||
deunicode = "1.6.0"
|
deunicode = "1.6.0"
|
||||||
paste = "1.0.15"
|
|
||||||
openssl = { version = "0.10.70", features = ["vendored"] }
|
openssl = { version = "0.10.70", features = ["vendored"] }
|
||||||
veil = "0.2.0"
|
veil = "0.2.0"
|
||||||
validate_theme_derive = "0.1.0"
|
validate_theme_derive = "0.1.0"
|
||||||
@@ -74,8 +73,11 @@ assert_cmd = "2.0.16"
|
|||||||
mockall = "0.13.0"
|
mockall = "0.13.0"
|
||||||
mockito = "1.0.0"
|
mockito = "1.0.0"
|
||||||
pretty_assertions = "1.3.0"
|
pretty_assertions = "1.3.0"
|
||||||
|
proptest = "1.6.0"
|
||||||
rstest = "0.25.0"
|
rstest = "0.25.0"
|
||||||
serial_test = "3.2.0"
|
serial_test = "3.2.0"
|
||||||
|
assertables = "9.8.2"
|
||||||
|
insta = "1.41.1"
|
||||||
|
|
||||||
[dev-dependencies.cargo-husky]
|
[dev-dependencies.cargo-husky]
|
||||||
version = "1"
|
version = "1"
|
||||||
|
|||||||
@@ -1,47 +0,0 @@
|
|||||||
#!make
|
|
||||||
VERSION := latest
|
|
||||||
IMG_NAME := darkalex17/managarr
|
|
||||||
IMAGE := ${IMG_NAME}:${VERSION}
|
|
||||||
|
|
||||||
default: run
|
|
||||||
|
|
||||||
.PHONY: test test-cov build run lint lint-fix fmt analyze sonar release delete-tag
|
|
||||||
|
|
||||||
test:
|
|
||||||
@cargo test --all
|
|
||||||
|
|
||||||
## Run all tests with coverage - `cargo install cargo-tarpaulin`
|
|
||||||
test-cov:
|
|
||||||
@cargo tarpaulin
|
|
||||||
|
|
||||||
build: test
|
|
||||||
@cargo build --release
|
|
||||||
|
|
||||||
docker:
|
|
||||||
@DOCKER_BUILDKIT=1 docker build --rm -t ${IMAGE} .
|
|
||||||
|
|
||||||
run:
|
|
||||||
@CARGO_INCREMENTAL=1 cargo fmt && make lint && cargo run
|
|
||||||
|
|
||||||
lint:
|
|
||||||
@find . | grep '\.\/src\/.*\.rs$$' | xargs touch && CARGO_INCREMENTAL=0 cargo clippy --all-targets --workspace
|
|
||||||
|
|
||||||
lint-fix:
|
|
||||||
@cargo fix
|
|
||||||
|
|
||||||
fmt:
|
|
||||||
@cargo fmt
|
|
||||||
|
|
||||||
minimal-versions:
|
|
||||||
@cargo +nightly update -Zdirect-minimal-versions
|
|
||||||
|
|
||||||
## Analyze for unsafe usage - `cargo install cargo-geiger`
|
|
||||||
analyze:
|
|
||||||
@cargo geiger
|
|
||||||
|
|
||||||
release:
|
|
||||||
@git tag -a ${V} -m "Release ${V}" && git push origin ${V}
|
|
||||||
|
|
||||||
delete-tag:
|
|
||||||
@git tag -d ${V} && git push --delete origin ${V}
|
|
||||||
|
|
||||||
@@ -12,4 +12,3 @@ coverage:
|
|||||||
|
|
||||||
ignore:
|
ignore:
|
||||||
- "**/*_tests.rs"
|
- "**/*_tests.rs"
|
||||||
- "src/ui"
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
# Documentation: https://docs.brew.sh/Formula-Cookbook
|
# Documentation: https://docs.brew.sh/Formula-Cookbook
|
||||||
# https://rubydoc.brew.sh/Formula
|
# https://rubydoc.brew.sh/Formula
|
||||||
class Managarr < Formula
|
class Managarr < Formula
|
||||||
desc "A fast and simple dashboard for Kubernetes written in Rust"
|
desc "Managarr is a TUI and CLI to help you manage your HTPC (Home Theater PC)"
|
||||||
homepage "https://github.com/Dark-Alex-17/managarr"
|
homepage "https://github.com/Dark-Alex-17/managarr"
|
||||||
if OS.mac? and Hardware::CPU.arm?
|
if OS.mac? and Hardware::CPU.arm?
|
||||||
url "https://github.com/Dark-Alex-17/managarr/releases/download/v$version/managarr-macos-arm64.tar.gz"
|
url "https://github.com/Dark-Alex-17/managarr/releases/download/v$version/managarr-macos-arm64.tar.gz"
|
||||||
|
|||||||
@@ -0,0 +1,91 @@
|
|||||||
|
VERSION := "latest"
|
||||||
|
IMG_NAME := "darkalex17/managarr"
|
||||||
|
IMAGE := "{{IMG_NAME}}:{{VERSION}}"
|
||||||
|
|
||||||
|
|
||||||
|
# List all recipes
|
||||||
|
default:
|
||||||
|
@just --list
|
||||||
|
|
||||||
|
# Format all files
|
||||||
|
[group: 'style']
|
||||||
|
fmt:
|
||||||
|
@cargo fmt --all
|
||||||
|
|
||||||
|
alias clippy := lint
|
||||||
|
# Run Clippy to inspect all files
|
||||||
|
[group: 'style']
|
||||||
|
lint:
|
||||||
|
@cargo clippy --all
|
||||||
|
|
||||||
|
alias clippy-fix := lint-fix
|
||||||
|
# Automatically fix clippy issues where possible
|
||||||
|
[group: 'style']
|
||||||
|
lint-fix:
|
||||||
|
@cargo fix
|
||||||
|
|
||||||
|
# Analyze the project for unsafe usage
|
||||||
|
[group: 'style']
|
||||||
|
@analyze:
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
cargo geiger -h > /dev/null 2>&1 | cargo install cargo-geiger
|
||||||
|
cargo geiger
|
||||||
|
|
||||||
|
# Run all tests
|
||||||
|
[group: 'test']
|
||||||
|
test:
|
||||||
|
@cargo test --all
|
||||||
|
|
||||||
|
# Run all tests with coverage
|
||||||
|
[group:'test']
|
||||||
|
@test-cov:
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
cargo tarpaulin -h > /dev/null 2>&1 || cargo install cargo-tarpaulin
|
||||||
|
cargo tarpaulin
|
||||||
|
|
||||||
|
# Run all doc tests
|
||||||
|
[group: 'test']
|
||||||
|
doctest:
|
||||||
|
@cargo test --all --doc
|
||||||
|
|
||||||
|
# Run all proptests
|
||||||
|
[group: 'test']
|
||||||
|
proptest:
|
||||||
|
@cargo test proptest
|
||||||
|
|
||||||
|
alias test-snapshots := snapshot-tests
|
||||||
|
# Run all snapshot tests
|
||||||
|
[group: 'test']
|
||||||
|
snapshot-tests:
|
||||||
|
@cargo test snapshot
|
||||||
|
|
||||||
|
alias review := snapshot-review
|
||||||
|
# Review snapshot test changes
|
||||||
|
[group: 'test']
|
||||||
|
@snapshot-review:
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
cargo insta -h > /dev/null 2>&1 || cargo install cargo-insta
|
||||||
|
cargo insta review
|
||||||
|
|
||||||
|
alias clean-orphaned-snapshots := snapshot-delete-unreferenced
|
||||||
|
# Delete any unreferenced snapshots
|
||||||
|
[group: 'test']
|
||||||
|
@snapshot-delete-unreferenced:
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
cargo insta -h > /dev/null 2>&1 || cargo install cargo-insta
|
||||||
|
cargo insta test --unreferenced=delete
|
||||||
|
|
||||||
|
# Build and run the binary for the current system
|
||||||
|
run:
|
||||||
|
@cargo run
|
||||||
|
|
||||||
|
# Build the project for the current system architecture
|
||||||
|
[group: 'build']
|
||||||
|
[arg('build_type', pattern="debug|release")]
|
||||||
|
build build_type='debug':
|
||||||
|
@cargo build {{ if build_type == "release" { "--release" } else { "" } }}
|
||||||
|
|
||||||
|
# Build the docker image
|
||||||
|
[group: 'build']
|
||||||
|
build-docker:
|
||||||
|
@DOCKER_BUILDKIT=1 docker build --rm -t {{IMAGE}}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "enum_display_style_derive"
|
name = "enum_display_style_derive"
|
||||||
version = "0.1.0"
|
version = "0.6.1"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
authors = ["Alex Clarke <alex.j.tusa@gmail.com>"]
|
authors = ["Alex Clarke <alex.j.tusa@gmail.com>"]
|
||||||
description = "A proc-macro to derive a `Display` and `FromStr` implementation for enums with a `style` attribute."
|
description = "A proc-macro to derive a `Display` and `FromStr` implementation for enums with a `style` attribute."
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "validate_theme_derive"
|
name = "validate_theme_derive"
|
||||||
version = "0.1.0"
|
version = "0.6.1"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
authors = ["Alex Clarke <alex.j.tusa@gmail.com>"]
|
authors = ["Alex Clarke <alex.j.tusa@gmail.com>"]
|
||||||
description = "A proc-macro to validate a theme."
|
description = "A proc-macro to validate a theme."
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
# Seeds for failure cases proptest has generated in the past. It is
|
||||||
|
# automatically read and these particular cases re-run before any
|
||||||
|
# novel cases are generated.
|
||||||
|
#
|
||||||
|
# It is recommended to check this file in to source control so that
|
||||||
|
# everyone who runs the test benefits from these saved cases.
|
||||||
|
cc 56330c025ad79db641d0eb9f429ab74e95822e1fb015b58f0e158ea674cd42a1 # shrinks to list_size = 1, page_ops = 1
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
# Seeds for failure cases proptest has generated in the past. It is
|
||||||
|
# automatically read and these particular cases re-run before any
|
||||||
|
# novel cases are generated.
|
||||||
|
#
|
||||||
|
# It is recommended to check this file in to source control so that
|
||||||
|
# everyone who runs the test benefits from these saved cases.
|
||||||
|
cc fb4b58aa3015a125fc33a78dfaf27981db4191247151b327a351fc445e07c231 # shrinks to input = "j"
|
||||||
|
cc d6ec17d4d3f635f0a095ade650a316d26abc1f9fe2b6d9cf67bf2f8b4ebedb60 # shrinks to backspace_count = 0
|
||||||
|
cc cd46ee46e18cf86c940fb89c7206f0b482909880b8f2eabe3dd20682b9912c8a # shrinks to input = "h"
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
# Seeds for failure cases proptest has generated in the past. It is
|
||||||
|
# automatically read and these particular cases re-run before any
|
||||||
|
# novel cases are generated.
|
||||||
|
#
|
||||||
|
# It is recommended to check this file in to source control so that
|
||||||
|
# everyone who runs the test benefits from these saved cases.
|
||||||
|
cc 24ae243412a324cb46c36cb4f629ddd4c9326b1479d1186d9b5545ac5e86dbba # shrinks to num_scroll_attempts = 0
|
||||||
|
cc c06a1cc1e4740b2498c50d7be64715bf09ef3ac4cf3bb3642f960578a3e06c74 # shrinks to is_loading = false, num_items = 1
|
||||||
|
cc 930207899afea2d389c7fa3974e31c2eb1803e71bcbd8179246c795903905ec7 # shrinks to parent_width = 20, parent_height = 12, percent_x = 1, percent_y = 1
|
||||||
+35
-33
@@ -7,12 +7,12 @@ mod tests {
|
|||||||
use serial_test::serial;
|
use serial_test::serial;
|
||||||
use tokio::sync::mpsc;
|
use tokio::sync::mpsc;
|
||||||
|
|
||||||
use crate::app::{interpolate_env_vars, App, AppConfig, Data, ServarrConfig};
|
use crate::app::{App, AppConfig, Data, ServarrConfig, interpolate_env_vars};
|
||||||
use crate::models::servarr_data::radarr::radarr_data::{ActiveRadarrBlock, RadarrData};
|
use crate::models::servarr_data::radarr::radarr_data::{ActiveRadarrBlock, RadarrData};
|
||||||
use crate::models::servarr_data::sonarr::sonarr_data::{ActiveSonarrBlock, SonarrData};
|
use crate::models::servarr_data::sonarr::sonarr_data::{ActiveSonarrBlock, SonarrData};
|
||||||
use crate::models::{HorizontallyScrollableText, TabRoute};
|
use crate::models::{HorizontallyScrollableText, TabRoute};
|
||||||
use crate::network::radarr_network::RadarrEvent;
|
|
||||||
use crate::network::NetworkEvent;
|
use crate::network::NetworkEvent;
|
||||||
|
use crate::network::radarr_network::RadarrEvent;
|
||||||
use tokio_util::sync::CancellationToken;
|
use tokio_util::sync::CancellationToken;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -69,9 +69,9 @@ mod tests {
|
|||||||
CancellationToken::new(),
|
CancellationToken::new(),
|
||||||
);
|
);
|
||||||
|
|
||||||
assert!(app.navigation_stack.is_empty());
|
assert_is_empty!(app.navigation_stack);
|
||||||
assert_eq!(app.get_current_route(), ActiveSonarrBlock::default().into());
|
assert_eq!(app.get_current_route(), ActiveSonarrBlock::default().into());
|
||||||
assert!(app.network_tx.is_some());
|
assert_some!(app.network_tx);
|
||||||
assert!(!app.cancellation_token.is_cancelled());
|
assert!(!app.cancellation_token.is_cancelled());
|
||||||
assert!(app.is_first_render);
|
assert!(app.is_first_render);
|
||||||
assert_eq!(app.error, HorizontallyScrollableText::default());
|
assert_eq!(app.error, HorizontallyScrollableText::default());
|
||||||
@@ -91,8 +91,8 @@ mod tests {
|
|||||||
fn test_app_default() {
|
fn test_app_default() {
|
||||||
let app = App::default();
|
let app = App::default();
|
||||||
|
|
||||||
assert!(app.navigation_stack.is_empty());
|
assert_is_empty!(app.navigation_stack);
|
||||||
assert!(app.network_tx.is_none());
|
assert_none!(app.network_tx);
|
||||||
assert!(!app.cancellation_token.is_cancelled());
|
assert!(!app.cancellation_token.is_cancelled());
|
||||||
assert!(app.is_first_render);
|
assert!(app.is_first_render);
|
||||||
assert_eq!(app.error, HorizontallyScrollableText::default());
|
assert_eq!(app.error, HorizontallyScrollableText::default());
|
||||||
@@ -326,23 +326,23 @@ mod tests {
|
|||||||
fn test_app_config_default() {
|
fn test_app_config_default() {
|
||||||
let app_config = AppConfig::default();
|
let app_config = AppConfig::default();
|
||||||
|
|
||||||
assert!(app_config.radarr.is_none());
|
assert_none!(app_config.radarr);
|
||||||
assert!(app_config.sonarr.is_none());
|
assert_none!(app_config.sonarr);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_servarr_config_default() {
|
fn test_servarr_config_default() {
|
||||||
let servarr_config = ServarrConfig::default();
|
let servarr_config = ServarrConfig::default();
|
||||||
|
|
||||||
assert_eq!(servarr_config.name, None);
|
assert_none!(servarr_config.name);
|
||||||
assert_eq!(servarr_config.host, Some("localhost".to_string()));
|
assert_some_eq_x!(&servarr_config.host, "localhost");
|
||||||
assert_eq!(servarr_config.port, None);
|
assert_none!(servarr_config.port);
|
||||||
assert_eq!(servarr_config.uri, None);
|
assert_none!(servarr_config.uri);
|
||||||
assert_eq!(servarr_config.weight, None);
|
assert_none!(servarr_config.weight);
|
||||||
assert_eq!(servarr_config.api_token, Some(String::new()));
|
assert_some_eq_x!(&servarr_config.api_token, "");
|
||||||
assert_eq!(servarr_config.api_token_file, None);
|
assert_none!(servarr_config.api_token_file);
|
||||||
assert_eq!(servarr_config.ssl_cert_path, None);
|
assert_none!(servarr_config.ssl_cert_path);
|
||||||
assert_eq!(servarr_config.custom_headers, None);
|
assert_none!(servarr_config.custom_headers);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -367,11 +367,11 @@ mod tests {
|
|||||||
assert!(custom.is_object());
|
assert!(custom.is_object());
|
||||||
let obj = custom.as_object().unwrap();
|
let obj = custom.as_object().unwrap();
|
||||||
|
|
||||||
assert_eq!(obj.get("x-api-key").unwrap(), "abc123");
|
assert_some_eq_x!(obj.get("x-api-key"), "abc123");
|
||||||
assert_eq!(obj.get("header-1").unwrap(), "test");
|
assert_some_eq_x!(obj.get("header-1"), "test");
|
||||||
|
|
||||||
assert!(obj.get("X-Api-Key").is_none());
|
assert_none!(obj.get("X-Api-Key"));
|
||||||
assert!(obj.get("HEADER-1").is_none());
|
assert_none!(obj.get("HEADER-1"));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -392,7 +392,7 @@ mod tests {
|
|||||||
|
|
||||||
let config: ServarrConfig = serde_yaml::from_str(yaml_data).unwrap();
|
let config: ServarrConfig = serde_yaml::from_str(yaml_data).unwrap();
|
||||||
|
|
||||||
assert_eq!(config.host, Some("localhost".to_string()));
|
assert_some_eq_x!(&config.host, "localhost");
|
||||||
unsafe { std::env::remove_var("TEST_VAR_DESERIALIZE_OPTION") };
|
unsafe { std::env::remove_var("TEST_VAR_DESERIALIZE_OPTION") };
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -407,7 +407,7 @@ mod tests {
|
|||||||
|
|
||||||
let config: ServarrConfig = serde_yaml::from_str(yaml_data).unwrap();
|
let config: ServarrConfig = serde_yaml::from_str(yaml_data).unwrap();
|
||||||
|
|
||||||
assert_eq!(config.host, Some("www.example.com".to_string()));
|
assert_some_eq_x!(&config.host, "www.example.com");
|
||||||
unsafe { std::env::remove_var("TEST_VAR_DESERIALIZE_OPTION_NO_OVERWRITE") };
|
unsafe { std::env::remove_var("TEST_VAR_DESERIALIZE_OPTION_NO_OVERWRITE") };
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -419,7 +419,7 @@ mod tests {
|
|||||||
|
|
||||||
let config: ServarrConfig = serde_yaml::from_str(yaml_data).unwrap();
|
let config: ServarrConfig = serde_yaml::from_str(yaml_data).unwrap();
|
||||||
|
|
||||||
assert_eq!(config.port, None);
|
assert_none!(config.port);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -440,7 +440,7 @@ mod tests {
|
|||||||
|
|
||||||
let config: ServarrConfig = serde_yaml::from_str(yaml_data).unwrap();
|
let config: ServarrConfig = serde_yaml::from_str(yaml_data).unwrap();
|
||||||
|
|
||||||
assert_eq!(config.custom_headers, Some(expected_custom_headers));
|
assert_some_eq_x!(&config.custom_headers, &expected_custom_headers);
|
||||||
unsafe { std::env::remove_var("TEST_VAR_DESERIALIZE_HEADER_OPTION") };
|
unsafe { std::env::remove_var("TEST_VAR_DESERIALIZE_HEADER_OPTION") };
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -467,7 +467,7 @@ mod tests {
|
|||||||
|
|
||||||
let config: ServarrConfig = serde_yaml::from_str(yaml_data).unwrap();
|
let config: ServarrConfig = serde_yaml::from_str(yaml_data).unwrap();
|
||||||
|
|
||||||
assert_eq!(config.custom_headers, Some(expected_custom_headers));
|
assert_some_eq_x!(&config.custom_headers, &expected_custom_headers);
|
||||||
unsafe { std::env::remove_var("TEST_VAR_DESERIALIZE_HEADER_OPTION_NO_OVERWRITE") };
|
unsafe { std::env::remove_var("TEST_VAR_DESERIALIZE_HEADER_OPTION_NO_OVERWRITE") };
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -479,7 +479,7 @@ mod tests {
|
|||||||
|
|
||||||
let config: ServarrConfig = serde_yaml::from_str(yaml_data).unwrap();
|
let config: ServarrConfig = serde_yaml::from_str(yaml_data).unwrap();
|
||||||
|
|
||||||
assert_eq!(config.custom_headers, None);
|
assert_none!(config.custom_headers);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -493,7 +493,7 @@ mod tests {
|
|||||||
|
|
||||||
let config: ServarrConfig = serde_yaml::from_str(yaml_data).unwrap();
|
let config: ServarrConfig = serde_yaml::from_str(yaml_data).unwrap();
|
||||||
|
|
||||||
assert_eq!(config.port, Some(1));
|
assert_some_eq_x!(config.port, 1);
|
||||||
unsafe { std::env::remove_var("TEST_VAR_DESERIALIZE_OPTION_U16") };
|
unsafe { std::env::remove_var("TEST_VAR_DESERIALIZE_OPTION_U16") };
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -508,7 +508,7 @@ mod tests {
|
|||||||
|
|
||||||
let config: ServarrConfig = serde_yaml::from_str(yaml_data).unwrap();
|
let config: ServarrConfig = serde_yaml::from_str(yaml_data).unwrap();
|
||||||
|
|
||||||
assert_eq!(config.port, Some(1234));
|
assert_some_eq_x!(config.port, 1234);
|
||||||
unsafe { std::env::remove_var("TEST_VAR_DESERIALIZE_OPTION_U16_UNUSED") };
|
unsafe { std::env::remove_var("TEST_VAR_DESERIALIZE_OPTION_U16_UNUSED") };
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -520,9 +520,9 @@ mod tests {
|
|||||||
"#;
|
"#;
|
||||||
let result: Result<ServarrConfig, _> = serde_yaml::from_str(yaml_data);
|
let result: Result<ServarrConfig, _> = serde_yaml::from_str(yaml_data);
|
||||||
|
|
||||||
assert!(result.is_err());
|
assert_err!(&result);
|
||||||
let err = result.unwrap_err().to_string();
|
let err = result.unwrap_err().to_string();
|
||||||
assert!(err.contains("invalid digit found in string"));
|
assert_contains!(err, "invalid digit found in string");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -533,7 +533,7 @@ mod tests {
|
|||||||
|
|
||||||
let config: ServarrConfig = serde_yaml::from_str(yaml_data).unwrap();
|
let config: ServarrConfig = serde_yaml::from_str(yaml_data).unwrap();
|
||||||
|
|
||||||
assert_eq!(config.port, None);
|
assert_none!(config.port);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -597,7 +597,9 @@ mod tests {
|
|||||||
let ssl_cert_path = "/some/path".to_owned();
|
let ssl_cert_path = "/some/path".to_owned();
|
||||||
let mut custom_headers = HeaderMap::new();
|
let mut custom_headers = HeaderMap::new();
|
||||||
custom_headers.insert("X-Custom-Header", "value".parse().unwrap());
|
custom_headers.insert("X-Custom-Header", "value".parse().unwrap());
|
||||||
let expected_str = format!("ServarrConfig {{ name: Some(\"{name}\"), host: Some(\"{host}\"), port: Some({port}), uri: Some(\"{uri}\"), weight: Some({weight}), api_token: Some(\"***********\"), api_token_file: Some(\"{api_token_file}\"), ssl_cert_path: Some(\"{ssl_cert_path}\"), custom_headers: Some({{\"x-custom-header\": \"value\"}}) }}");
|
let expected_str = format!(
|
||||||
|
"ServarrConfig {{ name: Some(\"{name}\"), host: Some(\"{host}\"), port: Some({port}), uri: Some(\"{uri}\"), weight: Some({weight}), api_token: Some(\"***********\"), api_token_file: Some(\"{api_token_file}\"), ssl_cert_path: Some(\"{ssl_cert_path}\"), custom_headers: Some({{\"x-custom-header\": \"value\"}}) }}"
|
||||||
|
);
|
||||||
let servarr_config = ServarrConfig {
|
let servarr_config = ServarrConfig {
|
||||||
name: Some(name),
|
name: Some(name),
|
||||||
host: Some(host),
|
host: Some(host),
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
use crate::app::key_binding::{KeyBinding, DEFAULT_KEYBINDINGS};
|
use crate::app::App;
|
||||||
|
use crate::app::key_binding::{DEFAULT_KEYBINDINGS, KeyBinding};
|
||||||
use crate::app::radarr::radarr_context_clues::RadarrContextClueProvider;
|
use crate::app::radarr::radarr_context_clues::RadarrContextClueProvider;
|
||||||
use crate::app::sonarr::sonarr_context_clues::SonarrContextClueProvider;
|
use crate::app::sonarr::sonarr_context_clues::SonarrContextClueProvider;
|
||||||
use crate::app::App;
|
|
||||||
use crate::models::Route;
|
use crate::models::Route;
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
|||||||
+186
-190
@@ -1,239 +1,237 @@
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
use pretty_assertions::{assert_eq, assert_str_eq};
|
|
||||||
|
|
||||||
use crate::app::context_clues::{
|
use crate::app::context_clues::{
|
||||||
ContextClueProvider, ServarrContextClueProvider, BARE_POPUP_CONTEXT_CLUES,
|
BARE_POPUP_CONTEXT_CLUES, BLOCKLIST_CONTEXT_CLUES, CONFIRMATION_PROMPT_CONTEXT_CLUES,
|
||||||
BLOCKLIST_CONTEXT_CLUES, CONFIRMATION_PROMPT_CONTEXT_CLUES, DOWNLOADS_CONTEXT_CLUES,
|
ContextClueProvider, DOWNLOADS_CONTEXT_CLUES, INDEXERS_CONTEXT_CLUES,
|
||||||
INDEXERS_CONTEXT_CLUES, ROOT_FOLDERS_CONTEXT_CLUES, SERVARR_CONTEXT_CLUES,
|
ROOT_FOLDERS_CONTEXT_CLUES, SERVARR_CONTEXT_CLUES, SYSTEM_CONTEXT_CLUES,
|
||||||
SYSTEM_CONTEXT_CLUES,
|
ServarrContextClueProvider,
|
||||||
};
|
};
|
||||||
use crate::app::{key_binding::DEFAULT_KEYBINDINGS, App};
|
use crate::app::{App, key_binding::DEFAULT_KEYBINDINGS};
|
||||||
|
use crate::models::servarr_data::ActiveKeybindingBlock;
|
||||||
use crate::models::servarr_data::radarr::radarr_data::ActiveRadarrBlock;
|
use crate::models::servarr_data::radarr::radarr_data::ActiveRadarrBlock;
|
||||||
use crate::models::servarr_data::sonarr::sonarr_data::ActiveSonarrBlock;
|
use crate::models::servarr_data::sonarr::sonarr_data::ActiveSonarrBlock;
|
||||||
use crate::models::servarr_data::ActiveKeybindingBlock;
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_servarr_context_clues() {
|
fn test_servarr_context_clues() {
|
||||||
let mut servarr_context_clues_iter = SERVARR_CONTEXT_CLUES.iter();
|
let mut servarr_context_clues_iter = SERVARR_CONTEXT_CLUES.iter();
|
||||||
|
|
||||||
let (key_binding, description) = servarr_context_clues_iter.next().unwrap();
|
assert_some_eq_x!(
|
||||||
|
servarr_context_clues_iter.next(),
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.up);
|
&(DEFAULT_KEYBINDINGS.up, "scroll up")
|
||||||
assert_str_eq!(*description, "scroll up");
|
);
|
||||||
|
assert_some_eq_x!(
|
||||||
let (key_binding, description) = servarr_context_clues_iter.next().unwrap();
|
servarr_context_clues_iter.next(),
|
||||||
|
&(DEFAULT_KEYBINDINGS.down, "scroll down")
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.down);
|
);
|
||||||
assert_str_eq!(*description, "scroll down");
|
assert_some_eq_x!(
|
||||||
|
servarr_context_clues_iter.next(),
|
||||||
let (key_binding, description) = servarr_context_clues_iter.next().unwrap();
|
&(DEFAULT_KEYBINDINGS.left, "previous tab")
|
||||||
|
);
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.left);
|
assert_some_eq_x!(
|
||||||
assert_str_eq!(*description, "previous tab");
|
servarr_context_clues_iter.next(),
|
||||||
|
&(DEFAULT_KEYBINDINGS.right, "next tab")
|
||||||
let (key_binding, description) = servarr_context_clues_iter.next().unwrap();
|
);
|
||||||
|
assert_some_eq_x!(
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.right);
|
servarr_context_clues_iter.next(),
|
||||||
assert_str_eq!(*description, "next tab");
|
&(DEFAULT_KEYBINDINGS.pg_up, DEFAULT_KEYBINDINGS.pg_up.desc)
|
||||||
|
);
|
||||||
let (key_binding, description) = servarr_context_clues_iter.next().unwrap();
|
assert_some_eq_x!(
|
||||||
|
servarr_context_clues_iter.next(),
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.pg_up);
|
&(
|
||||||
assert_str_eq!(*description, DEFAULT_KEYBINDINGS.pg_up.desc);
|
DEFAULT_KEYBINDINGS.pg_down,
|
||||||
|
DEFAULT_KEYBINDINGS.pg_down.desc
|
||||||
let (key_binding, description) = servarr_context_clues_iter.next().unwrap();
|
)
|
||||||
|
);
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.pg_down);
|
assert_some_eq_x!(
|
||||||
assert_str_eq!(*description, DEFAULT_KEYBINDINGS.pg_down.desc);
|
servarr_context_clues_iter.next(),
|
||||||
|
&(
|
||||||
let (key_binding, description) = servarr_context_clues_iter.next().unwrap();
|
DEFAULT_KEYBINDINGS.next_servarr,
|
||||||
|
DEFAULT_KEYBINDINGS.next_servarr.desc
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.next_servarr);
|
)
|
||||||
assert_str_eq!(*description, DEFAULT_KEYBINDINGS.next_servarr.desc);
|
);
|
||||||
|
assert_some_eq_x!(
|
||||||
let (key_binding, description) = servarr_context_clues_iter.next().unwrap();
|
servarr_context_clues_iter.next(),
|
||||||
|
&(
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.previous_servarr);
|
DEFAULT_KEYBINDINGS.previous_servarr,
|
||||||
assert_str_eq!(*description, DEFAULT_KEYBINDINGS.previous_servarr.desc);
|
DEFAULT_KEYBINDINGS.previous_servarr.desc
|
||||||
|
)
|
||||||
let (key_binding, description) = servarr_context_clues_iter.next().unwrap();
|
);
|
||||||
|
assert_some_eq_x!(
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.quit);
|
servarr_context_clues_iter.next(),
|
||||||
assert_str_eq!(*description, DEFAULT_KEYBINDINGS.quit.desc);
|
&(DEFAULT_KEYBINDINGS.quit, DEFAULT_KEYBINDINGS.quit.desc)
|
||||||
|
);
|
||||||
let (key_binding, description) = servarr_context_clues_iter.next().unwrap();
|
assert_some_eq_x!(
|
||||||
|
servarr_context_clues_iter.next(),
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.help);
|
&(DEFAULT_KEYBINDINGS.help, DEFAULT_KEYBINDINGS.help.desc)
|
||||||
assert_str_eq!(*description, DEFAULT_KEYBINDINGS.help.desc);
|
);
|
||||||
assert_eq!(servarr_context_clues_iter.next(), None);
|
assert_none!(servarr_context_clues_iter.next());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_bare_popup_context_clues() {
|
fn test_bare_popup_context_clues() {
|
||||||
let mut bare_popup_context_clues_iter = BARE_POPUP_CONTEXT_CLUES.iter();
|
let mut bare_popup_context_clues_iter = BARE_POPUP_CONTEXT_CLUES.iter();
|
||||||
|
|
||||||
let (key_binding, description) = bare_popup_context_clues_iter.next().unwrap();
|
assert_some_eq_x!(
|
||||||
|
bare_popup_context_clues_iter.next(),
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.esc);
|
&(DEFAULT_KEYBINDINGS.esc, DEFAULT_KEYBINDINGS.esc.desc)
|
||||||
assert_str_eq!(*description, DEFAULT_KEYBINDINGS.esc.desc);
|
);
|
||||||
assert_eq!(bare_popup_context_clues_iter.next(), None);
|
assert_none!(bare_popup_context_clues_iter.next());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_downloads_context_clues() {
|
fn test_downloads_context_clues() {
|
||||||
let mut downloads_context_clues_iter = DOWNLOADS_CONTEXT_CLUES.iter();
|
let mut downloads_context_clues_iter = DOWNLOADS_CONTEXT_CLUES.iter();
|
||||||
|
|
||||||
let (key_binding, description) = downloads_context_clues_iter.next().unwrap();
|
assert_some_eq_x!(
|
||||||
|
downloads_context_clues_iter.next(),
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.refresh);
|
&(
|
||||||
assert_str_eq!(*description, DEFAULT_KEYBINDINGS.refresh.desc);
|
DEFAULT_KEYBINDINGS.refresh,
|
||||||
|
DEFAULT_KEYBINDINGS.refresh.desc
|
||||||
let (key_binding, description) = downloads_context_clues_iter.next().unwrap();
|
)
|
||||||
|
);
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.delete);
|
assert_some_eq_x!(
|
||||||
assert_str_eq!(*description, DEFAULT_KEYBINDINGS.delete.desc);
|
downloads_context_clues_iter.next(),
|
||||||
|
&(DEFAULT_KEYBINDINGS.delete, DEFAULT_KEYBINDINGS.delete.desc)
|
||||||
let (key_binding, description) = downloads_context_clues_iter.next().unwrap();
|
);
|
||||||
|
assert_some_eq_x!(
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.update);
|
downloads_context_clues_iter.next(),
|
||||||
assert_str_eq!(*description, "update downloads");
|
&(DEFAULT_KEYBINDINGS.update, "update downloads")
|
||||||
assert_eq!(downloads_context_clues_iter.next(), None);
|
);
|
||||||
|
assert_none!(downloads_context_clues_iter.next());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_blocklist_context_clues() {
|
fn test_blocklist_context_clues() {
|
||||||
let mut blocklist_context_clues_iter = BLOCKLIST_CONTEXT_CLUES.iter();
|
let mut blocklist_context_clues_iter = BLOCKLIST_CONTEXT_CLUES.iter();
|
||||||
|
|
||||||
let (key_binding, description) = blocklist_context_clues_iter.next().unwrap();
|
assert_some_eq_x!(
|
||||||
|
blocklist_context_clues_iter.next(),
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.refresh);
|
&(
|
||||||
assert_str_eq!(*description, DEFAULT_KEYBINDINGS.refresh.desc);
|
DEFAULT_KEYBINDINGS.refresh,
|
||||||
|
DEFAULT_KEYBINDINGS.refresh.desc
|
||||||
let (key_binding, description) = blocklist_context_clues_iter.next().unwrap();
|
)
|
||||||
|
);
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.sort);
|
assert_some_eq_x!(
|
||||||
assert_str_eq!(*description, DEFAULT_KEYBINDINGS.sort.desc);
|
blocklist_context_clues_iter.next(),
|
||||||
|
&(DEFAULT_KEYBINDINGS.sort, DEFAULT_KEYBINDINGS.sort.desc)
|
||||||
let (key_binding, description) = blocklist_context_clues_iter.next().unwrap();
|
);
|
||||||
|
assert_some_eq_x!(
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.submit);
|
blocklist_context_clues_iter.next(),
|
||||||
assert_str_eq!(*description, "details");
|
&(DEFAULT_KEYBINDINGS.submit, "details")
|
||||||
|
);
|
||||||
let (key_binding, description) = blocklist_context_clues_iter.next().unwrap();
|
assert_some_eq_x!(
|
||||||
|
blocklist_context_clues_iter.next(),
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.delete);
|
&(DEFAULT_KEYBINDINGS.delete, DEFAULT_KEYBINDINGS.delete.desc)
|
||||||
assert_str_eq!(*description, DEFAULT_KEYBINDINGS.delete.desc);
|
);
|
||||||
|
assert_some_eq_x!(
|
||||||
let (key_binding, description) = blocklist_context_clues_iter.next().unwrap();
|
blocklist_context_clues_iter.next(),
|
||||||
|
&(DEFAULT_KEYBINDINGS.clear, "clear blocklist")
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.clear);
|
);
|
||||||
assert_str_eq!(*description, "clear blocklist");
|
assert_none!(blocklist_context_clues_iter.next());
|
||||||
assert_eq!(blocklist_context_clues_iter.next(), None);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_confirmation_prompt_context_clues() {
|
fn test_confirmation_prompt_context_clues() {
|
||||||
let mut confirmation_prompt_context_clues_iter = CONFIRMATION_PROMPT_CONTEXT_CLUES.iter();
|
let mut confirmation_prompt_context_clues_iter = CONFIRMATION_PROMPT_CONTEXT_CLUES.iter();
|
||||||
|
|
||||||
let (key_binding, description) = confirmation_prompt_context_clues_iter.next().unwrap();
|
assert_some_eq_x!(
|
||||||
|
confirmation_prompt_context_clues_iter.next(),
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.confirm);
|
&(DEFAULT_KEYBINDINGS.confirm, "submit")
|
||||||
assert_str_eq!(*description, "submit");
|
);
|
||||||
|
assert_some_eq_x!(
|
||||||
let (key_binding, description) = confirmation_prompt_context_clues_iter.next().unwrap();
|
confirmation_prompt_context_clues_iter.next(),
|
||||||
|
&(DEFAULT_KEYBINDINGS.esc, "cancel")
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.esc);
|
);
|
||||||
assert_str_eq!(*description, "cancel");
|
assert_none!(confirmation_prompt_context_clues_iter.next());
|
||||||
assert_eq!(confirmation_prompt_context_clues_iter.next(), None);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_root_folders_context_clues() {
|
fn test_root_folders_context_clues() {
|
||||||
let mut root_folders_context_clues_iter = ROOT_FOLDERS_CONTEXT_CLUES.iter();
|
let mut root_folders_context_clues_iter = ROOT_FOLDERS_CONTEXT_CLUES.iter();
|
||||||
|
|
||||||
let (key_binding, description) = root_folders_context_clues_iter.next().unwrap();
|
assert_some_eq_x!(
|
||||||
|
root_folders_context_clues_iter.next(),
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.add);
|
&(DEFAULT_KEYBINDINGS.add, DEFAULT_KEYBINDINGS.add.desc)
|
||||||
assert_str_eq!(*description, DEFAULT_KEYBINDINGS.add.desc);
|
);
|
||||||
|
assert_some_eq_x!(
|
||||||
let (key_binding, description) = root_folders_context_clues_iter.next().unwrap();
|
root_folders_context_clues_iter.next(),
|
||||||
|
&(DEFAULT_KEYBINDINGS.delete, DEFAULT_KEYBINDINGS.delete.desc)
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.delete);
|
);
|
||||||
assert_str_eq!(*description, DEFAULT_KEYBINDINGS.delete.desc);
|
assert_some_eq_x!(
|
||||||
|
root_folders_context_clues_iter.next(),
|
||||||
let (key_binding, description) = root_folders_context_clues_iter.next().unwrap();
|
&(
|
||||||
|
DEFAULT_KEYBINDINGS.refresh,
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.refresh);
|
DEFAULT_KEYBINDINGS.refresh.desc
|
||||||
assert_str_eq!(*description, DEFAULT_KEYBINDINGS.refresh.desc);
|
)
|
||||||
assert_eq!(root_folders_context_clues_iter.next(), None);
|
);
|
||||||
|
assert_none!(root_folders_context_clues_iter.next());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_indexers_context_clues() {
|
fn test_indexers_context_clues() {
|
||||||
let mut indexers_context_clues_iter = INDEXERS_CONTEXT_CLUES.iter();
|
let mut indexers_context_clues_iter = INDEXERS_CONTEXT_CLUES.iter();
|
||||||
|
|
||||||
let (key_binding, description) = indexers_context_clues_iter.next().unwrap();
|
assert_some_eq_x!(
|
||||||
|
indexers_context_clues_iter.next(),
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.submit);
|
&(DEFAULT_KEYBINDINGS.submit, "edit indexer")
|
||||||
assert_str_eq!(*description, "edit indexer");
|
);
|
||||||
|
assert_some_eq_x!(
|
||||||
let (key_binding, description) = indexers_context_clues_iter.next().unwrap();
|
indexers_context_clues_iter.next(),
|
||||||
|
&(
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.settings);
|
DEFAULT_KEYBINDINGS.settings,
|
||||||
assert_str_eq!(*description, DEFAULT_KEYBINDINGS.settings.desc);
|
DEFAULT_KEYBINDINGS.settings.desc
|
||||||
|
)
|
||||||
let (key_binding, description) = indexers_context_clues_iter.next().unwrap();
|
);
|
||||||
|
assert_some_eq_x!(
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.delete);
|
indexers_context_clues_iter.next(),
|
||||||
assert_str_eq!(*description, DEFAULT_KEYBINDINGS.delete.desc);
|
&(DEFAULT_KEYBINDINGS.delete, DEFAULT_KEYBINDINGS.delete.desc)
|
||||||
|
);
|
||||||
let (key_binding, description) = indexers_context_clues_iter.next().unwrap();
|
assert_some_eq_x!(
|
||||||
|
indexers_context_clues_iter.next(),
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.test);
|
&(DEFAULT_KEYBINDINGS.test, "test indexer")
|
||||||
assert_str_eq!(*description, "test indexer");
|
);
|
||||||
|
assert_some_eq_x!(
|
||||||
let (key_binding, description) = indexers_context_clues_iter.next().unwrap();
|
indexers_context_clues_iter.next(),
|
||||||
|
&(DEFAULT_KEYBINDINGS.test_all, "test all indexers")
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.test_all);
|
);
|
||||||
assert_str_eq!(*description, "test all indexers");
|
assert_some_eq_x!(
|
||||||
|
indexers_context_clues_iter.next(),
|
||||||
let (key_binding, description) = indexers_context_clues_iter.next().unwrap();
|
&(
|
||||||
|
DEFAULT_KEYBINDINGS.refresh,
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.refresh);
|
DEFAULT_KEYBINDINGS.refresh.desc
|
||||||
assert_str_eq!(*description, DEFAULT_KEYBINDINGS.refresh.desc);
|
)
|
||||||
assert_eq!(indexers_context_clues_iter.next(), None);
|
);
|
||||||
|
assert_none!(indexers_context_clues_iter.next());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_system_context_clues() {
|
fn test_system_context_clues() {
|
||||||
let mut system_context_clues_iter = SYSTEM_CONTEXT_CLUES.iter();
|
let mut system_context_clues_iter = SYSTEM_CONTEXT_CLUES.iter();
|
||||||
|
|
||||||
let (key_binding, description) = system_context_clues_iter.next().unwrap();
|
assert_some_eq_x!(
|
||||||
|
system_context_clues_iter.next(),
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.tasks);
|
&(DEFAULT_KEYBINDINGS.tasks, "open tasks")
|
||||||
assert_str_eq!(*description, "open tasks");
|
);
|
||||||
|
assert_some_eq_x!(
|
||||||
let (key_binding, description) = system_context_clues_iter.next().unwrap();
|
system_context_clues_iter.next(),
|
||||||
|
&(DEFAULT_KEYBINDINGS.events, "open events")
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.events);
|
);
|
||||||
assert_str_eq!(*description, "open events");
|
assert_some_eq_x!(
|
||||||
|
system_context_clues_iter.next(),
|
||||||
let (key_binding, description) = system_context_clues_iter.next().unwrap();
|
&(DEFAULT_KEYBINDINGS.logs, "open logs")
|
||||||
|
);
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.logs);
|
assert_some_eq_x!(
|
||||||
assert_str_eq!(*description, "open logs");
|
system_context_clues_iter.next(),
|
||||||
|
&(DEFAULT_KEYBINDINGS.update, "open updates")
|
||||||
let (key_binding, description) = system_context_clues_iter.next().unwrap();
|
);
|
||||||
|
assert_some_eq_x!(
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.update);
|
system_context_clues_iter.next(),
|
||||||
assert_str_eq!(*description, "open updates");
|
&(
|
||||||
|
DEFAULT_KEYBINDINGS.refresh,
|
||||||
let (key_binding, description) = system_context_clues_iter.next().unwrap();
|
DEFAULT_KEYBINDINGS.refresh.desc
|
||||||
|
)
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.refresh);
|
);
|
||||||
assert_str_eq!(*description, DEFAULT_KEYBINDINGS.refresh.desc);
|
assert_none!(system_context_clues_iter.next());
|
||||||
assert_eq!(system_context_clues_iter.next(), None);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -243,10 +241,9 @@ mod test {
|
|||||||
|
|
||||||
let context_clues = ServarrContextClueProvider::get_context_clues(&mut app);
|
let context_clues = ServarrContextClueProvider::get_context_clues(&mut app);
|
||||||
|
|
||||||
assert!(context_clues.is_some());
|
assert_some_eq_x!(
|
||||||
assert_eq!(
|
context_clues,
|
||||||
&crate::app::radarr::radarr_context_clues::SYSTEM_TASKS_CONTEXT_CLUES,
|
&crate::app::radarr::radarr_context_clues::SYSTEM_TASKS_CONTEXT_CLUES,
|
||||||
context_clues.unwrap()
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -257,10 +254,9 @@ mod test {
|
|||||||
|
|
||||||
let context_clues = ServarrContextClueProvider::get_context_clues(&mut app);
|
let context_clues = ServarrContextClueProvider::get_context_clues(&mut app);
|
||||||
|
|
||||||
assert!(context_clues.is_some());
|
assert_some_eq_x!(
|
||||||
assert_eq!(
|
context_clues,
|
||||||
&crate::app::sonarr::sonarr_context_clues::SYSTEM_TASKS_CONTEXT_CLUES,
|
&crate::app::sonarr::sonarr_context_clues::SYSTEM_TASKS_CONTEXT_CLUES,
|
||||||
context_clues.unwrap()
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -271,6 +267,6 @@ mod test {
|
|||||||
|
|
||||||
let context_clues = ServarrContextClueProvider::get_context_clues(&mut app);
|
let context_clues = ServarrContextClueProvider::get_context_clues(&mut app);
|
||||||
|
|
||||||
assert!(context_clues.is_none());
|
assert_none!(context_clues);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ mod test {
|
|||||||
use pretty_assertions::{assert_eq, assert_str_eq};
|
use pretty_assertions::{assert_eq, assert_str_eq};
|
||||||
use rstest::rstest;
|
use rstest::rstest;
|
||||||
|
|
||||||
use crate::app::key_binding::{KeyBinding, DEFAULT_KEYBINDINGS};
|
use crate::app::key_binding::{DEFAULT_KEYBINDINGS, KeyBinding};
|
||||||
use crate::event::Key;
|
use crate::event::Key;
|
||||||
use crate::matches_key;
|
use crate::matches_key;
|
||||||
|
|
||||||
|
|||||||
+65
-34
@@ -1,4 +1,4 @@
|
|||||||
use anyhow::{anyhow, Error, Result};
|
use anyhow::{Error, Result, anyhow};
|
||||||
use colored::Colorize;
|
use colored::Colorize;
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
use log::{debug, error};
|
use log::{debug, error};
|
||||||
@@ -21,7 +21,6 @@ use crate::models::{HorizontallyScrollableText, Route, TabRoute, TabState};
|
|||||||
use crate::network::NetworkEvent;
|
use crate::network::NetworkEvent;
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
#[path = "app_tests.rs"]
|
|
||||||
mod app_tests;
|
mod app_tests;
|
||||||
pub mod context_clues;
|
pub mod context_clues;
|
||||||
pub mod key_binding;
|
pub mod key_binding;
|
||||||
@@ -57,42 +56,43 @@ impl App<'_> {
|
|||||||
let mut server_tabs = Vec::new();
|
let mut server_tabs = Vec::new();
|
||||||
|
|
||||||
if let Some(radarr_configs) = config.radarr {
|
if let Some(radarr_configs) = config.radarr {
|
||||||
let mut idx = 0;
|
let mut unnamed_idx = 0;
|
||||||
for radarr_config in radarr_configs {
|
let radarr_tabs = radarr_configs.into_iter().map(|radarr_config| {
|
||||||
let name = if let Some(name) = radarr_config.name.clone() {
|
let name = if let Some(name) = radarr_config.name.clone() {
|
||||||
name
|
name
|
||||||
} else {
|
} else {
|
||||||
idx += 1;
|
unnamed_idx += 1;
|
||||||
format!("Radarr {idx}")
|
format!("Radarr {unnamed_idx}")
|
||||||
};
|
};
|
||||||
|
|
||||||
server_tabs.push(TabRoute {
|
TabRoute {
|
||||||
title: name,
|
title: name,
|
||||||
route: ActiveRadarrBlock::Movies.into(),
|
route: ActiveRadarrBlock::Movies.into(),
|
||||||
contextual_help: None,
|
contextual_help: None,
|
||||||
config: Some(radarr_config),
|
config: Some(radarr_config),
|
||||||
});
|
}
|
||||||
}
|
});
|
||||||
|
server_tabs.extend(radarr_tabs);
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(sonarr_configs) = config.sonarr {
|
if let Some(sonarr_configs) = config.sonarr {
|
||||||
let mut idx = 0;
|
let mut unnamed_idx = 0;
|
||||||
|
let sonarr_tabs = sonarr_configs.into_iter().map(|sonarr_config| {
|
||||||
for sonarr_config in sonarr_configs {
|
|
||||||
let name = if let Some(name) = sonarr_config.name.clone() {
|
let name = if let Some(name) = sonarr_config.name.clone() {
|
||||||
name
|
name
|
||||||
} else {
|
} else {
|
||||||
idx += 1;
|
unnamed_idx += 1;
|
||||||
format!("Sonarr {idx}")
|
format!("Sonarr {unnamed_idx}")
|
||||||
};
|
};
|
||||||
|
|
||||||
server_tabs.push(TabRoute {
|
TabRoute {
|
||||||
title: name,
|
title: name,
|
||||||
route: ActiveSonarrBlock::Series.into(),
|
route: ActiveSonarrBlock::Series.into(),
|
||||||
contextual_help: None,
|
contextual_help: None,
|
||||||
config: Some(sonarr_config),
|
config: Some(sonarr_config),
|
||||||
});
|
}
|
||||||
}
|
});
|
||||||
|
server_tabs.extend(sonarr_tabs);
|
||||||
}
|
}
|
||||||
|
|
||||||
let weight_sorted_tabs = server_tabs
|
let weight_sorted_tabs = server_tabs
|
||||||
@@ -132,12 +132,12 @@ impl App<'_> {
|
|||||||
self.is_loading = true;
|
self.is_loading = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(network_tx) = &self.network_tx {
|
if let Some(network_tx) = &self.network_tx
|
||||||
if let Err(e) = network_tx.send(action).await {
|
&& let Err(e) = network_tx.send(action).await
|
||||||
self.is_loading = false;
|
{
|
||||||
error!("Failed to send event. {e:?}");
|
self.is_loading = false;
|
||||||
self.handle_error(anyhow!(e));
|
error!("Failed to send event. {e:?}");
|
||||||
}
|
self.handle_error(anyhow!(e));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -160,7 +160,10 @@ impl App<'_> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub async fn on_tick(&mut self) {
|
pub async fn on_tick(&mut self) {
|
||||||
if self.tick_count % self.tick_until_poll == 0 || self.is_routing || self.should_refresh {
|
if self.tick_count.is_multiple_of(self.tick_until_poll)
|
||||||
|
|| self.is_routing
|
||||||
|
|| self.should_refresh
|
||||||
|
{
|
||||||
match self.get_current_route() {
|
match self.get_current_route() {
|
||||||
Route::Radarr(active_radarr_block, _) => self.radarr_on_tick(active_radarr_block).await,
|
Route::Radarr(active_radarr_block, _) => self.radarr_on_tick(active_radarr_block).await,
|
||||||
Route::Sonarr(active_sonarr_block, _) => self.sonarr_on_tick(active_sonarr_block).await,
|
Route::Sonarr(active_sonarr_block, _) => self.sonarr_on_tick(active_sonarr_block).await,
|
||||||
@@ -200,10 +203,14 @@ impl App<'_> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_current_route(&self) -> Route {
|
pub fn get_current_route(&self) -> Route {
|
||||||
*self
|
*self.navigation_stack.last().unwrap_or(
|
||||||
.navigation_stack
|
&self
|
||||||
.last()
|
.server_tabs
|
||||||
.unwrap_or(&self.server_tabs.tabs.first().unwrap().route)
|
.tabs
|
||||||
|
.first()
|
||||||
|
.expect("At least one server tab must exist")
|
||||||
|
.route,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -251,6 +258,30 @@ impl App<'_> {
|
|||||||
..App::default()
|
..App::default()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn test_default_fully_populated() -> Self {
|
||||||
|
App {
|
||||||
|
data: Data {
|
||||||
|
radarr_data: RadarrData::test_default_fully_populated(),
|
||||||
|
sonarr_data: SonarrData::test_default_fully_populated(),
|
||||||
|
},
|
||||||
|
server_tabs: TabState::new(vec![
|
||||||
|
TabRoute {
|
||||||
|
title: "Radarr".to_owned(),
|
||||||
|
route: ActiveRadarrBlock::Movies.into(),
|
||||||
|
contextual_help: None,
|
||||||
|
config: Some(ServarrConfig::default()),
|
||||||
|
},
|
||||||
|
TabRoute {
|
||||||
|
title: "Sonarr".to_owned(),
|
||||||
|
route: ActiveSonarrBlock::Series.into(),
|
||||||
|
contextual_help: None,
|
||||||
|
config: Some(ServarrConfig::default()),
|
||||||
|
},
|
||||||
|
]),
|
||||||
|
..App::default()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
@@ -474,15 +505,15 @@ where
|
|||||||
|
|
||||||
fn interpolate_env_vars(s: &str) -> String {
|
fn interpolate_env_vars(s: &str) -> String {
|
||||||
let result = s.to_string();
|
let result = s.to_string();
|
||||||
let scrubbing_regex = Regex::new(r#"[\s\{\}!\$^\(\)\[\]\\\|`'"]+"#).unwrap();
|
let scrubbing_regex = Regex::new(r#"[\s{}!$^()\[\]\\|`'"]+"#).unwrap();
|
||||||
let var_regex = Regex::new(r"\$\{(.*?)\}").unwrap();
|
let var_regex = Regex::new(r"\$\{(.*?)}").unwrap();
|
||||||
|
|
||||||
var_regex
|
var_regex
|
||||||
.replace_all(s, |caps: ®ex::Captures<'_>| {
|
.replace_all(s, |caps: ®ex::Captures<'_>| {
|
||||||
if let Some(mat) = caps.get(1) {
|
if let Some(mat) = caps.get(1)
|
||||||
if let Ok(value) = std::env::var(mat.as_str()) {
|
&& let Ok(value) = std::env::var(mat.as_str())
|
||||||
return scrubbing_regex.replace_all(&value, "").to_string();
|
{
|
||||||
}
|
return scrubbing_regex.replace_all(&value, "").to_string();
|
||||||
}
|
}
|
||||||
|
|
||||||
scrubbing_regex.replace_all(&result, "").to_string()
|
scrubbing_regex.replace_all(&result, "").to_string()
|
||||||
|
|||||||
@@ -185,7 +185,7 @@ impl App<'_> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if self.tick_count % self.tick_until_poll == 0 {
|
if self.tick_count.is_multiple_of(self.tick_until_poll) {
|
||||||
self.refresh_radarr_metadata().await;
|
self.refresh_radarr_metadata().await;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
|
use crate::app::App;
|
||||||
use crate::app::context_clues::{
|
use crate::app::context_clues::{
|
||||||
ContextClue, ContextClueProvider, BARE_POPUP_CONTEXT_CLUES, CONFIRMATION_PROMPT_CONTEXT_CLUES,
|
BARE_POPUP_CONTEXT_CLUES, CONFIRMATION_PROMPT_CONTEXT_CLUES, ContextClue, ContextClueProvider,
|
||||||
};
|
};
|
||||||
use crate::app::key_binding::DEFAULT_KEYBINDINGS;
|
use crate::app::key_binding::DEFAULT_KEYBINDINGS;
|
||||||
use crate::app::App;
|
use crate::models::Route;
|
||||||
use crate::models::servarr_data::radarr::radarr_data::{
|
use crate::models::servarr_data::radarr::radarr_data::{
|
||||||
ActiveRadarrBlock, ADD_MOVIE_BLOCKS, EDIT_COLLECTION_BLOCKS, EDIT_INDEXER_BLOCKS,
|
ADD_MOVIE_BLOCKS, ActiveRadarrBlock, EDIT_COLLECTION_BLOCKS, EDIT_INDEXER_BLOCKS,
|
||||||
EDIT_MOVIE_BLOCKS, INDEXER_SETTINGS_BLOCKS, MOVIE_DETAILS_BLOCKS,
|
EDIT_MOVIE_BLOCKS, INDEXER_SETTINGS_BLOCKS, MOVIE_DETAILS_BLOCKS,
|
||||||
};
|
};
|
||||||
use crate::models::Route;
|
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
#[path = "radarr_context_clues_tests.rs"]
|
#[path = "radarr_context_clues_tests.rs"]
|
||||||
|
|||||||
@@ -1,126 +1,118 @@
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
|
use crate::app::App;
|
||||||
use crate::app::context_clues::{
|
use crate::app::context_clues::{
|
||||||
ContextClue, ContextClueProvider, BARE_POPUP_CONTEXT_CLUES, BLOCKLIST_CONTEXT_CLUES,
|
BARE_POPUP_CONTEXT_CLUES, BLOCKLIST_CONTEXT_CLUES, CONFIRMATION_PROMPT_CONTEXT_CLUES,
|
||||||
CONFIRMATION_PROMPT_CONTEXT_CLUES, DOWNLOADS_CONTEXT_CLUES, INDEXERS_CONTEXT_CLUES,
|
ContextClue, ContextClueProvider, DOWNLOADS_CONTEXT_CLUES, INDEXERS_CONTEXT_CLUES,
|
||||||
ROOT_FOLDERS_CONTEXT_CLUES, SYSTEM_CONTEXT_CLUES,
|
ROOT_FOLDERS_CONTEXT_CLUES, SYSTEM_CONTEXT_CLUES,
|
||||||
};
|
};
|
||||||
use crate::app::key_binding::DEFAULT_KEYBINDINGS;
|
use crate::app::key_binding::DEFAULT_KEYBINDINGS;
|
||||||
use crate::app::radarr::radarr_context_clues::{
|
use crate::app::radarr::radarr_context_clues::{
|
||||||
RadarrContextClueProvider, ADD_MOVIE_SEARCH_RESULTS_CONTEXT_CLUES, COLLECTIONS_CONTEXT_CLUES,
|
ADD_MOVIE_SEARCH_RESULTS_CONTEXT_CLUES, COLLECTION_DETAILS_CONTEXT_CLUES,
|
||||||
COLLECTION_DETAILS_CONTEXT_CLUES, LIBRARY_CONTEXT_CLUES, MANUAL_MOVIE_SEARCH_CONTEXT_CLUES,
|
COLLECTIONS_CONTEXT_CLUES, LIBRARY_CONTEXT_CLUES, MANUAL_MOVIE_SEARCH_CONTEXT_CLUES,
|
||||||
MOVIE_DETAILS_CONTEXT_CLUES, SYSTEM_TASKS_CONTEXT_CLUES,
|
MOVIE_DETAILS_CONTEXT_CLUES, RadarrContextClueProvider, SYSTEM_TASKS_CONTEXT_CLUES,
|
||||||
};
|
};
|
||||||
use crate::app::App;
|
|
||||||
use crate::models::servarr_data::radarr::radarr_data::{ActiveRadarrBlock, RadarrData};
|
use crate::models::servarr_data::radarr::radarr_data::{ActiveRadarrBlock, RadarrData};
|
||||||
use crate::models::servarr_data::sonarr::sonarr_data::ActiveSonarrBlock;
|
use crate::models::servarr_data::sonarr::sonarr_data::ActiveSonarrBlock;
|
||||||
use pretty_assertions::{assert_eq, assert_str_eq};
|
use pretty_assertions::assert_eq;
|
||||||
use rstest::rstest;
|
use rstest::rstest;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_library_context_clues() {
|
fn test_library_context_clues() {
|
||||||
let mut library_context_clues_iter = LIBRARY_CONTEXT_CLUES.iter();
|
let mut library_context_clues_iter = LIBRARY_CONTEXT_CLUES.iter();
|
||||||
|
|
||||||
let (key_binding, description) = library_context_clues_iter.next().unwrap();
|
assert_some_eq_x!(
|
||||||
|
library_context_clues_iter.next(),
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.add);
|
&(DEFAULT_KEYBINDINGS.add, DEFAULT_KEYBINDINGS.add.desc)
|
||||||
assert_str_eq!(*description, DEFAULT_KEYBINDINGS.add.desc);
|
);
|
||||||
|
assert_some_eq_x!(
|
||||||
let (key_binding, description) = library_context_clues_iter.next().unwrap();
|
library_context_clues_iter.next(),
|
||||||
|
&(DEFAULT_KEYBINDINGS.edit, DEFAULT_KEYBINDINGS.edit.desc)
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.edit);
|
);
|
||||||
assert_str_eq!(*description, DEFAULT_KEYBINDINGS.edit.desc);
|
assert_some_eq_x!(
|
||||||
|
library_context_clues_iter.next(),
|
||||||
let (key_binding, description) = library_context_clues_iter.next().unwrap();
|
&(
|
||||||
|
DEFAULT_KEYBINDINGS.toggle_monitoring,
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.toggle_monitoring);
|
DEFAULT_KEYBINDINGS.toggle_monitoring.desc
|
||||||
assert_str_eq!(*description, DEFAULT_KEYBINDINGS.toggle_monitoring.desc);
|
)
|
||||||
|
);
|
||||||
let (key_binding, description) = library_context_clues_iter.next().unwrap();
|
assert_some_eq_x!(
|
||||||
|
library_context_clues_iter.next(),
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.sort);
|
&(DEFAULT_KEYBINDINGS.sort, DEFAULT_KEYBINDINGS.sort.desc)
|
||||||
assert_str_eq!(*description, DEFAULT_KEYBINDINGS.sort.desc);
|
);
|
||||||
|
assert_some_eq_x!(
|
||||||
let (key_binding, description) = library_context_clues_iter.next().unwrap();
|
library_context_clues_iter.next(),
|
||||||
|
&(DEFAULT_KEYBINDINGS.delete, DEFAULT_KEYBINDINGS.delete.desc)
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.delete);
|
);
|
||||||
assert_str_eq!(*description, DEFAULT_KEYBINDINGS.delete.desc);
|
assert_some_eq_x!(
|
||||||
|
library_context_clues_iter.next(),
|
||||||
let (key_binding, description) = library_context_clues_iter.next().unwrap();
|
&(DEFAULT_KEYBINDINGS.search, DEFAULT_KEYBINDINGS.search.desc)
|
||||||
|
);
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.search);
|
assert_some_eq_x!(
|
||||||
assert_str_eq!(*description, DEFAULT_KEYBINDINGS.search.desc);
|
library_context_clues_iter.next(),
|
||||||
|
&(DEFAULT_KEYBINDINGS.filter, DEFAULT_KEYBINDINGS.filter.desc)
|
||||||
let (key_binding, description) = library_context_clues_iter.next().unwrap();
|
);
|
||||||
|
assert_some_eq_x!(
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.filter);
|
library_context_clues_iter.next(),
|
||||||
assert_str_eq!(*description, DEFAULT_KEYBINDINGS.filter.desc);
|
&(
|
||||||
|
DEFAULT_KEYBINDINGS.refresh,
|
||||||
let (key_binding, description) = library_context_clues_iter.next().unwrap();
|
DEFAULT_KEYBINDINGS.refresh.desc
|
||||||
|
)
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.refresh);
|
);
|
||||||
assert_str_eq!(*description, DEFAULT_KEYBINDINGS.refresh.desc);
|
assert_some_eq_x!(
|
||||||
|
library_context_clues_iter.next(),
|
||||||
let (key_binding, description) = library_context_clues_iter.next().unwrap();
|
&(DEFAULT_KEYBINDINGS.update, "update all")
|
||||||
|
);
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.update);
|
assert_some_eq_x!(
|
||||||
assert_str_eq!(*description, "update all");
|
library_context_clues_iter.next(),
|
||||||
|
&(DEFAULT_KEYBINDINGS.submit, "details")
|
||||||
let (key_binding, description) = library_context_clues_iter.next().unwrap();
|
);
|
||||||
|
assert_some_eq_x!(
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.submit);
|
library_context_clues_iter.next(),
|
||||||
assert_str_eq!(*description, "details");
|
&(DEFAULT_KEYBINDINGS.esc, "cancel filter")
|
||||||
|
);
|
||||||
let (key_binding, description) = library_context_clues_iter.next().unwrap();
|
assert_none!(library_context_clues_iter.next());
|
||||||
|
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.esc);
|
|
||||||
assert_str_eq!(*description, "cancel filter");
|
|
||||||
assert_eq!(library_context_clues_iter.next(), None);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_collections_context_clues() {
|
fn test_collections_context_clues() {
|
||||||
let mut collections_context_clues = COLLECTIONS_CONTEXT_CLUES.iter();
|
let mut collections_context_clues = COLLECTIONS_CONTEXT_CLUES.iter();
|
||||||
|
|
||||||
let (key_binding, description) = collections_context_clues.next().unwrap();
|
assert_some_eq_x!(
|
||||||
|
collections_context_clues.next(),
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.search);
|
&(DEFAULT_KEYBINDINGS.search, DEFAULT_KEYBINDINGS.search.desc)
|
||||||
assert_str_eq!(*description, DEFAULT_KEYBINDINGS.search.desc);
|
);
|
||||||
|
assert_some_eq_x!(
|
||||||
let (key_binding, description) = collections_context_clues.next().unwrap();
|
collections_context_clues.next(),
|
||||||
|
&(DEFAULT_KEYBINDINGS.edit, DEFAULT_KEYBINDINGS.edit.desc)
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.edit);
|
);
|
||||||
assert_str_eq!(*description, DEFAULT_KEYBINDINGS.edit.desc);
|
assert_some_eq_x!(
|
||||||
|
collections_context_clues.next(),
|
||||||
let (key_binding, description) = collections_context_clues.next().unwrap();
|
&(DEFAULT_KEYBINDINGS.sort, DEFAULT_KEYBINDINGS.sort.desc)
|
||||||
|
);
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.sort);
|
assert_some_eq_x!(
|
||||||
assert_str_eq!(*description, DEFAULT_KEYBINDINGS.sort.desc);
|
collections_context_clues.next(),
|
||||||
|
&(DEFAULT_KEYBINDINGS.filter, DEFAULT_KEYBINDINGS.filter.desc)
|
||||||
let (key_binding, description) = collections_context_clues.next().unwrap();
|
);
|
||||||
|
assert_some_eq_x!(
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.filter);
|
collections_context_clues.next(),
|
||||||
assert_str_eq!(*description, DEFAULT_KEYBINDINGS.filter.desc);
|
&(
|
||||||
|
DEFAULT_KEYBINDINGS.refresh,
|
||||||
let (key_binding, description) = collections_context_clues.next().unwrap();
|
DEFAULT_KEYBINDINGS.refresh.desc
|
||||||
|
)
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.refresh);
|
);
|
||||||
assert_str_eq!(*description, DEFAULT_KEYBINDINGS.refresh.desc);
|
assert_some_eq_x!(
|
||||||
|
collections_context_clues.next(),
|
||||||
let (key_binding, description) = collections_context_clues.next().unwrap();
|
&(DEFAULT_KEYBINDINGS.update, "update all")
|
||||||
|
);
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.update);
|
assert_some_eq_x!(
|
||||||
assert_str_eq!(*description, "update all");
|
collections_context_clues.next(),
|
||||||
|
&(DEFAULT_KEYBINDINGS.submit, "details")
|
||||||
let (key_binding, description) = collections_context_clues.next().unwrap();
|
);
|
||||||
|
assert_some_eq_x!(
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.submit);
|
collections_context_clues.next(),
|
||||||
assert_str_eq!(*description, "details");
|
&(DEFAULT_KEYBINDINGS.esc, "cancel filter")
|
||||||
|
);
|
||||||
let (key_binding, description) = collections_context_clues.next().unwrap();
|
|
||||||
|
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.esc);
|
|
||||||
assert_str_eq!(*description, "cancel filter");
|
|
||||||
assert_eq!(collections_context_clues.next(), None);
|
assert_eq!(collections_context_clues.next(), None);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -128,30 +120,32 @@ mod tests {
|
|||||||
fn test_movie_details_context_clues() {
|
fn test_movie_details_context_clues() {
|
||||||
let mut movie_details_context_clues_iter = MOVIE_DETAILS_CONTEXT_CLUES.iter();
|
let mut movie_details_context_clues_iter = MOVIE_DETAILS_CONTEXT_CLUES.iter();
|
||||||
|
|
||||||
let (key_binding, description) = movie_details_context_clues_iter.next().unwrap();
|
assert_some_eq_x!(
|
||||||
|
movie_details_context_clues_iter.next(),
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.refresh);
|
&(
|
||||||
assert_str_eq!(*description, DEFAULT_KEYBINDINGS.refresh.desc);
|
DEFAULT_KEYBINDINGS.refresh,
|
||||||
|
DEFAULT_KEYBINDINGS.refresh.desc
|
||||||
let (key_binding, description) = movie_details_context_clues_iter.next().unwrap();
|
)
|
||||||
|
);
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.update);
|
assert_some_eq_x!(
|
||||||
assert_str_eq!(*description, DEFAULT_KEYBINDINGS.update.desc);
|
movie_details_context_clues_iter.next(),
|
||||||
|
&(DEFAULT_KEYBINDINGS.update, DEFAULT_KEYBINDINGS.update.desc)
|
||||||
let (key_binding, description) = movie_details_context_clues_iter.next().unwrap();
|
);
|
||||||
|
assert_some_eq_x!(
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.edit);
|
movie_details_context_clues_iter.next(),
|
||||||
assert_str_eq!(*description, DEFAULT_KEYBINDINGS.edit.desc);
|
&(DEFAULT_KEYBINDINGS.edit, DEFAULT_KEYBINDINGS.edit.desc)
|
||||||
|
);
|
||||||
let (key_binding, description) = movie_details_context_clues_iter.next().unwrap();
|
assert_some_eq_x!(
|
||||||
|
movie_details_context_clues_iter.next(),
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.auto_search);
|
&(
|
||||||
assert_str_eq!(*description, DEFAULT_KEYBINDINGS.auto_search.desc);
|
DEFAULT_KEYBINDINGS.auto_search,
|
||||||
|
DEFAULT_KEYBINDINGS.auto_search.desc
|
||||||
let (key_binding, description) = movie_details_context_clues_iter.next().unwrap();
|
)
|
||||||
|
);
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.esc);
|
assert_some_eq_x!(
|
||||||
assert_str_eq!(*description, DEFAULT_KEYBINDINGS.esc.desc);
|
movie_details_context_clues_iter.next(),
|
||||||
|
&(DEFAULT_KEYBINDINGS.esc, DEFAULT_KEYBINDINGS.esc.desc)
|
||||||
|
);
|
||||||
assert_eq!(movie_details_context_clues_iter.next(), None);
|
assert_eq!(movie_details_context_clues_iter.next(), None);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -159,41 +153,40 @@ mod tests {
|
|||||||
fn test_manual_movie_search_context_clues() {
|
fn test_manual_movie_search_context_clues() {
|
||||||
let mut manual_movie_search_context_clues_iter = MANUAL_MOVIE_SEARCH_CONTEXT_CLUES.iter();
|
let mut manual_movie_search_context_clues_iter = MANUAL_MOVIE_SEARCH_CONTEXT_CLUES.iter();
|
||||||
|
|
||||||
let (key_binding, description) = manual_movie_search_context_clues_iter.next().unwrap();
|
assert_some_eq_x!(
|
||||||
|
manual_movie_search_context_clues_iter.next(),
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.refresh);
|
&(
|
||||||
assert_str_eq!(*description, DEFAULT_KEYBINDINGS.refresh.desc);
|
DEFAULT_KEYBINDINGS.refresh,
|
||||||
|
DEFAULT_KEYBINDINGS.refresh.desc
|
||||||
let (key_binding, description) = manual_movie_search_context_clues_iter.next().unwrap();
|
)
|
||||||
|
);
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.update);
|
assert_some_eq_x!(
|
||||||
assert_str_eq!(*description, DEFAULT_KEYBINDINGS.update.desc);
|
manual_movie_search_context_clues_iter.next(),
|
||||||
|
&(DEFAULT_KEYBINDINGS.update, DEFAULT_KEYBINDINGS.update.desc)
|
||||||
let (key_binding, description) = manual_movie_search_context_clues_iter.next().unwrap();
|
);
|
||||||
|
assert_some_eq_x!(
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.edit);
|
manual_movie_search_context_clues_iter.next(),
|
||||||
assert_str_eq!(*description, DEFAULT_KEYBINDINGS.edit.desc);
|
&(DEFAULT_KEYBINDINGS.edit, DEFAULT_KEYBINDINGS.edit.desc)
|
||||||
|
);
|
||||||
let (key_binding, description) = manual_movie_search_context_clues_iter.next().unwrap();
|
assert_some_eq_x!(
|
||||||
|
manual_movie_search_context_clues_iter.next(),
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.sort);
|
&(DEFAULT_KEYBINDINGS.sort, DEFAULT_KEYBINDINGS.sort.desc)
|
||||||
assert_str_eq!(*description, DEFAULT_KEYBINDINGS.sort.desc);
|
);
|
||||||
|
assert_some_eq_x!(
|
||||||
let (key_binding, description) = manual_movie_search_context_clues_iter.next().unwrap();
|
manual_movie_search_context_clues_iter.next(),
|
||||||
|
&(
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.auto_search);
|
DEFAULT_KEYBINDINGS.auto_search,
|
||||||
assert_str_eq!(*description, DEFAULT_KEYBINDINGS.auto_search.desc);
|
DEFAULT_KEYBINDINGS.auto_search.desc
|
||||||
|
)
|
||||||
let (key_binding, description) = manual_movie_search_context_clues_iter.next().unwrap();
|
);
|
||||||
|
assert_some_eq_x!(
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.submit);
|
manual_movie_search_context_clues_iter.next(),
|
||||||
assert_str_eq!(*description, "details");
|
&(DEFAULT_KEYBINDINGS.submit, "details")
|
||||||
|
);
|
||||||
let (key_binding, description) = manual_movie_search_context_clues_iter.next().unwrap();
|
assert_some_eq_x!(
|
||||||
|
manual_movie_search_context_clues_iter.next(),
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.esc);
|
&(DEFAULT_KEYBINDINGS.esc, DEFAULT_KEYBINDINGS.esc.desc)
|
||||||
assert_str_eq!(*description, DEFAULT_KEYBINDINGS.esc.desc);
|
);
|
||||||
|
|
||||||
assert_eq!(manual_movie_search_context_clues_iter.next(), None);
|
assert_eq!(manual_movie_search_context_clues_iter.next(), None);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -202,15 +195,14 @@ mod tests {
|
|||||||
let mut add_movie_search_results_context_clues_iter =
|
let mut add_movie_search_results_context_clues_iter =
|
||||||
ADD_MOVIE_SEARCH_RESULTS_CONTEXT_CLUES.iter();
|
ADD_MOVIE_SEARCH_RESULTS_CONTEXT_CLUES.iter();
|
||||||
|
|
||||||
let (key_binding, description) = add_movie_search_results_context_clues_iter.next().unwrap();
|
assert_some_eq_x!(
|
||||||
|
add_movie_search_results_context_clues_iter.next(),
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.submit);
|
&(DEFAULT_KEYBINDINGS.submit, "details")
|
||||||
assert_str_eq!(*description, "details");
|
);
|
||||||
|
assert_some_eq_x!(
|
||||||
let (key_binding, description) = add_movie_search_results_context_clues_iter.next().unwrap();
|
add_movie_search_results_context_clues_iter.next(),
|
||||||
|
&(DEFAULT_KEYBINDINGS.esc, "edit search")
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.esc);
|
);
|
||||||
assert_str_eq!(*description, "edit search");
|
|
||||||
assert_eq!(add_movie_search_results_context_clues_iter.next(), None);
|
assert_eq!(add_movie_search_results_context_clues_iter.next(), None);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -218,15 +210,14 @@ mod tests {
|
|||||||
fn test_system_tasks_context_clues() {
|
fn test_system_tasks_context_clues() {
|
||||||
let mut system_tasks_context_clues_iter = SYSTEM_TASKS_CONTEXT_CLUES.iter();
|
let mut system_tasks_context_clues_iter = SYSTEM_TASKS_CONTEXT_CLUES.iter();
|
||||||
|
|
||||||
let (key_binding, description) = system_tasks_context_clues_iter.next().unwrap();
|
assert_some_eq_x!(
|
||||||
|
system_tasks_context_clues_iter.next(),
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.submit);
|
&(DEFAULT_KEYBINDINGS.submit, "start task")
|
||||||
assert_str_eq!(*description, "start task");
|
);
|
||||||
|
assert_some_eq_x!(
|
||||||
let (key_binding, description) = system_tasks_context_clues_iter.next().unwrap();
|
system_tasks_context_clues_iter.next(),
|
||||||
|
&(DEFAULT_KEYBINDINGS.esc, DEFAULT_KEYBINDINGS.esc.desc)
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.esc);
|
);
|
||||||
assert_str_eq!(*description, DEFAULT_KEYBINDINGS.esc.desc);
|
|
||||||
assert_eq!(system_tasks_context_clues_iter.next(), None);
|
assert_eq!(system_tasks_context_clues_iter.next(), None);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -234,20 +225,18 @@ mod tests {
|
|||||||
fn test_collection_details_context_clues() {
|
fn test_collection_details_context_clues() {
|
||||||
let mut collection_details_context_clues_iter = COLLECTION_DETAILS_CONTEXT_CLUES.iter();
|
let mut collection_details_context_clues_iter = COLLECTION_DETAILS_CONTEXT_CLUES.iter();
|
||||||
|
|
||||||
let (key_binding, description) = collection_details_context_clues_iter.next().unwrap();
|
assert_some_eq_x!(
|
||||||
|
collection_details_context_clues_iter.next(),
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.submit);
|
&(DEFAULT_KEYBINDINGS.submit, "show overview/add movie")
|
||||||
assert_str_eq!(*description, "show overview/add movie");
|
);
|
||||||
|
assert_some_eq_x!(
|
||||||
let (key_binding, description) = collection_details_context_clues_iter.next().unwrap();
|
collection_details_context_clues_iter.next(),
|
||||||
|
&(DEFAULT_KEYBINDINGS.edit, "edit collection")
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.edit);
|
);
|
||||||
assert_str_eq!(*description, "edit collection");
|
assert_some_eq_x!(
|
||||||
|
collection_details_context_clues_iter.next(),
|
||||||
let (key_binding, description) = collection_details_context_clues_iter.next().unwrap();
|
&(DEFAULT_KEYBINDINGS.esc, DEFAULT_KEYBINDINGS.esc.desc)
|
||||||
|
);
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.esc);
|
|
||||||
assert_str_eq!(*description, DEFAULT_KEYBINDINGS.esc.desc);
|
|
||||||
assert_eq!(collection_details_context_clues_iter.next(), None);
|
assert_eq!(collection_details_context_clues_iter.next(), None);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -283,8 +272,7 @@ mod tests {
|
|||||||
|
|
||||||
let context_clues = RadarrContextClueProvider::get_context_clues(&mut app);
|
let context_clues = RadarrContextClueProvider::get_context_clues(&mut app);
|
||||||
|
|
||||||
assert!(context_clues.is_some());
|
assert_some_eq_x!(context_clues, &BARE_POPUP_CONTEXT_CLUES);
|
||||||
assert_eq!(&BARE_POPUP_CONTEXT_CLUES, context_clues.unwrap());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[rstest]
|
#[rstest]
|
||||||
@@ -306,8 +294,7 @@ mod tests {
|
|||||||
|
|
||||||
let context_clues = RadarrContextClueProvider::get_context_clues(&mut app);
|
let context_clues = RadarrContextClueProvider::get_context_clues(&mut app);
|
||||||
|
|
||||||
assert!(context_clues.is_some());
|
assert_some_eq_x!(context_clues, expected_context_clues);
|
||||||
assert_eq!(expected_context_clues, context_clues.unwrap());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[rstest]
|
#[rstest]
|
||||||
@@ -329,8 +316,7 @@ mod tests {
|
|||||||
|
|
||||||
let context_clues = RadarrContextClueProvider::get_context_clues(&mut app);
|
let context_clues = RadarrContextClueProvider::get_context_clues(&mut app);
|
||||||
|
|
||||||
assert!(context_clues.is_some());
|
assert_some_eq_x!(context_clues, &CONFIRMATION_PROMPT_CONTEXT_CLUES);
|
||||||
assert_eq!(&CONFIRMATION_PROMPT_CONTEXT_CLUES, context_clues.unwrap());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[rstest]
|
#[rstest]
|
||||||
@@ -352,8 +338,7 @@ mod tests {
|
|||||||
|
|
||||||
let context_clues = RadarrContextClueProvider::get_context_clues(&mut app);
|
let context_clues = RadarrContextClueProvider::get_context_clues(&mut app);
|
||||||
|
|
||||||
assert!(context_clues.is_some());
|
assert_some_eq_x!(context_clues, &CONFIRMATION_PROMPT_CONTEXT_CLUES);
|
||||||
assert_eq!(&CONFIRMATION_PROMPT_CONTEXT_CLUES, context_clues.unwrap());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[rstest]
|
#[rstest]
|
||||||
@@ -379,8 +364,7 @@ mod tests {
|
|||||||
|
|
||||||
let context_clues = RadarrContextClueProvider::get_context_clues(&mut app);
|
let context_clues = RadarrContextClueProvider::get_context_clues(&mut app);
|
||||||
|
|
||||||
assert!(context_clues.is_some());
|
assert_some_eq_x!(context_clues, &CONFIRMATION_PROMPT_CONTEXT_CLUES);
|
||||||
assert_eq!(&CONFIRMATION_PROMPT_CONTEXT_CLUES, context_clues.unwrap());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[rstest]
|
#[rstest]
|
||||||
@@ -405,8 +389,7 @@ mod tests {
|
|||||||
|
|
||||||
let context_clues = RadarrContextClueProvider::get_context_clues(&mut app);
|
let context_clues = RadarrContextClueProvider::get_context_clues(&mut app);
|
||||||
|
|
||||||
assert!(context_clues.is_some());
|
assert_some_eq_x!(context_clues, &CONFIRMATION_PROMPT_CONTEXT_CLUES);
|
||||||
assert_eq!(&CONFIRMATION_PROMPT_CONTEXT_CLUES, context_clues.unwrap());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[rstest]
|
#[rstest]
|
||||||
@@ -428,8 +411,7 @@ mod tests {
|
|||||||
|
|
||||||
let context_clues = RadarrContextClueProvider::get_context_clues(&mut app);
|
let context_clues = RadarrContextClueProvider::get_context_clues(&mut app);
|
||||||
|
|
||||||
assert!(context_clues.is_some());
|
assert_some_eq_x!(context_clues, &CONFIRMATION_PROMPT_CONTEXT_CLUES);
|
||||||
assert_eq!(&CONFIRMATION_PROMPT_CONTEXT_CLUES, context_clues.unwrap());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[rstest]
|
#[rstest]
|
||||||
@@ -446,11 +428,7 @@ mod tests {
|
|||||||
|
|
||||||
let context_clues = RadarrContextClueProvider::get_context_clues(&mut app);
|
let context_clues = RadarrContextClueProvider::get_context_clues(&mut app);
|
||||||
|
|
||||||
assert!(context_clues.is_some());
|
assert_some_eq_x!(context_clues, &ADD_MOVIE_SEARCH_RESULTS_CONTEXT_CLUES);
|
||||||
assert_eq!(
|
|
||||||
&ADD_MOVIE_SEARCH_RESULTS_CONTEXT_CLUES,
|
|
||||||
context_clues.unwrap()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -461,8 +439,7 @@ mod tests {
|
|||||||
|
|
||||||
let context_clues = RadarrContextClueProvider::get_context_clues(&mut app);
|
let context_clues = RadarrContextClueProvider::get_context_clues(&mut app);
|
||||||
|
|
||||||
assert!(context_clues.is_some());
|
assert_some_eq_x!(context_clues, &COLLECTION_DETAILS_CONTEXT_CLUES);
|
||||||
assert_eq!(&COLLECTION_DETAILS_CONTEXT_CLUES, context_clues.unwrap());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -474,8 +451,7 @@ mod tests {
|
|||||||
|
|
||||||
let context_clues = RadarrContextClueProvider::get_context_clues(&mut app);
|
let context_clues = RadarrContextClueProvider::get_context_clues(&mut app);
|
||||||
|
|
||||||
assert!(context_clues.is_some());
|
assert_some_eq_x!(context_clues, &SYSTEM_TASKS_CONTEXT_CLUES);
|
||||||
assert_eq!(&SYSTEM_TASKS_CONTEXT_CLUES, context_clues.unwrap());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[rstest]
|
#[rstest]
|
||||||
@@ -498,7 +474,6 @@ mod tests {
|
|||||||
|
|
||||||
let context_clues = RadarrContextClueProvider::get_context_clues(&mut app);
|
let context_clues = RadarrContextClueProvider::get_context_clues(&mut app);
|
||||||
|
|
||||||
assert!(context_clues.is_some());
|
assert_some_eq_x!(context_clues, expected_context_clues);
|
||||||
assert_eq!(expected_context_clues, context_clues.unwrap());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,15 +3,15 @@ mod tests {
|
|||||||
use pretty_assertions::assert_eq;
|
use pretty_assertions::assert_eq;
|
||||||
use tokio::sync::mpsc;
|
use tokio::sync::mpsc;
|
||||||
|
|
||||||
use crate::app::radarr::ActiveRadarrBlock;
|
|
||||||
use crate::app::App;
|
use crate::app::App;
|
||||||
|
use crate::app::radarr::ActiveRadarrBlock;
|
||||||
use crate::models::radarr_models::{
|
use crate::models::radarr_models::{
|
||||||
AddMovieBody, AddMovieOptions, Collection, CollectionMovie, Credit, Movie, RadarrRelease,
|
AddMovieBody, AddMovieOptions, Collection, CollectionMovie, Credit, Movie, RadarrRelease,
|
||||||
};
|
};
|
||||||
use crate::models::servarr_data::radarr::modals::MovieDetailsModal;
|
use crate::models::servarr_data::radarr::modals::MovieDetailsModal;
|
||||||
use crate::models::servarr_models::Indexer;
|
use crate::models::servarr_models::Indexer;
|
||||||
use crate::network::radarr_network::RadarrEvent;
|
|
||||||
use crate::network::NetworkEvent;
|
use crate::network::NetworkEvent;
|
||||||
|
use crate::network::radarr_network::RadarrEvent;
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn test_dispatch_by_blocklist_block() {
|
async fn test_dispatch_by_blocklist_block() {
|
||||||
|
|||||||
+10
-11
@@ -94,16 +94,15 @@ impl App<'_> {
|
|||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
ActiveSonarrBlock::ManualEpisodeSearch => {
|
ActiveSonarrBlock::ManualEpisodeSearch => {
|
||||||
if let Some(season_details_modal) = self.data.sonarr_data.season_details_modal.as_ref() {
|
if let Some(season_details_modal) = self.data.sonarr_data.season_details_modal.as_ref()
|
||||||
if let Some(episode_details_modal) = season_details_modal.episode_details_modal.as_ref() {
|
&& let Some(episode_details_modal) = season_details_modal.episode_details_modal.as_ref()
|
||||||
if episode_details_modal.episode_releases.is_empty() {
|
&& episode_details_modal.episode_releases.is_empty()
|
||||||
self
|
{
|
||||||
.dispatch_network_event(
|
self
|
||||||
SonarrEvent::GetEpisodeReleases(self.extract_episode_id().await).into(),
|
.dispatch_network_event(
|
||||||
)
|
SonarrEvent::GetEpisodeReleases(self.extract_episode_id().await).into(),
|
||||||
.await;
|
)
|
||||||
}
|
.await;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ActiveSonarrBlock::Downloads => {
|
ActiveSonarrBlock::Downloads => {
|
||||||
@@ -215,7 +214,7 @@ impl App<'_> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if self.tick_count % self.tick_until_poll == 0 {
|
if self.tick_count.is_multiple_of(self.tick_until_poll) {
|
||||||
self.refresh_sonarr_metadata().await;
|
self.refresh_sonarr_metadata().await;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
use crate::app::context_clues::{
|
use crate::app::context_clues::{
|
||||||
ContextClueProvider, BARE_POPUP_CONTEXT_CLUES, CONFIRMATION_PROMPT_CONTEXT_CLUES,
|
BARE_POPUP_CONTEXT_CLUES, CONFIRMATION_PROMPT_CONTEXT_CLUES, ContextClueProvider,
|
||||||
};
|
};
|
||||||
use crate::app::{context_clues::ContextClue, key_binding::DEFAULT_KEYBINDINGS, App};
|
use crate::app::{App, context_clues::ContextClue, key_binding::DEFAULT_KEYBINDINGS};
|
||||||
|
use crate::models::Route;
|
||||||
use crate::models::servarr_data::sonarr::sonarr_data::{
|
use crate::models::servarr_data::sonarr::sonarr_data::{
|
||||||
ActiveSonarrBlock, ADD_SERIES_BLOCKS, EDIT_INDEXER_BLOCKS, EDIT_SERIES_BLOCKS,
|
ADD_SERIES_BLOCKS, ActiveSonarrBlock, EDIT_INDEXER_BLOCKS, EDIT_SERIES_BLOCKS,
|
||||||
EPISODE_DETAILS_BLOCKS, INDEXER_SETTINGS_BLOCKS, SEASON_DETAILS_BLOCKS, SERIES_DETAILS_BLOCKS,
|
EPISODE_DETAILS_BLOCKS, INDEXER_SETTINGS_BLOCKS, SEASON_DETAILS_BLOCKS, SERIES_DETAILS_BLOCKS,
|
||||||
};
|
};
|
||||||
use crate::models::Route;
|
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
#[path = "sonarr_context_clues_tests.rs"]
|
#[path = "sonarr_context_clues_tests.rs"]
|
||||||
|
|||||||
@@ -1,14 +1,15 @@
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use crate::app::context_clues::{
|
use crate::app::context_clues::{
|
||||||
ContextClue, ContextClueProvider, BARE_POPUP_CONTEXT_CLUES, BLOCKLIST_CONTEXT_CLUES,
|
BARE_POPUP_CONTEXT_CLUES, BLOCKLIST_CONTEXT_CLUES, CONFIRMATION_PROMPT_CONTEXT_CLUES,
|
||||||
CONFIRMATION_PROMPT_CONTEXT_CLUES, DOWNLOADS_CONTEXT_CLUES, INDEXERS_CONTEXT_CLUES,
|
ContextClue, ContextClueProvider, DOWNLOADS_CONTEXT_CLUES, INDEXERS_CONTEXT_CLUES,
|
||||||
ROOT_FOLDERS_CONTEXT_CLUES, SYSTEM_CONTEXT_CLUES,
|
ROOT_FOLDERS_CONTEXT_CLUES, SYSTEM_CONTEXT_CLUES,
|
||||||
};
|
};
|
||||||
use crate::app::sonarr::sonarr_context_clues::{
|
use crate::app::sonarr::sonarr_context_clues::{
|
||||||
SonarrContextClueProvider, SELECTABLE_EPISODE_DETAILS_CONTEXT_CLUES,
|
SELECTABLE_EPISODE_DETAILS_CONTEXT_CLUES, SonarrContextClueProvider,
|
||||||
};
|
};
|
||||||
use crate::app::{
|
use crate::app::{
|
||||||
|
App,
|
||||||
key_binding::DEFAULT_KEYBINDINGS,
|
key_binding::DEFAULT_KEYBINDINGS,
|
||||||
sonarr::sonarr_context_clues::{
|
sonarr::sonarr_context_clues::{
|
||||||
ADD_SERIES_SEARCH_RESULTS_CONTEXT_CLUES, EPISODE_DETAILS_CONTEXT_CLUES,
|
ADD_SERIES_SEARCH_RESULTS_CONTEXT_CLUES, EPISODE_DETAILS_CONTEXT_CLUES,
|
||||||
@@ -17,12 +18,10 @@ mod tests {
|
|||||||
SEASON_HISTORY_CONTEXT_CLUES, SERIES_CONTEXT_CLUES, SERIES_DETAILS_CONTEXT_CLUES,
|
SEASON_HISTORY_CONTEXT_CLUES, SERIES_CONTEXT_CLUES, SERIES_DETAILS_CONTEXT_CLUES,
|
||||||
SERIES_HISTORY_CONTEXT_CLUES, SYSTEM_TASKS_CONTEXT_CLUES,
|
SERIES_HISTORY_CONTEXT_CLUES, SYSTEM_TASKS_CONTEXT_CLUES,
|
||||||
},
|
},
|
||||||
App,
|
|
||||||
};
|
};
|
||||||
use crate::models::servarr_data::radarr::radarr_data::ActiveRadarrBlock;
|
use crate::models::servarr_data::radarr::radarr_data::ActiveRadarrBlock;
|
||||||
use crate::models::servarr_data::sonarr::modals::{EpisodeDetailsModal, SeasonDetailsModal};
|
use crate::models::servarr_data::sonarr::modals::{EpisodeDetailsModal, SeasonDetailsModal};
|
||||||
use crate::models::servarr_data::sonarr::sonarr_data::{ActiveSonarrBlock, SonarrData};
|
use crate::models::servarr_data::sonarr::sonarr_data::{ActiveSonarrBlock, SonarrData};
|
||||||
use pretty_assertions::{assert_eq, assert_str_eq};
|
|
||||||
use rstest::rstest;
|
use rstest::rstest;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -30,417 +29,422 @@ mod tests {
|
|||||||
let mut add_series_search_results_context_clues_iter =
|
let mut add_series_search_results_context_clues_iter =
|
||||||
ADD_SERIES_SEARCH_RESULTS_CONTEXT_CLUES.iter();
|
ADD_SERIES_SEARCH_RESULTS_CONTEXT_CLUES.iter();
|
||||||
|
|
||||||
let (key_binding, description) = add_series_search_results_context_clues_iter.next().unwrap();
|
assert_some_eq_x!(
|
||||||
|
add_series_search_results_context_clues_iter.next(),
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.submit);
|
&(DEFAULT_KEYBINDINGS.submit, "details")
|
||||||
assert_str_eq!(*description, "details");
|
);
|
||||||
|
assert_some_eq_x!(
|
||||||
let (key_binding, description) = add_series_search_results_context_clues_iter.next().unwrap();
|
add_series_search_results_context_clues_iter.next(),
|
||||||
|
&(DEFAULT_KEYBINDINGS.esc, "edit search")
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.esc);
|
);
|
||||||
assert_str_eq!(*description, "edit search");
|
assert_none!(add_series_search_results_context_clues_iter.next());
|
||||||
assert_eq!(add_series_search_results_context_clues_iter.next(), None);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_series_context_clues() {
|
fn test_series_context_clues() {
|
||||||
let mut series_context_clues_iter = SERIES_CONTEXT_CLUES.iter();
|
let mut series_context_clues_iter = SERIES_CONTEXT_CLUES.iter();
|
||||||
|
|
||||||
let (key_binding, description) = series_context_clues_iter.next().unwrap();
|
assert_some_eq_x!(
|
||||||
|
series_context_clues_iter.next(),
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.add);
|
&(DEFAULT_KEYBINDINGS.add, DEFAULT_KEYBINDINGS.add.desc)
|
||||||
assert_str_eq!(*description, DEFAULT_KEYBINDINGS.add.desc);
|
);
|
||||||
|
assert_some_eq_x!(
|
||||||
let (key_binding, description) = series_context_clues_iter.next().unwrap();
|
series_context_clues_iter.next(),
|
||||||
|
&(DEFAULT_KEYBINDINGS.edit, DEFAULT_KEYBINDINGS.edit.desc)
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.edit);
|
);
|
||||||
assert_str_eq!(*description, DEFAULT_KEYBINDINGS.edit.desc);
|
assert_some_eq_x!(
|
||||||
|
series_context_clues_iter.next(),
|
||||||
let (key_binding, description) = series_context_clues_iter.next().unwrap();
|
&(
|
||||||
|
DEFAULT_KEYBINDINGS.toggle_monitoring,
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.toggle_monitoring);
|
DEFAULT_KEYBINDINGS.toggle_monitoring.desc
|
||||||
assert_str_eq!(*description, DEFAULT_KEYBINDINGS.toggle_monitoring.desc);
|
)
|
||||||
|
);
|
||||||
let (key_binding, description) = series_context_clues_iter.next().unwrap();
|
assert_some_eq_x!(
|
||||||
|
series_context_clues_iter.next(),
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.sort);
|
&(DEFAULT_KEYBINDINGS.sort, DEFAULT_KEYBINDINGS.sort.desc)
|
||||||
assert_str_eq!(*description, DEFAULT_KEYBINDINGS.sort.desc);
|
);
|
||||||
|
assert_some_eq_x!(
|
||||||
let (key_binding, description) = series_context_clues_iter.next().unwrap();
|
series_context_clues_iter.next(),
|
||||||
|
&(DEFAULT_KEYBINDINGS.delete, DEFAULT_KEYBINDINGS.delete.desc)
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.delete);
|
);
|
||||||
assert_str_eq!(*description, DEFAULT_KEYBINDINGS.delete.desc);
|
assert_some_eq_x!(
|
||||||
|
series_context_clues_iter.next(),
|
||||||
let (key_binding, description) = series_context_clues_iter.next().unwrap();
|
&(DEFAULT_KEYBINDINGS.search, DEFAULT_KEYBINDINGS.search.desc)
|
||||||
|
);
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.search);
|
assert_some_eq_x!(
|
||||||
assert_str_eq!(*description, DEFAULT_KEYBINDINGS.search.desc);
|
series_context_clues_iter.next(),
|
||||||
|
&(DEFAULT_KEYBINDINGS.filter, DEFAULT_KEYBINDINGS.filter.desc)
|
||||||
let (key_binding, description) = series_context_clues_iter.next().unwrap();
|
);
|
||||||
|
assert_some_eq_x!(
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.filter);
|
series_context_clues_iter.next(),
|
||||||
assert_str_eq!(*description, DEFAULT_KEYBINDINGS.filter.desc);
|
&(
|
||||||
|
DEFAULT_KEYBINDINGS.refresh,
|
||||||
let (key_binding, description) = series_context_clues_iter.next().unwrap();
|
DEFAULT_KEYBINDINGS.refresh.desc
|
||||||
|
)
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.refresh);
|
);
|
||||||
assert_str_eq!(*description, DEFAULT_KEYBINDINGS.refresh.desc);
|
assert_some_eq_x!(
|
||||||
|
series_context_clues_iter.next(),
|
||||||
let (key_binding, description) = series_context_clues_iter.next().unwrap();
|
&(DEFAULT_KEYBINDINGS.update, "update all")
|
||||||
|
);
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.update);
|
assert_some_eq_x!(
|
||||||
assert_str_eq!(*description, "update all");
|
series_context_clues_iter.next(),
|
||||||
|
&(DEFAULT_KEYBINDINGS.submit, "details")
|
||||||
let (key_binding, description) = series_context_clues_iter.next().unwrap();
|
);
|
||||||
|
assert_some_eq_x!(
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.submit);
|
series_context_clues_iter.next(),
|
||||||
assert_str_eq!(*description, "details");
|
&(DEFAULT_KEYBINDINGS.esc, "cancel filter")
|
||||||
|
);
|
||||||
let (key_binding, description) = series_context_clues_iter.next().unwrap();
|
assert_none!(series_context_clues_iter.next());
|
||||||
|
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.esc);
|
|
||||||
assert_str_eq!(*description, "cancel filter");
|
|
||||||
assert_eq!(series_context_clues_iter.next(), None);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_series_history_context_clues() {
|
fn test_series_history_context_clues() {
|
||||||
let mut series_history_context_clues_iter = SERIES_HISTORY_CONTEXT_CLUES.iter();
|
let mut series_history_context_clues_iter = SERIES_HISTORY_CONTEXT_CLUES.iter();
|
||||||
|
|
||||||
let (key_binding, description) = series_history_context_clues_iter.next().unwrap();
|
assert_some_eq_x!(
|
||||||
|
series_history_context_clues_iter.next(),
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.refresh);
|
&(
|
||||||
assert_str_eq!(*description, DEFAULT_KEYBINDINGS.refresh.desc);
|
DEFAULT_KEYBINDINGS.refresh,
|
||||||
|
DEFAULT_KEYBINDINGS.refresh.desc
|
||||||
let (key_binding, description) = series_history_context_clues_iter.next().unwrap();
|
)
|
||||||
|
);
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.edit);
|
assert_some_eq_x!(
|
||||||
assert_str_eq!(*description, DEFAULT_KEYBINDINGS.edit.desc);
|
series_history_context_clues_iter.next(),
|
||||||
|
&(DEFAULT_KEYBINDINGS.edit, DEFAULT_KEYBINDINGS.edit.desc)
|
||||||
let (key_binding, description) = series_history_context_clues_iter.next().unwrap();
|
);
|
||||||
|
assert_some_eq_x!(
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.submit);
|
series_history_context_clues_iter.next(),
|
||||||
assert_str_eq!(*description, "details");
|
&(DEFAULT_KEYBINDINGS.submit, "details")
|
||||||
|
);
|
||||||
let (key_binding, description) = series_history_context_clues_iter.next().unwrap();
|
assert_some_eq_x!(
|
||||||
|
series_history_context_clues_iter.next(),
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.sort);
|
&(DEFAULT_KEYBINDINGS.sort, DEFAULT_KEYBINDINGS.sort.desc)
|
||||||
assert_str_eq!(*description, DEFAULT_KEYBINDINGS.sort.desc);
|
);
|
||||||
|
assert_some_eq_x!(
|
||||||
let (key_binding, description) = series_history_context_clues_iter.next().unwrap();
|
series_history_context_clues_iter.next(),
|
||||||
|
&(DEFAULT_KEYBINDINGS.search, DEFAULT_KEYBINDINGS.search.desc)
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.search);
|
);
|
||||||
assert_str_eq!(*description, DEFAULT_KEYBINDINGS.search.desc);
|
assert_some_eq_x!(
|
||||||
|
series_history_context_clues_iter.next(),
|
||||||
let (key_binding, description) = series_history_context_clues_iter.next().unwrap();
|
&(DEFAULT_KEYBINDINGS.filter, DEFAULT_KEYBINDINGS.filter.desc)
|
||||||
|
);
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.filter);
|
assert_some_eq_x!(
|
||||||
assert_str_eq!(*description, DEFAULT_KEYBINDINGS.filter.desc);
|
series_history_context_clues_iter.next(),
|
||||||
|
&(
|
||||||
let (key_binding, description) = series_history_context_clues_iter.next().unwrap();
|
DEFAULT_KEYBINDINGS.auto_search,
|
||||||
|
DEFAULT_KEYBINDINGS.auto_search.desc
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.auto_search);
|
)
|
||||||
assert_str_eq!(*description, DEFAULT_KEYBINDINGS.auto_search.desc);
|
);
|
||||||
|
assert_some_eq_x!(
|
||||||
let (key_binding, description) = series_history_context_clues_iter.next().unwrap();
|
series_history_context_clues_iter.next(),
|
||||||
|
&(DEFAULT_KEYBINDINGS.update, DEFAULT_KEYBINDINGS.update.desc)
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.update);
|
);
|
||||||
assert_str_eq!(*description, DEFAULT_KEYBINDINGS.update.desc);
|
assert_some_eq_x!(
|
||||||
|
series_history_context_clues_iter.next(),
|
||||||
let (key_binding, description) = series_history_context_clues_iter.next().unwrap();
|
&(DEFAULT_KEYBINDINGS.esc, "cancel filter/close")
|
||||||
|
);
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.esc);
|
assert_none!(series_history_context_clues_iter.next());
|
||||||
assert_str_eq!(*description, "cancel filter/close");
|
|
||||||
assert_eq!(series_history_context_clues_iter.next(), None);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_history_context_clues() {
|
fn test_history_context_clues() {
|
||||||
let mut history_context_clues_iter = HISTORY_CONTEXT_CLUES.iter();
|
let mut history_context_clues_iter = HISTORY_CONTEXT_CLUES.iter();
|
||||||
|
|
||||||
let (key_binding, description) = history_context_clues_iter.next().unwrap();
|
assert_some_eq_x!(
|
||||||
|
history_context_clues_iter.next(),
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.submit);
|
&(DEFAULT_KEYBINDINGS.submit, "details")
|
||||||
assert_str_eq!(*description, "details");
|
);
|
||||||
|
assert_some_eq_x!(
|
||||||
let (key_binding, description) = history_context_clues_iter.next().unwrap();
|
history_context_clues_iter.next(),
|
||||||
|
&(DEFAULT_KEYBINDINGS.sort, DEFAULT_KEYBINDINGS.sort.desc)
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.sort);
|
);
|
||||||
assert_str_eq!(*description, DEFAULT_KEYBINDINGS.sort.desc);
|
assert_some_eq_x!(
|
||||||
|
history_context_clues_iter.next(),
|
||||||
let (key_binding, description) = history_context_clues_iter.next().unwrap();
|
&(DEFAULT_KEYBINDINGS.search, DEFAULT_KEYBINDINGS.search.desc)
|
||||||
|
);
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.search);
|
assert_some_eq_x!(
|
||||||
assert_str_eq!(*description, DEFAULT_KEYBINDINGS.search.desc);
|
history_context_clues_iter.next(),
|
||||||
|
&(DEFAULT_KEYBINDINGS.filter, DEFAULT_KEYBINDINGS.filter.desc)
|
||||||
let (key_binding, description) = history_context_clues_iter.next().unwrap();
|
);
|
||||||
|
assert_some_eq_x!(
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.filter);
|
history_context_clues_iter.next(),
|
||||||
assert_str_eq!(*description, DEFAULT_KEYBINDINGS.filter.desc);
|
&(
|
||||||
|
DEFAULT_KEYBINDINGS.refresh,
|
||||||
let (key_binding, description) = history_context_clues_iter.next().unwrap();
|
DEFAULT_KEYBINDINGS.refresh.desc
|
||||||
|
)
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.refresh);
|
);
|
||||||
assert_str_eq!(*description, DEFAULT_KEYBINDINGS.refresh.desc);
|
assert_some_eq_x!(
|
||||||
|
history_context_clues_iter.next(),
|
||||||
let (key_binding, description) = history_context_clues_iter.next().unwrap();
|
&(DEFAULT_KEYBINDINGS.esc, "cancel filter")
|
||||||
|
);
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.esc);
|
assert_none!(history_context_clues_iter.next());
|
||||||
assert_str_eq!(*description, "cancel filter");
|
|
||||||
assert_eq!(history_context_clues_iter.next(), None);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_series_details_context_clues() {
|
fn test_series_details_context_clues() {
|
||||||
let mut series_details_context_clues_iter = SERIES_DETAILS_CONTEXT_CLUES.iter();
|
let mut series_details_context_clues_iter = SERIES_DETAILS_CONTEXT_CLUES.iter();
|
||||||
|
|
||||||
let (key_binding, description) = series_details_context_clues_iter.next().unwrap();
|
assert_some_eq_x!(
|
||||||
|
series_details_context_clues_iter.next(),
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.refresh);
|
&(
|
||||||
assert_str_eq!(*description, DEFAULT_KEYBINDINGS.refresh.desc);
|
DEFAULT_KEYBINDINGS.refresh,
|
||||||
|
DEFAULT_KEYBINDINGS.refresh.desc
|
||||||
let (key_binding, description) = series_details_context_clues_iter.next().unwrap();
|
)
|
||||||
|
);
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.edit);
|
assert_some_eq_x!(
|
||||||
assert_str_eq!(*description, DEFAULT_KEYBINDINGS.edit.desc);
|
series_details_context_clues_iter.next(),
|
||||||
|
&(DEFAULT_KEYBINDINGS.edit, DEFAULT_KEYBINDINGS.edit.desc)
|
||||||
let (key_binding, description) = series_details_context_clues_iter.next().unwrap();
|
);
|
||||||
|
assert_some_eq_x!(
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.toggle_monitoring);
|
series_details_context_clues_iter.next(),
|
||||||
assert_str_eq!(*description, DEFAULT_KEYBINDINGS.toggle_monitoring.desc);
|
&(
|
||||||
|
DEFAULT_KEYBINDINGS.toggle_monitoring,
|
||||||
let (key_binding, description) = series_details_context_clues_iter.next().unwrap();
|
DEFAULT_KEYBINDINGS.toggle_monitoring.desc
|
||||||
|
)
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.submit);
|
);
|
||||||
assert_str_eq!(*description, "season details");
|
assert_some_eq_x!(
|
||||||
|
series_details_context_clues_iter.next(),
|
||||||
let (key_binding, description) = series_details_context_clues_iter.next().unwrap();
|
&(DEFAULT_KEYBINDINGS.submit, "season details")
|
||||||
|
);
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.search);
|
assert_some_eq_x!(
|
||||||
assert_str_eq!(*description, DEFAULT_KEYBINDINGS.search.desc);
|
series_details_context_clues_iter.next(),
|
||||||
|
&(DEFAULT_KEYBINDINGS.search, DEFAULT_KEYBINDINGS.search.desc)
|
||||||
let (key_binding, description) = series_details_context_clues_iter.next().unwrap();
|
);
|
||||||
|
assert_some_eq_x!(
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.update);
|
series_details_context_clues_iter.next(),
|
||||||
assert_str_eq!(*description, DEFAULT_KEYBINDINGS.update.desc);
|
&(DEFAULT_KEYBINDINGS.update, DEFAULT_KEYBINDINGS.update.desc)
|
||||||
|
);
|
||||||
let (key_binding, description) = series_details_context_clues_iter.next().unwrap();
|
assert_some_eq_x!(
|
||||||
|
series_details_context_clues_iter.next(),
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.auto_search);
|
&(
|
||||||
assert_str_eq!(*description, DEFAULT_KEYBINDINGS.auto_search.desc);
|
DEFAULT_KEYBINDINGS.auto_search,
|
||||||
|
DEFAULT_KEYBINDINGS.auto_search.desc
|
||||||
let (key_binding, description) = series_details_context_clues_iter.next().unwrap();
|
)
|
||||||
|
);
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.esc);
|
assert_some_eq_x!(
|
||||||
assert_str_eq!(*description, DEFAULT_KEYBINDINGS.esc.desc);
|
series_details_context_clues_iter.next(),
|
||||||
assert_eq!(series_details_context_clues_iter.next(), None);
|
&(DEFAULT_KEYBINDINGS.esc, DEFAULT_KEYBINDINGS.esc.desc)
|
||||||
|
);
|
||||||
|
assert_none!(series_details_context_clues_iter.next());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_season_details_context_clues() {
|
fn test_season_details_context_clues() {
|
||||||
let mut season_details_context_clues_iter = SEASON_DETAILS_CONTEXT_CLUES.iter();
|
let mut season_details_context_clues_iter = SEASON_DETAILS_CONTEXT_CLUES.iter();
|
||||||
|
|
||||||
let (key_binding, description) = season_details_context_clues_iter.next().unwrap();
|
assert_some_eq_x!(
|
||||||
|
season_details_context_clues_iter.next(),
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.refresh);
|
&(
|
||||||
assert_str_eq!(*description, DEFAULT_KEYBINDINGS.refresh.desc);
|
DEFAULT_KEYBINDINGS.refresh,
|
||||||
|
DEFAULT_KEYBINDINGS.refresh.desc
|
||||||
let (key_binding, description) = season_details_context_clues_iter.next().unwrap();
|
)
|
||||||
|
);
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.toggle_monitoring);
|
assert_some_eq_x!(
|
||||||
assert_str_eq!(*description, DEFAULT_KEYBINDINGS.toggle_monitoring.desc);
|
season_details_context_clues_iter.next(),
|
||||||
|
&(
|
||||||
let (key_binding, description) = season_details_context_clues_iter.next().unwrap();
|
DEFAULT_KEYBINDINGS.toggle_monitoring,
|
||||||
|
DEFAULT_KEYBINDINGS.toggle_monitoring.desc
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.search);
|
)
|
||||||
assert_str_eq!(*description, DEFAULT_KEYBINDINGS.search.desc);
|
);
|
||||||
|
assert_some_eq_x!(
|
||||||
let (key_binding, description) = season_details_context_clues_iter.next().unwrap();
|
season_details_context_clues_iter.next(),
|
||||||
|
&(DEFAULT_KEYBINDINGS.search, DEFAULT_KEYBINDINGS.search.desc)
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.auto_search);
|
);
|
||||||
assert_str_eq!(*description, DEFAULT_KEYBINDINGS.auto_search.desc);
|
assert_some_eq_x!(
|
||||||
|
season_details_context_clues_iter.next(),
|
||||||
let (key_binding, description) = season_details_context_clues_iter.next().unwrap();
|
&(
|
||||||
|
DEFAULT_KEYBINDINGS.auto_search,
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.esc);
|
DEFAULT_KEYBINDINGS.auto_search.desc
|
||||||
assert_str_eq!(*description, DEFAULT_KEYBINDINGS.esc.desc);
|
)
|
||||||
|
);
|
||||||
let (key_binding, description) = season_details_context_clues_iter.next().unwrap();
|
assert_some_eq_x!(
|
||||||
|
season_details_context_clues_iter.next(),
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.submit);
|
&(DEFAULT_KEYBINDINGS.esc, DEFAULT_KEYBINDINGS.esc.desc)
|
||||||
assert_str_eq!(*description, "episode details");
|
);
|
||||||
|
assert_some_eq_x!(
|
||||||
let (key_binding, description) = season_details_context_clues_iter.next().unwrap();
|
season_details_context_clues_iter.next(),
|
||||||
|
&(DEFAULT_KEYBINDINGS.submit, "episode details")
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.delete);
|
);
|
||||||
assert_str_eq!(*description, "delete episode");
|
assert_some_eq_x!(
|
||||||
|
season_details_context_clues_iter.next(),
|
||||||
assert_eq!(season_details_context_clues_iter.next(), None);
|
&(DEFAULT_KEYBINDINGS.delete, "delete episode")
|
||||||
|
);
|
||||||
|
assert_none!(season_details_context_clues_iter.next());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_season_history_context_clues() {
|
fn test_season_history_context_clues() {
|
||||||
let mut season_history_context_clues_iter = SEASON_HISTORY_CONTEXT_CLUES.iter();
|
let mut season_history_context_clues_iter = SEASON_HISTORY_CONTEXT_CLUES.iter();
|
||||||
let (key_binding, description) = season_history_context_clues_iter.next().unwrap();
|
assert_some_eq_x!(
|
||||||
|
season_history_context_clues_iter.next(),
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.refresh);
|
&(
|
||||||
assert_str_eq!(*description, DEFAULT_KEYBINDINGS.refresh.desc);
|
DEFAULT_KEYBINDINGS.refresh,
|
||||||
|
DEFAULT_KEYBINDINGS.refresh.desc
|
||||||
let (key_binding, description) = season_history_context_clues_iter.next().unwrap();
|
)
|
||||||
|
);
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.sort);
|
assert_some_eq_x!(
|
||||||
assert_str_eq!(*description, DEFAULT_KEYBINDINGS.sort.desc);
|
season_history_context_clues_iter.next(),
|
||||||
|
&(DEFAULT_KEYBINDINGS.sort, DEFAULT_KEYBINDINGS.sort.desc)
|
||||||
let (key_binding, description) = season_history_context_clues_iter.next().unwrap();
|
);
|
||||||
|
assert_some_eq_x!(
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.search);
|
season_history_context_clues_iter.next(),
|
||||||
assert_str_eq!(*description, DEFAULT_KEYBINDINGS.search.desc);
|
&(DEFAULT_KEYBINDINGS.search, DEFAULT_KEYBINDINGS.search.desc)
|
||||||
|
);
|
||||||
let (key_binding, description) = season_history_context_clues_iter.next().unwrap();
|
assert_some_eq_x!(
|
||||||
|
season_history_context_clues_iter.next(),
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.filter);
|
&(DEFAULT_KEYBINDINGS.filter, DEFAULT_KEYBINDINGS.filter.desc)
|
||||||
assert_str_eq!(*description, DEFAULT_KEYBINDINGS.filter.desc);
|
);
|
||||||
|
assert_some_eq_x!(
|
||||||
let (key_binding, description) = season_history_context_clues_iter.next().unwrap();
|
season_history_context_clues_iter.next(),
|
||||||
|
&(
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.auto_search);
|
DEFAULT_KEYBINDINGS.auto_search,
|
||||||
assert_str_eq!(*description, DEFAULT_KEYBINDINGS.auto_search.desc);
|
DEFAULT_KEYBINDINGS.auto_search.desc
|
||||||
|
)
|
||||||
let (key_binding, description) = season_history_context_clues_iter.next().unwrap();
|
);
|
||||||
|
assert_some_eq_x!(
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.submit);
|
season_history_context_clues_iter.next(),
|
||||||
assert_str_eq!(*description, "details");
|
&(DEFAULT_KEYBINDINGS.submit, "details")
|
||||||
|
);
|
||||||
let (key_binding, description) = season_history_context_clues_iter.next().unwrap();
|
assert_some_eq_x!(
|
||||||
|
season_history_context_clues_iter.next(),
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.esc);
|
&(DEFAULT_KEYBINDINGS.esc, "cancel filter/close")
|
||||||
assert_str_eq!(*description, "cancel filter/close");
|
);
|
||||||
assert_eq!(season_history_context_clues_iter.next(), None);
|
assert_none!(season_history_context_clues_iter.next());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_manual_season_search_context_clues() {
|
fn test_manual_season_search_context_clues() {
|
||||||
let mut manual_season_search_context_clues_iter = MANUAL_SEASON_SEARCH_CONTEXT_CLUES.iter();
|
let mut manual_season_search_context_clues_iter = MANUAL_SEASON_SEARCH_CONTEXT_CLUES.iter();
|
||||||
|
|
||||||
let (key_binding, description) = manual_season_search_context_clues_iter.next().unwrap();
|
assert_some_eq_x!(
|
||||||
|
manual_season_search_context_clues_iter.next(),
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.refresh);
|
&(
|
||||||
assert_str_eq!(*description, DEFAULT_KEYBINDINGS.refresh.desc);
|
DEFAULT_KEYBINDINGS.refresh,
|
||||||
|
DEFAULT_KEYBINDINGS.refresh.desc
|
||||||
let (key_binding, description) = manual_season_search_context_clues_iter.next().unwrap();
|
)
|
||||||
|
);
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.auto_search);
|
assert_some_eq_x!(
|
||||||
assert_str_eq!(*description, DEFAULT_KEYBINDINGS.auto_search.desc);
|
manual_season_search_context_clues_iter.next(),
|
||||||
|
&(
|
||||||
let (key_binding, description) = manual_season_search_context_clues_iter.next().unwrap();
|
DEFAULT_KEYBINDINGS.auto_search,
|
||||||
|
DEFAULT_KEYBINDINGS.auto_search.desc
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.sort);
|
)
|
||||||
assert_str_eq!(*description, DEFAULT_KEYBINDINGS.sort.desc);
|
);
|
||||||
|
assert_some_eq_x!(
|
||||||
let (key_binding, description) = manual_season_search_context_clues_iter.next().unwrap();
|
manual_season_search_context_clues_iter.next(),
|
||||||
|
&(DEFAULT_KEYBINDINGS.sort, DEFAULT_KEYBINDINGS.sort.desc)
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.submit);
|
);
|
||||||
assert_str_eq!(*description, "details");
|
assert_some_eq_x!(
|
||||||
|
manual_season_search_context_clues_iter.next(),
|
||||||
let (key_binding, description) = manual_season_search_context_clues_iter.next().unwrap();
|
&(DEFAULT_KEYBINDINGS.submit, "details")
|
||||||
|
);
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.esc);
|
assert_some_eq_x!(
|
||||||
assert_str_eq!(*description, DEFAULT_KEYBINDINGS.esc.desc);
|
manual_season_search_context_clues_iter.next(),
|
||||||
assert_eq!(manual_season_search_context_clues_iter.next(), None);
|
&(DEFAULT_KEYBINDINGS.esc, DEFAULT_KEYBINDINGS.esc.desc)
|
||||||
|
);
|
||||||
|
assert_none!(manual_season_search_context_clues_iter.next());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_manual_episode_search_context_clues() {
|
fn test_manual_episode_search_context_clues() {
|
||||||
let mut manual_episode_search_context_clues_iter = MANUAL_EPISODE_SEARCH_CONTEXT_CLUES.iter();
|
let mut manual_episode_search_context_clues_iter = MANUAL_EPISODE_SEARCH_CONTEXT_CLUES.iter();
|
||||||
|
|
||||||
let (key_binding, description) = manual_episode_search_context_clues_iter.next().unwrap();
|
assert_some_eq_x!(
|
||||||
|
manual_episode_search_context_clues_iter.next(),
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.refresh);
|
&(
|
||||||
assert_str_eq!(*description, DEFAULT_KEYBINDINGS.refresh.desc);
|
DEFAULT_KEYBINDINGS.refresh,
|
||||||
|
DEFAULT_KEYBINDINGS.refresh.desc
|
||||||
let (key_binding, description) = manual_episode_search_context_clues_iter.next().unwrap();
|
)
|
||||||
|
);
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.auto_search);
|
assert_some_eq_x!(
|
||||||
assert_str_eq!(*description, DEFAULT_KEYBINDINGS.auto_search.desc);
|
manual_episode_search_context_clues_iter.next(),
|
||||||
|
&(
|
||||||
let (key_binding, description) = manual_episode_search_context_clues_iter.next().unwrap();
|
DEFAULT_KEYBINDINGS.auto_search,
|
||||||
|
DEFAULT_KEYBINDINGS.auto_search.desc
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.sort);
|
)
|
||||||
assert_str_eq!(*description, DEFAULT_KEYBINDINGS.sort.desc);
|
);
|
||||||
|
assert_some_eq_x!(
|
||||||
let (key_binding, description) = manual_episode_search_context_clues_iter.next().unwrap();
|
manual_episode_search_context_clues_iter.next(),
|
||||||
|
&(DEFAULT_KEYBINDINGS.sort, DEFAULT_KEYBINDINGS.sort.desc)
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.submit);
|
);
|
||||||
assert_str_eq!(*description, "details");
|
assert_some_eq_x!(
|
||||||
|
manual_episode_search_context_clues_iter.next(),
|
||||||
let (key_binding, description) = manual_episode_search_context_clues_iter.next().unwrap();
|
&(DEFAULT_KEYBINDINGS.submit, "details")
|
||||||
|
);
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.esc);
|
assert_some_eq_x!(
|
||||||
assert_str_eq!(*description, DEFAULT_KEYBINDINGS.esc.desc);
|
manual_episode_search_context_clues_iter.next(),
|
||||||
assert_eq!(manual_episode_search_context_clues_iter.next(), None);
|
&(DEFAULT_KEYBINDINGS.esc, DEFAULT_KEYBINDINGS.esc.desc)
|
||||||
|
);
|
||||||
|
assert_none!(manual_episode_search_context_clues_iter.next());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_episode_details_context_clues() {
|
fn test_episode_details_context_clues() {
|
||||||
let mut episode_details_context_clues_iter = EPISODE_DETAILS_CONTEXT_CLUES.iter();
|
let mut episode_details_context_clues_iter = EPISODE_DETAILS_CONTEXT_CLUES.iter();
|
||||||
|
|
||||||
let (key_binding, description) = episode_details_context_clues_iter.next().unwrap();
|
assert_some_eq_x!(
|
||||||
|
episode_details_context_clues_iter.next(),
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.refresh);
|
&(
|
||||||
assert_str_eq!(*description, DEFAULT_KEYBINDINGS.refresh.desc);
|
DEFAULT_KEYBINDINGS.refresh,
|
||||||
|
DEFAULT_KEYBINDINGS.refresh.desc
|
||||||
let (key_binding, description) = episode_details_context_clues_iter.next().unwrap();
|
)
|
||||||
|
);
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.auto_search);
|
assert_some_eq_x!(
|
||||||
assert_str_eq!(*description, DEFAULT_KEYBINDINGS.auto_search.desc);
|
episode_details_context_clues_iter.next(),
|
||||||
|
&(
|
||||||
let (key_binding, description) = episode_details_context_clues_iter.next().unwrap();
|
DEFAULT_KEYBINDINGS.auto_search,
|
||||||
|
DEFAULT_KEYBINDINGS.auto_search.desc
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.esc);
|
)
|
||||||
assert_str_eq!(*description, DEFAULT_KEYBINDINGS.esc.desc);
|
);
|
||||||
assert_eq!(episode_details_context_clues_iter.next(), None);
|
assert_some_eq_x!(
|
||||||
|
episode_details_context_clues_iter.next(),
|
||||||
|
&(DEFAULT_KEYBINDINGS.esc, DEFAULT_KEYBINDINGS.esc.desc)
|
||||||
|
);
|
||||||
|
assert_none!(episode_details_context_clues_iter.next());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_selectable_episode_details_context_clues() {
|
fn test_selectable_episode_details_context_clues() {
|
||||||
let mut episode_details_context_clues_iter = SELECTABLE_EPISODE_DETAILS_CONTEXT_CLUES.iter();
|
let mut episode_details_context_clues_iter = SELECTABLE_EPISODE_DETAILS_CONTEXT_CLUES.iter();
|
||||||
|
|
||||||
let (key_binding, description) = episode_details_context_clues_iter.next().unwrap();
|
assert_some_eq_x!(
|
||||||
|
episode_details_context_clues_iter.next(),
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.refresh);
|
&(
|
||||||
assert_str_eq!(*description, DEFAULT_KEYBINDINGS.refresh.desc);
|
DEFAULT_KEYBINDINGS.refresh,
|
||||||
|
DEFAULT_KEYBINDINGS.refresh.desc
|
||||||
let (key_binding, description) = episode_details_context_clues_iter.next().unwrap();
|
)
|
||||||
|
);
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.auto_search);
|
assert_some_eq_x!(
|
||||||
assert_str_eq!(*description, DEFAULT_KEYBINDINGS.auto_search.desc);
|
episode_details_context_clues_iter.next(),
|
||||||
|
&(
|
||||||
let (key_binding, description) = episode_details_context_clues_iter.next().unwrap();
|
DEFAULT_KEYBINDINGS.auto_search,
|
||||||
|
DEFAULT_KEYBINDINGS.auto_search.desc
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.submit);
|
)
|
||||||
assert_str_eq!(*description, "details");
|
);
|
||||||
|
assert_some_eq_x!(
|
||||||
let (key_binding, description) = episode_details_context_clues_iter.next().unwrap();
|
episode_details_context_clues_iter.next(),
|
||||||
|
&(DEFAULT_KEYBINDINGS.submit, "details")
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.esc);
|
);
|
||||||
assert_str_eq!(*description, DEFAULT_KEYBINDINGS.esc.desc);
|
assert_some_eq_x!(
|
||||||
assert_eq!(episode_details_context_clues_iter.next(), None);
|
episode_details_context_clues_iter.next(),
|
||||||
|
&(DEFAULT_KEYBINDINGS.esc, DEFAULT_KEYBINDINGS.esc.desc)
|
||||||
|
);
|
||||||
|
assert_none!(episode_details_context_clues_iter.next());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_system_tasks_context_clues() {
|
fn test_system_tasks_context_clues() {
|
||||||
let mut system_tasks_context_clues_iter = SYSTEM_TASKS_CONTEXT_CLUES.iter();
|
let mut system_tasks_context_clues_iter = SYSTEM_TASKS_CONTEXT_CLUES.iter();
|
||||||
|
|
||||||
let (key_binding, description) = system_tasks_context_clues_iter.next().unwrap();
|
assert_some_eq_x!(
|
||||||
|
system_tasks_context_clues_iter.next(),
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.submit);
|
&(DEFAULT_KEYBINDINGS.submit, "start task")
|
||||||
assert_str_eq!(*description, "start task");
|
);
|
||||||
|
assert_some_eq_x!(
|
||||||
let (key_binding, description) = system_tasks_context_clues_iter.next().unwrap();
|
system_tasks_context_clues_iter.next(),
|
||||||
|
&(DEFAULT_KEYBINDINGS.esc, DEFAULT_KEYBINDINGS.esc.desc)
|
||||||
assert_eq!(*key_binding, DEFAULT_KEYBINDINGS.esc);
|
);
|
||||||
assert_str_eq!(*description, DEFAULT_KEYBINDINGS.esc.desc);
|
assert_none!(system_tasks_context_clues_iter.next());
|
||||||
assert_eq!(system_tasks_context_clues_iter.next(), None);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -470,8 +474,7 @@ mod tests {
|
|||||||
|
|
||||||
let context_clues = SonarrContextClueProvider::get_context_clues(&mut app);
|
let context_clues = SonarrContextClueProvider::get_context_clues(&mut app);
|
||||||
|
|
||||||
assert!(context_clues.is_some());
|
assert_some_eq_x!(context_clues, expected_context_clues);
|
||||||
assert_eq!(expected_context_clues, context_clues.unwrap());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[rstest]
|
#[rstest]
|
||||||
@@ -495,8 +498,7 @@ mod tests {
|
|||||||
|
|
||||||
let context_clues = SonarrContextClueProvider::get_context_clues(&mut app);
|
let context_clues = SonarrContextClueProvider::get_context_clues(&mut app);
|
||||||
|
|
||||||
assert!(context_clues.is_some());
|
assert_some_eq_x!(context_clues, expected_context_clues);
|
||||||
assert_eq!(expected_context_clues, context_clues.unwrap());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[rstest]
|
#[rstest]
|
||||||
@@ -524,8 +526,7 @@ mod tests {
|
|||||||
|
|
||||||
let context_clues = SonarrContextClueProvider::get_context_clues(&mut app);
|
let context_clues = SonarrContextClueProvider::get_context_clues(&mut app);
|
||||||
|
|
||||||
assert!(context_clues.is_some());
|
assert_some_eq_x!(context_clues, expected_context_clues);
|
||||||
assert_eq!(expected_context_clues, context_clues.unwrap());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[rstest]
|
#[rstest]
|
||||||
@@ -544,8 +545,7 @@ mod tests {
|
|||||||
|
|
||||||
let context_clues = SonarrContextClueProvider::get_context_clues(&mut app);
|
let context_clues = SonarrContextClueProvider::get_context_clues(&mut app);
|
||||||
|
|
||||||
assert!(context_clues.is_some());
|
assert_some_eq_x!(context_clues, &BARE_POPUP_CONTEXT_CLUES);
|
||||||
assert_eq!(context_clues.unwrap(), &BARE_POPUP_CONTEXT_CLUES);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[rstest]
|
#[rstest]
|
||||||
@@ -567,8 +567,7 @@ mod tests {
|
|||||||
|
|
||||||
let context_clues = SonarrContextClueProvider::get_context_clues(&mut app);
|
let context_clues = SonarrContextClueProvider::get_context_clues(&mut app);
|
||||||
|
|
||||||
assert!(context_clues.is_some());
|
assert_some_eq_x!(context_clues, &CONFIRMATION_PROMPT_CONTEXT_CLUES);
|
||||||
assert_eq!(context_clues.unwrap(), &CONFIRMATION_PROMPT_CONTEXT_CLUES);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[rstest]
|
#[rstest]
|
||||||
@@ -593,8 +592,7 @@ mod tests {
|
|||||||
|
|
||||||
let context_clues = SonarrContextClueProvider::get_context_clues(&mut app);
|
let context_clues = SonarrContextClueProvider::get_context_clues(&mut app);
|
||||||
|
|
||||||
assert!(context_clues.is_some());
|
assert_some_eq_x!(context_clues, &CONFIRMATION_PROMPT_CONTEXT_CLUES);
|
||||||
assert_eq!(context_clues.unwrap(), &CONFIRMATION_PROMPT_CONTEXT_CLUES);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[rstest]
|
#[rstest]
|
||||||
@@ -614,8 +612,7 @@ mod tests {
|
|||||||
|
|
||||||
let context_clues = SonarrContextClueProvider::get_context_clues(&mut app);
|
let context_clues = SonarrContextClueProvider::get_context_clues(&mut app);
|
||||||
|
|
||||||
assert!(context_clues.is_some());
|
assert_some_eq_x!(context_clues, &CONFIRMATION_PROMPT_CONTEXT_CLUES);
|
||||||
assert_eq!(context_clues.unwrap(), &CONFIRMATION_PROMPT_CONTEXT_CLUES);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[rstest]
|
#[rstest]
|
||||||
@@ -638,8 +635,7 @@ mod tests {
|
|||||||
|
|
||||||
let context_clues = SonarrContextClueProvider::get_context_clues(&mut app);
|
let context_clues = SonarrContextClueProvider::get_context_clues(&mut app);
|
||||||
|
|
||||||
assert!(context_clues.is_some());
|
assert_some_eq_x!(context_clues, &CONFIRMATION_PROMPT_CONTEXT_CLUES);
|
||||||
assert_eq!(context_clues.unwrap(), &CONFIRMATION_PROMPT_CONTEXT_CLUES);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[rstest]
|
#[rstest]
|
||||||
@@ -655,11 +651,7 @@ mod tests {
|
|||||||
|
|
||||||
let context_clues = SonarrContextClueProvider::get_context_clues(&mut app);
|
let context_clues = SonarrContextClueProvider::get_context_clues(&mut app);
|
||||||
|
|
||||||
assert!(context_clues.is_some());
|
assert_some_eq_x!(context_clues, &ADD_SERIES_SEARCH_RESULTS_CONTEXT_CLUES);
|
||||||
assert_eq!(
|
|
||||||
context_clues.unwrap(),
|
|
||||||
&ADD_SERIES_SEARCH_RESULTS_CONTEXT_CLUES
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -669,8 +661,7 @@ mod tests {
|
|||||||
app.push_navigation_stack(ActiveSonarrBlock::SystemTasks.into());
|
app.push_navigation_stack(ActiveSonarrBlock::SystemTasks.into());
|
||||||
let context_clues = SonarrContextClueProvider::get_context_clues(&mut app);
|
let context_clues = SonarrContextClueProvider::get_context_clues(&mut app);
|
||||||
|
|
||||||
assert!(context_clues.is_some());
|
assert_some_eq_x!(context_clues, &SYSTEM_TASKS_CONTEXT_CLUES);
|
||||||
assert_eq!(context_clues.unwrap(), &SYSTEM_TASKS_CONTEXT_CLUES);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[rstest]
|
#[rstest]
|
||||||
@@ -693,7 +684,6 @@ mod tests {
|
|||||||
|
|
||||||
let context_clues = SonarrContextClueProvider::get_context_clues(&mut app);
|
let context_clues = SonarrContextClueProvider::get_context_clues(&mut app);
|
||||||
|
|
||||||
assert!(context_clues.is_some());
|
assert_some_eq_x!(context_clues, expected_context_clues);
|
||||||
assert_eq!(expected_context_clues, context_clues.unwrap());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ mod tests {
|
|||||||
},
|
},
|
||||||
sonarr_models::{Season, Series, SonarrRelease},
|
sonarr_models::{Season, Series, SonarrRelease},
|
||||||
},
|
},
|
||||||
network::{sonarr_network::SonarrEvent, NetworkEvent},
|
network::{NetworkEvent, sonarr_network::SonarrEvent},
|
||||||
};
|
};
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
|
|||||||
+12
-12
@@ -2,16 +2,18 @@
|
|||||||
mod tests {
|
mod tests {
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use clap::{error::ErrorKind, CommandFactory};
|
use clap::{CommandFactory, error::ErrorKind};
|
||||||
use mockall::predicate::eq;
|
use mockall::predicate::eq;
|
||||||
use rstest::rstest;
|
use rstest::rstest;
|
||||||
use serde_json::json;
|
use serde_json::json;
|
||||||
use tokio::sync::Mutex;
|
use tokio::sync::Mutex;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
|
Cli,
|
||||||
app::App,
|
app::App,
|
||||||
cli::{handle_command, mutex_flags_or_option, radarr::RadarrCommand, sonarr::SonarrCommand},
|
cli::{handle_command, mutex_flags_or_option, radarr::RadarrCommand, sonarr::SonarrCommand},
|
||||||
models::{
|
models::{
|
||||||
|
Serdeable,
|
||||||
radarr_models::{
|
radarr_models::{
|
||||||
BlocklistItem as RadarrBlocklistItem, BlocklistResponse as RadarrBlocklistResponse,
|
BlocklistItem as RadarrBlocklistItem, BlocklistResponse as RadarrBlocklistResponse,
|
||||||
RadarrSerdeable,
|
RadarrSerdeable,
|
||||||
@@ -20,12 +22,10 @@ mod tests {
|
|||||||
BlocklistItem as SonarrBlocklistItem, BlocklistResponse as SonarrBlocklistResponse,
|
BlocklistItem as SonarrBlocklistItem, BlocklistResponse as SonarrBlocklistResponse,
|
||||||
SonarrSerdeable,
|
SonarrSerdeable,
|
||||||
},
|
},
|
||||||
Serdeable,
|
|
||||||
},
|
},
|
||||||
network::{
|
network::{
|
||||||
radarr_network::RadarrEvent, sonarr_network::SonarrEvent, MockNetworkTrait, NetworkEvent,
|
MockNetworkTrait, NetworkEvent, radarr_network::RadarrEvent, sonarr_network::SonarrEvent,
|
||||||
},
|
},
|
||||||
Cli,
|
|
||||||
};
|
};
|
||||||
use pretty_assertions::assert_eq;
|
use pretty_assertions::assert_eq;
|
||||||
|
|
||||||
@@ -33,7 +33,7 @@ mod tests {
|
|||||||
fn test_servarr_subcommand_requires_subcommand(#[values("radarr", "sonarr")] subcommand: &str) {
|
fn test_servarr_subcommand_requires_subcommand(#[values("radarr", "sonarr")] subcommand: &str) {
|
||||||
let result = Cli::command().try_get_matches_from(["managarr", subcommand]);
|
let result = Cli::command().try_get_matches_from(["managarr", subcommand]);
|
||||||
|
|
||||||
assert!(result.is_err());
|
assert_err!(&result);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
result.unwrap_err().kind(),
|
result.unwrap_err().kind(),
|
||||||
ErrorKind::DisplayHelpOnMissingArgumentOrSubcommand
|
ErrorKind::DisplayHelpOnMissingArgumentOrSubcommand
|
||||||
@@ -45,21 +45,21 @@ mod tests {
|
|||||||
let result =
|
let result =
|
||||||
Cli::command().try_get_matches_from(["managarr", "radarr", "get", "all-indexer-settings"]);
|
Cli::command().try_get_matches_from(["managarr", "radarr", "get", "all-indexer-settings"]);
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_sonarr_subcommand_delegates_to_sonarr() {
|
fn test_sonarr_subcommand_delegates_to_sonarr() {
|
||||||
let result = Cli::command().try_get_matches_from(["managarr", "sonarr", "list", "series"]);
|
let result = Cli::command().try_get_matches_from(["managarr", "sonarr", "list", "series"]);
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_completions_requires_argument() {
|
fn test_completions_requires_argument() {
|
||||||
let result = Cli::command().try_get_matches_from(["managarr", "completions"]);
|
let result = Cli::command().try_get_matches_from(["managarr", "completions"]);
|
||||||
|
|
||||||
assert!(result.is_err());
|
assert_err!(&result);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
result.unwrap_err().kind(),
|
result.unwrap_err().kind(),
|
||||||
ErrorKind::DisplayHelpOnMissingArgumentOrSubcommand
|
ErrorKind::DisplayHelpOnMissingArgumentOrSubcommand
|
||||||
@@ -70,7 +70,7 @@ mod tests {
|
|||||||
fn test_completions_invalid_argument() {
|
fn test_completions_invalid_argument() {
|
||||||
let result = Cli::command().try_get_matches_from(["managarr", "completions", "test"]);
|
let result = Cli::command().try_get_matches_from(["managarr", "completions", "test"]);
|
||||||
|
|
||||||
assert!(result.is_err());
|
assert_err!(&result);
|
||||||
assert_eq!(result.unwrap_err().kind(), ErrorKind::InvalidValue);
|
assert_eq!(result.unwrap_err().kind(), ErrorKind::InvalidValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -78,7 +78,7 @@ mod tests {
|
|||||||
fn test_completions_satisfied_with_argument() {
|
fn test_completions_satisfied_with_argument() {
|
||||||
let result = Cli::command().try_get_matches_from(["managarr", "completions", "bash"]);
|
let result = Cli::command().try_get_matches_from(["managarr", "completions", "bash"]);
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[rstest]
|
#[rstest]
|
||||||
@@ -141,7 +141,7 @@ mod tests {
|
|||||||
|
|
||||||
let result = handle_command(&app_arc, clear_blocklist_command, &mut mock_network).await;
|
let result = handle_command(&app_arc, clear_blocklist_command, &mut mock_network).await;
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
@@ -172,6 +172,6 @@ mod tests {
|
|||||||
|
|
||||||
let result = handle_command(&app_arc, clear_blocklist_command, &mut mock_network).await;
|
let result = handle_command(&app_arc, clear_blocklist_command, &mut mock_network).await;
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use clap::{command, Subcommand};
|
use clap::{Subcommand, command};
|
||||||
use clap_complete::Shell;
|
use clap_complete::Shell;
|
||||||
use radarr::{RadarrCliHandler, RadarrCommand};
|
use radarr::{RadarrCliHandler, RadarrCommand};
|
||||||
use sonarr::{SonarrCliHandler, SonarrCommand};
|
use sonarr::{SonarrCliHandler, SonarrCommand};
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use clap::{arg, command, ArgAction, Subcommand};
|
use clap::{ArgAction, Subcommand, arg, command};
|
||||||
use tokio::sync::Mutex;
|
use tokio::sync::Mutex;
|
||||||
|
|
||||||
use super::RadarrCommand;
|
use super::RadarrCommand;
|
||||||
@@ -10,7 +10,7 @@ use crate::{
|
|||||||
app::App,
|
app::App,
|
||||||
cli::{CliCommandHandler, Command},
|
cli::{CliCommandHandler, Command},
|
||||||
models::radarr_models::{AddMovieBody, AddMovieOptions, MinimumAvailability, MovieMonitor},
|
models::radarr_models::{AddMovieBody, AddMovieOptions, MinimumAvailability, MovieMonitor},
|
||||||
network::{radarr_network::RadarrEvent, NetworkTrait},
|
network::{NetworkTrait, radarr_network::RadarrEvent},
|
||||||
};
|
};
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use clap::{error::ErrorKind, CommandFactory, Parser};
|
use clap::{CommandFactory, Parser, error::ErrorKind};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
|
Cli,
|
||||||
cli::{
|
cli::{
|
||||||
radarr::{add_command_handler::RadarrAddCommand, RadarrCommand},
|
|
||||||
Command,
|
Command,
|
||||||
|
radarr::{RadarrCommand, add_command_handler::RadarrAddCommand},
|
||||||
},
|
},
|
||||||
models::radarr_models::{MinimumAvailability, MovieMonitor},
|
models::radarr_models::{MinimumAvailability, MovieMonitor},
|
||||||
Cli,
|
|
||||||
};
|
};
|
||||||
use pretty_assertions::assert_eq;
|
use pretty_assertions::assert_eq;
|
||||||
|
|
||||||
@@ -32,7 +32,7 @@ mod tests {
|
|||||||
fn test_add_movie_requires_arguments() {
|
fn test_add_movie_requires_arguments() {
|
||||||
let result = Cli::command().try_get_matches_from(["managarr", "radarr", "add", "movie"]);
|
let result = Cli::command().try_get_matches_from(["managarr", "radarr", "add", "movie"]);
|
||||||
|
|
||||||
assert!(result.is_err());
|
assert_err!(&result);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
result.unwrap_err().kind(),
|
result.unwrap_err().kind(),
|
||||||
ErrorKind::MissingRequiredArgument
|
ErrorKind::MissingRequiredArgument
|
||||||
@@ -52,7 +52,7 @@ mod tests {
|
|||||||
"1",
|
"1",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_err());
|
assert_err!(&result);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
result.unwrap_err().kind(),
|
result.unwrap_err().kind(),
|
||||||
ErrorKind::MissingRequiredArgument
|
ErrorKind::MissingRequiredArgument
|
||||||
@@ -72,7 +72,7 @@ mod tests {
|
|||||||
"/test",
|
"/test",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_err());
|
assert_err!(&result);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
result.unwrap_err().kind(),
|
result.unwrap_err().kind(),
|
||||||
ErrorKind::MissingRequiredArgument
|
ErrorKind::MissingRequiredArgument
|
||||||
@@ -92,7 +92,7 @@ mod tests {
|
|||||||
"1",
|
"1",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_err());
|
assert_err!(&result);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
result.unwrap_err().kind(),
|
result.unwrap_err().kind(),
|
||||||
ErrorKind::MissingRequiredArgument
|
ErrorKind::MissingRequiredArgument
|
||||||
@@ -117,7 +117,7 @@ mod tests {
|
|||||||
flag,
|
flag,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_err());
|
assert_err!(&result);
|
||||||
assert_eq!(result.unwrap_err().kind(), ErrorKind::InvalidValue);
|
assert_eq!(result.unwrap_err().kind(), ErrorKind::InvalidValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -136,7 +136,7 @@ mod tests {
|
|||||||
"1",
|
"1",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -156,7 +156,7 @@ mod tests {
|
|||||||
"test",
|
"test",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_err());
|
assert_err!(&result);
|
||||||
assert_eq!(result.unwrap_err().kind(), ErrorKind::InvalidValue);
|
assert_eq!(result.unwrap_err().kind(), ErrorKind::InvalidValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -177,7 +177,7 @@ mod tests {
|
|||||||
"test",
|
"test",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_err());
|
assert_err!(&result);
|
||||||
assert_eq!(result.unwrap_err().kind(), ErrorKind::InvalidValue);
|
assert_eq!(result.unwrap_err().kind(), ErrorKind::InvalidValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -207,10 +207,11 @@ mod tests {
|
|||||||
"1",
|
"1",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
if let Some(Command::Radarr(RadarrCommand::Add(add_command))) = result.unwrap().command {
|
let Some(Command::Radarr(RadarrCommand::Add(add_command))) = result.unwrap().command else {
|
||||||
assert_eq!(add_command, expected_args);
|
panic!("Unexpected command type")
|
||||||
}
|
};
|
||||||
|
assert_eq!(add_command, expected_args);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -243,10 +244,11 @@ mod tests {
|
|||||||
"2",
|
"2",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
if let Some(Command::Radarr(RadarrCommand::Add(add_command))) = result.unwrap().command {
|
let Some(Command::Radarr(RadarrCommand::Add(add_command))) = result.unwrap().command else {
|
||||||
assert_eq!(add_command, expected_args);
|
panic!("Unexpected command type")
|
||||||
}
|
};
|
||||||
|
assert_eq!(add_command, expected_args);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -285,10 +287,11 @@ mod tests {
|
|||||||
"--no-search-for-movie",
|
"--no-search-for-movie",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
if let Some(Command::Radarr(RadarrCommand::Add(add_command))) = result.unwrap().command {
|
let Some(Command::Radarr(RadarrCommand::Add(add_command))) = result.unwrap().command else {
|
||||||
assert_eq!(add_command, expected_args);
|
panic!("Unexpected command type")
|
||||||
}
|
};
|
||||||
|
assert_eq!(add_command, expected_args);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -296,7 +299,7 @@ mod tests {
|
|||||||
let result =
|
let result =
|
||||||
Cli::command().try_get_matches_from(["managarr", "radarr", "add", "root-folder"]);
|
Cli::command().try_get_matches_from(["managarr", "radarr", "add", "root-folder"]);
|
||||||
|
|
||||||
assert!(result.is_err());
|
assert_err!(&result);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
result.unwrap_err().kind(),
|
result.unwrap_err().kind(),
|
||||||
ErrorKind::MissingRequiredArgument
|
ErrorKind::MissingRequiredArgument
|
||||||
@@ -318,18 +321,19 @@ mod tests {
|
|||||||
"/nfs/test",
|
"/nfs/test",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
|
|
||||||
if let Some(Command::Radarr(RadarrCommand::Add(add_command))) = result.unwrap().command {
|
let Some(Command::Radarr(RadarrCommand::Add(add_command))) = result.unwrap().command else {
|
||||||
assert_eq!(add_command, expected_args);
|
panic!("Unexpected command type")
|
||||||
}
|
};
|
||||||
|
assert_eq!(add_command, expected_args);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_add_tag_requires_arguments() {
|
fn test_add_tag_requires_arguments() {
|
||||||
let result = Cli::command().try_get_matches_from(["managarr", "radarr", "add", "tag"]);
|
let result = Cli::command().try_get_matches_from(["managarr", "radarr", "add", "tag"]);
|
||||||
|
|
||||||
assert!(result.is_err());
|
assert_err!(&result);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
result.unwrap_err().kind(),
|
result.unwrap_err().kind(),
|
||||||
ErrorKind::MissingRequiredArgument
|
ErrorKind::MissingRequiredArgument
|
||||||
@@ -344,11 +348,12 @@ mod tests {
|
|||||||
|
|
||||||
let result = Cli::try_parse_from(["managarr", "radarr", "add", "tag", "--name", "test"]);
|
let result = Cli::try_parse_from(["managarr", "radarr", "add", "tag", "--name", "test"]);
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
|
|
||||||
if let Some(Command::Radarr(RadarrCommand::Add(add_command))) = result.unwrap().command {
|
let Some(Command::Radarr(RadarrCommand::Add(add_command))) = result.unwrap().command else {
|
||||||
assert_eq!(add_command, expected_args);
|
panic!("Unexpected command type")
|
||||||
}
|
};
|
||||||
|
assert_eq!(add_command, expected_args);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -357,12 +362,12 @@ mod tests {
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
app::App,
|
app::App,
|
||||||
cli::{radarr::add_command_handler::RadarrAddCommandHandler, CliCommandHandler},
|
cli::{CliCommandHandler, radarr::add_command_handler::RadarrAddCommandHandler},
|
||||||
models::{
|
models::{
|
||||||
radarr_models::{AddMovieBody, AddMovieOptions, RadarrSerdeable},
|
|
||||||
Serdeable,
|
Serdeable,
|
||||||
|
radarr_models::{AddMovieBody, AddMovieOptions, RadarrSerdeable},
|
||||||
},
|
},
|
||||||
network::{radarr_network::RadarrEvent, MockNetworkTrait, NetworkEvent},
|
network::{MockNetworkTrait, NetworkEvent, radarr_network::RadarrEvent},
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
@@ -416,7 +421,7 @@ mod tests {
|
|||||||
.handle()
|
.handle()
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
@@ -447,7 +452,7 @@ mod tests {
|
|||||||
.handle()
|
.handle()
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
@@ -474,7 +479,7 @@ mod tests {
|
|||||||
.handle()
|
.handle()
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ use crate::{
|
|||||||
app::App,
|
app::App,
|
||||||
cli::{CliCommandHandler, Command},
|
cli::{CliCommandHandler, Command},
|
||||||
models::radarr_models::DeleteMovieParams,
|
models::radarr_models::DeleteMovieParams,
|
||||||
network::{radarr_network::RadarrEvent, NetworkTrait},
|
network::{NetworkTrait, radarr_network::RadarrEvent},
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::RadarrCommand;
|
use super::RadarrCommand;
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use crate::{
|
use crate::{
|
||||||
cli::{
|
|
||||||
radarr::{delete_command_handler::RadarrDeleteCommand, RadarrCommand},
|
|
||||||
Command,
|
|
||||||
},
|
|
||||||
Cli,
|
Cli,
|
||||||
|
cli::{
|
||||||
|
Command,
|
||||||
|
radarr::{RadarrCommand, delete_command_handler::RadarrDeleteCommand},
|
||||||
|
},
|
||||||
};
|
};
|
||||||
use clap::{error::ErrorKind, CommandFactory, Parser};
|
use clap::{CommandFactory, Parser, error::ErrorKind};
|
||||||
use pretty_assertions::assert_eq;
|
use pretty_assertions::assert_eq;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -30,7 +30,7 @@ mod tests {
|
|||||||
let result =
|
let result =
|
||||||
Cli::command().try_get_matches_from(["managarr", "radarr", "delete", "blocklist-item"]);
|
Cli::command().try_get_matches_from(["managarr", "radarr", "delete", "blocklist-item"]);
|
||||||
|
|
||||||
assert!(result.is_err());
|
assert_err!(&result);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
result.unwrap_err().kind(),
|
result.unwrap_err().kind(),
|
||||||
ErrorKind::MissingRequiredArgument
|
ErrorKind::MissingRequiredArgument
|
||||||
@@ -52,12 +52,13 @@ mod tests {
|
|||||||
"1",
|
"1",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
|
|
||||||
if let Some(Command::Radarr(RadarrCommand::Delete(delete_command))) = result.unwrap().command
|
let Some(Command::Radarr(RadarrCommand::Delete(delete_command))) = result.unwrap().command
|
||||||
{
|
else {
|
||||||
assert_eq!(delete_command, expected_args);
|
panic!("Unexpected command type");
|
||||||
}
|
};
|
||||||
|
assert_eq!(delete_command, expected_args);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -65,7 +66,7 @@ mod tests {
|
|||||||
let result =
|
let result =
|
||||||
Cli::command().try_get_matches_from(["managarr", "radarr", "delete", "download"]);
|
Cli::command().try_get_matches_from(["managarr", "radarr", "delete", "download"]);
|
||||||
|
|
||||||
assert!(result.is_err());
|
assert_err!(&result);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
result.unwrap_err().kind(),
|
result.unwrap_err().kind(),
|
||||||
ErrorKind::MissingRequiredArgument
|
ErrorKind::MissingRequiredArgument
|
||||||
@@ -85,19 +86,20 @@ mod tests {
|
|||||||
"1",
|
"1",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
|
|
||||||
if let Some(Command::Radarr(RadarrCommand::Delete(delete_command))) = result.unwrap().command
|
let Some(Command::Radarr(RadarrCommand::Delete(delete_command))) = result.unwrap().command
|
||||||
{
|
else {
|
||||||
assert_eq!(delete_command, expected_args);
|
panic!("Unexpected command type");
|
||||||
}
|
};
|
||||||
|
assert_eq!(delete_command, expected_args);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_delete_indexer_requires_arguments() {
|
fn test_delete_indexer_requires_arguments() {
|
||||||
let result = Cli::command().try_get_matches_from(["managarr", "radarr", "delete", "indexer"]);
|
let result = Cli::command().try_get_matches_from(["managarr", "radarr", "delete", "indexer"]);
|
||||||
|
|
||||||
assert!(result.is_err());
|
assert_err!(&result);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
result.unwrap_err().kind(),
|
result.unwrap_err().kind(),
|
||||||
ErrorKind::MissingRequiredArgument
|
ErrorKind::MissingRequiredArgument
|
||||||
@@ -117,19 +119,20 @@ mod tests {
|
|||||||
"1",
|
"1",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
|
|
||||||
if let Some(Command::Radarr(RadarrCommand::Delete(delete_command))) = result.unwrap().command
|
let Some(Command::Radarr(RadarrCommand::Delete(delete_command))) = result.unwrap().command
|
||||||
{
|
else {
|
||||||
assert_eq!(delete_command, expected_args);
|
panic!("Unexpected command type");
|
||||||
}
|
};
|
||||||
|
assert_eq!(delete_command, expected_args);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_delete_movie_requires_arguments() {
|
fn test_delete_movie_requires_arguments() {
|
||||||
let result = Cli::command().try_get_matches_from(["managarr", "radarr", "delete", "movie"]);
|
let result = Cli::command().try_get_matches_from(["managarr", "radarr", "delete", "movie"]);
|
||||||
|
|
||||||
assert!(result.is_err());
|
assert_err!(&result);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
result.unwrap_err().kind(),
|
result.unwrap_err().kind(),
|
||||||
ErrorKind::MissingRequiredArgument
|
ErrorKind::MissingRequiredArgument
|
||||||
@@ -147,12 +150,13 @@ mod tests {
|
|||||||
let result =
|
let result =
|
||||||
Cli::try_parse_from(["managarr", "radarr", "delete", "movie", "--movie-id", "1"]);
|
Cli::try_parse_from(["managarr", "radarr", "delete", "movie", "--movie-id", "1"]);
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
|
|
||||||
if let Some(Command::Radarr(RadarrCommand::Delete(delete_command))) = result.unwrap().command
|
let Some(Command::Radarr(RadarrCommand::Delete(delete_command))) = result.unwrap().command
|
||||||
{
|
else {
|
||||||
assert_eq!(delete_command, expected_args);
|
panic!("Unexpected command type");
|
||||||
}
|
};
|
||||||
|
assert_eq!(delete_command, expected_args);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -174,12 +178,13 @@ mod tests {
|
|||||||
"--add-list-exclusion",
|
"--add-list-exclusion",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
|
|
||||||
if let Some(Command::Radarr(RadarrCommand::Delete(delete_command))) = result.unwrap().command
|
let Some(Command::Radarr(RadarrCommand::Delete(delete_command))) = result.unwrap().command
|
||||||
{
|
else {
|
||||||
assert_eq!(delete_command, expected_args);
|
panic!("Unexpected command type");
|
||||||
}
|
};
|
||||||
|
assert_eq!(delete_command, expected_args);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -187,7 +192,7 @@ mod tests {
|
|||||||
let result =
|
let result =
|
||||||
Cli::command().try_get_matches_from(["managarr", "radarr", "delete", "root-folder"]);
|
Cli::command().try_get_matches_from(["managarr", "radarr", "delete", "root-folder"]);
|
||||||
|
|
||||||
assert!(result.is_err());
|
assert_err!(&result);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
result.unwrap_err().kind(),
|
result.unwrap_err().kind(),
|
||||||
ErrorKind::MissingRequiredArgument
|
ErrorKind::MissingRequiredArgument
|
||||||
@@ -207,19 +212,20 @@ mod tests {
|
|||||||
"1",
|
"1",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
|
|
||||||
if let Some(Command::Radarr(RadarrCommand::Delete(delete_command))) = result.unwrap().command
|
let Some(Command::Radarr(RadarrCommand::Delete(delete_command))) = result.unwrap().command
|
||||||
{
|
else {
|
||||||
assert_eq!(delete_command, expected_args);
|
panic!("Unexpected command type");
|
||||||
}
|
};
|
||||||
|
assert_eq!(delete_command, expected_args);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_delete_tag_requires_arguments() {
|
fn test_delete_tag_requires_arguments() {
|
||||||
let result = Cli::command().try_get_matches_from(["managarr", "radarr", "delete", "tag"]);
|
let result = Cli::command().try_get_matches_from(["managarr", "radarr", "delete", "tag"]);
|
||||||
|
|
||||||
assert!(result.is_err());
|
assert_err!(&result);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
result.unwrap_err().kind(),
|
result.unwrap_err().kind(),
|
||||||
ErrorKind::MissingRequiredArgument
|
ErrorKind::MissingRequiredArgument
|
||||||
@@ -232,12 +238,13 @@ mod tests {
|
|||||||
|
|
||||||
let result = Cli::try_parse_from(["managarr", "radarr", "delete", "tag", "--tag-id", "1"]);
|
let result = Cli::try_parse_from(["managarr", "radarr", "delete", "tag", "--tag-id", "1"]);
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
|
|
||||||
if let Some(Command::Radarr(RadarrCommand::Delete(delete_command))) = result.unwrap().command
|
let Some(Command::Radarr(RadarrCommand::Delete(delete_command))) = result.unwrap().command
|
||||||
{
|
else {
|
||||||
assert_eq!(delete_command, expected_args);
|
panic!("Unexpected command type");
|
||||||
}
|
};
|
||||||
|
assert_eq!(delete_command, expected_args);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -251,14 +258,14 @@ mod tests {
|
|||||||
use crate::{
|
use crate::{
|
||||||
app::App,
|
app::App,
|
||||||
cli::{
|
cli::{
|
||||||
radarr::delete_command_handler::{RadarrDeleteCommand, RadarrDeleteCommandHandler},
|
|
||||||
CliCommandHandler,
|
CliCommandHandler,
|
||||||
|
radarr::delete_command_handler::{RadarrDeleteCommand, RadarrDeleteCommandHandler},
|
||||||
},
|
},
|
||||||
models::{
|
models::{
|
||||||
radarr_models::{DeleteMovieParams, RadarrSerdeable},
|
|
||||||
Serdeable,
|
Serdeable,
|
||||||
|
radarr_models::{DeleteMovieParams, RadarrSerdeable},
|
||||||
},
|
},
|
||||||
network::{radarr_network::RadarrEvent, MockNetworkTrait, NetworkEvent},
|
network::{MockNetworkTrait, NetworkEvent, radarr_network::RadarrEvent},
|
||||||
};
|
};
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
@@ -289,7 +296,7 @@ mod tests {
|
|||||||
.handle()
|
.handle()
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
@@ -315,7 +322,7 @@ mod tests {
|
|||||||
.handle()
|
.handle()
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
@@ -341,7 +348,7 @@ mod tests {
|
|||||||
.handle()
|
.handle()
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
@@ -375,7 +382,7 @@ mod tests {
|
|||||||
.handle()
|
.handle()
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
@@ -401,7 +408,7 @@ mod tests {
|
|||||||
.handle()
|
.handle()
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
@@ -427,7 +434,7 @@ mod tests {
|
|||||||
.handle()
|
.handle()
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,15 +6,15 @@ use tokio::sync::Mutex;
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
app::App,
|
app::App,
|
||||||
cli::{mutex_flags_or_default, mutex_flags_or_option, CliCommandHandler, Command},
|
cli::{CliCommandHandler, Command, mutex_flags_or_default, mutex_flags_or_option},
|
||||||
models::{
|
models::{
|
||||||
|
Serdeable,
|
||||||
radarr_models::{
|
radarr_models::{
|
||||||
EditCollectionParams, EditMovieParams, IndexerSettings, MinimumAvailability, RadarrSerdeable,
|
EditCollectionParams, EditMovieParams, IndexerSettings, MinimumAvailability, RadarrSerdeable,
|
||||||
},
|
},
|
||||||
servarr_models::EditIndexerParams,
|
servarr_models::EditIndexerParams,
|
||||||
Serdeable,
|
|
||||||
},
|
},
|
||||||
network::{radarr_network::RadarrEvent, NetworkTrait},
|
network::{NetworkTrait, radarr_network::RadarrEvent},
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::RadarrCommand;
|
use super::RadarrCommand;
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use crate::{
|
use crate::{
|
||||||
cli::{
|
|
||||||
radarr::{edit_command_handler::RadarrEditCommand, RadarrCommand},
|
|
||||||
Command,
|
|
||||||
},
|
|
||||||
Cli,
|
Cli,
|
||||||
|
cli::{
|
||||||
|
Command,
|
||||||
|
radarr::{RadarrCommand, edit_command_handler::RadarrEditCommand},
|
||||||
|
},
|
||||||
};
|
};
|
||||||
use clap::{error::ErrorKind, CommandFactory, Parser};
|
use clap::{CommandFactory, Parser, error::ErrorKind};
|
||||||
use pretty_assertions::assert_eq;
|
use pretty_assertions::assert_eq;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -42,7 +42,7 @@ mod tests {
|
|||||||
let result =
|
let result =
|
||||||
Cli::command().try_get_matches_from(["managarr", "radarr", "edit", "all-indexer-settings"]);
|
Cli::command().try_get_matches_from(["managarr", "radarr", "edit", "all-indexer-settings"]);
|
||||||
|
|
||||||
assert!(result.is_err());
|
assert_err!(&result);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
result.unwrap_err().kind(),
|
result.unwrap_err().kind(),
|
||||||
ErrorKind::MissingRequiredArgument
|
ErrorKind::MissingRequiredArgument
|
||||||
@@ -60,7 +60,7 @@ mod tests {
|
|||||||
"--disable-allow-hardcoded-subs",
|
"--disable-allow-hardcoded-subs",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_err());
|
assert_err!(&result);
|
||||||
assert_eq!(result.unwrap_err().kind(), ErrorKind::ArgumentConflict);
|
assert_eq!(result.unwrap_err().kind(), ErrorKind::ArgumentConflict);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -75,7 +75,7 @@ mod tests {
|
|||||||
"--disable-prefer-indexer-flags",
|
"--disable-prefer-indexer-flags",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_err());
|
assert_err!(&result);
|
||||||
assert_eq!(result.unwrap_err().kind(), ErrorKind::ArgumentConflict);
|
assert_eq!(result.unwrap_err().kind(), ErrorKind::ArgumentConflict);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -99,7 +99,7 @@ mod tests {
|
|||||||
flag,
|
flag,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_err());
|
assert_err!(&result);
|
||||||
assert_eq!(result.unwrap_err().kind(), ErrorKind::InvalidValue);
|
assert_eq!(result.unwrap_err().kind(), ErrorKind::InvalidValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -126,11 +126,12 @@ mod tests {
|
|||||||
"1",
|
"1",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
|
|
||||||
if let Some(Command::Radarr(RadarrCommand::Edit(edit_command))) = result.unwrap().command {
|
let Some(Command::Radarr(RadarrCommand::Edit(edit_command))) = result.unwrap().command else {
|
||||||
assert_eq!(edit_command, expected_args);
|
panic!("Unexpected command type");
|
||||||
}
|
};
|
||||||
|
assert_eq!(edit_command, expected_args);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -168,11 +169,12 @@ mod tests {
|
|||||||
"test",
|
"test",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
|
|
||||||
if let Some(Command::Radarr(RadarrCommand::Edit(edit_command))) = result.unwrap().command {
|
let Some(Command::Radarr(RadarrCommand::Edit(edit_command))) = result.unwrap().command else {
|
||||||
assert_eq!(edit_command, expected_args);
|
panic!("Unexpected command type");
|
||||||
}
|
};
|
||||||
|
assert_eq!(edit_command, expected_args);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -180,7 +182,7 @@ mod tests {
|
|||||||
let result =
|
let result =
|
||||||
Cli::command().try_get_matches_from(["managarr", "radarr", "edit", "collection"]);
|
Cli::command().try_get_matches_from(["managarr", "radarr", "edit", "collection"]);
|
||||||
|
|
||||||
assert!(result.is_err());
|
assert_err!(&result);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
result.unwrap_err().kind(),
|
result.unwrap_err().kind(),
|
||||||
ErrorKind::MissingRequiredArgument
|
ErrorKind::MissingRequiredArgument
|
||||||
@@ -198,7 +200,7 @@ mod tests {
|
|||||||
"1",
|
"1",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_err());
|
assert_err!(&result);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
result.unwrap_err().kind(),
|
result.unwrap_err().kind(),
|
||||||
ErrorKind::MissingRequiredArgument
|
ErrorKind::MissingRequiredArgument
|
||||||
@@ -218,7 +220,7 @@ mod tests {
|
|||||||
"--disable-monitoring",
|
"--disable-monitoring",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_err());
|
assert_err!(&result);
|
||||||
assert_eq!(result.unwrap_err().kind(), ErrorKind::ArgumentConflict);
|
assert_eq!(result.unwrap_err().kind(), ErrorKind::ArgumentConflict);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -235,7 +237,7 @@ mod tests {
|
|||||||
"--disable-search-on-add",
|
"--disable-search-on-add",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_err());
|
assert_err!(&result);
|
||||||
assert_eq!(result.unwrap_err().kind(), ErrorKind::ArgumentConflict);
|
assert_eq!(result.unwrap_err().kind(), ErrorKind::ArgumentConflict);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -252,7 +254,7 @@ mod tests {
|
|||||||
"test",
|
"test",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_err());
|
assert_err!(&result);
|
||||||
assert_eq!(result.unwrap_err().kind(), ErrorKind::InvalidValue);
|
assert_eq!(result.unwrap_err().kind(), ErrorKind::InvalidValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -270,7 +272,7 @@ mod tests {
|
|||||||
flag,
|
flag,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_err());
|
assert_err!(&result);
|
||||||
assert_eq!(result.unwrap_err().kind(), ErrorKind::InvalidValue);
|
assert_eq!(result.unwrap_err().kind(), ErrorKind::InvalidValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -298,11 +300,12 @@ mod tests {
|
|||||||
"/test",
|
"/test",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
|
|
||||||
if let Some(Command::Radarr(RadarrCommand::Edit(edit_command))) = result.unwrap().command {
|
let Some(Command::Radarr(RadarrCommand::Edit(edit_command))) = result.unwrap().command else {
|
||||||
assert_eq!(edit_command, expected_args);
|
panic!("Unexpected command type");
|
||||||
}
|
};
|
||||||
|
assert_eq!(edit_command, expected_args);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -334,18 +337,19 @@ mod tests {
|
|||||||
"--search-on-add",
|
"--search-on-add",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
|
|
||||||
if let Some(Command::Radarr(RadarrCommand::Edit(edit_command))) = result.unwrap().command {
|
let Some(Command::Radarr(RadarrCommand::Edit(edit_command))) = result.unwrap().command else {
|
||||||
assert_eq!(edit_command, expected_args);
|
panic!("Unexpected command type");
|
||||||
}
|
};
|
||||||
|
assert_eq!(edit_command, expected_args);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_edit_indexer_requires_arguments() {
|
fn test_edit_indexer_requires_arguments() {
|
||||||
let result = Cli::command().try_get_matches_from(["managarr", "radarr", "edit", "indexer"]);
|
let result = Cli::command().try_get_matches_from(["managarr", "radarr", "edit", "indexer"]);
|
||||||
|
|
||||||
assert!(result.is_err());
|
assert_err!(&result);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
result.unwrap_err().kind(),
|
result.unwrap_err().kind(),
|
||||||
ErrorKind::MissingRequiredArgument
|
ErrorKind::MissingRequiredArgument
|
||||||
@@ -363,7 +367,7 @@ mod tests {
|
|||||||
"1",
|
"1",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_err());
|
assert_err!(&result);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
result.unwrap_err().kind(),
|
result.unwrap_err().kind(),
|
||||||
ErrorKind::MissingRequiredArgument
|
ErrorKind::MissingRequiredArgument
|
||||||
@@ -383,7 +387,7 @@ mod tests {
|
|||||||
"--disable-rss",
|
"--disable-rss",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_err());
|
assert_err!(&result);
|
||||||
assert_eq!(result.unwrap_err().kind(), ErrorKind::ArgumentConflict);
|
assert_eq!(result.unwrap_err().kind(), ErrorKind::ArgumentConflict);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -400,7 +404,7 @@ mod tests {
|
|||||||
"--disable-automatic-search",
|
"--disable-automatic-search",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_err());
|
assert_err!(&result);
|
||||||
assert_eq!(result.unwrap_err().kind(), ErrorKind::ArgumentConflict);
|
assert_eq!(result.unwrap_err().kind(), ErrorKind::ArgumentConflict);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -417,7 +421,7 @@ mod tests {
|
|||||||
"--disable-interactive-search",
|
"--disable-interactive-search",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_err());
|
assert_err!(&result);
|
||||||
assert_eq!(result.unwrap_err().kind(), ErrorKind::ArgumentConflict);
|
assert_eq!(result.unwrap_err().kind(), ErrorKind::ArgumentConflict);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -435,7 +439,7 @@ mod tests {
|
|||||||
"--clear-tags",
|
"--clear-tags",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_err());
|
assert_err!(&result);
|
||||||
assert_eq!(result.unwrap_err().kind(), ErrorKind::ArgumentConflict);
|
assert_eq!(result.unwrap_err().kind(), ErrorKind::ArgumentConflict);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -453,7 +457,7 @@ mod tests {
|
|||||||
flag,
|
flag,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_err());
|
assert_err!(&result);
|
||||||
assert_eq!(result.unwrap_err().kind(), ErrorKind::InvalidValue);
|
assert_eq!(result.unwrap_err().kind(), ErrorKind::InvalidValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -487,11 +491,12 @@ mod tests {
|
|||||||
"Test",
|
"Test",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
|
|
||||||
if let Some(Command::Radarr(RadarrCommand::Edit(edit_command))) = result.unwrap().command {
|
let Some(Command::Radarr(RadarrCommand::Edit(edit_command))) = result.unwrap().command else {
|
||||||
assert_eq!(edit_command, expected_args);
|
panic!("Unexpected command type");
|
||||||
}
|
};
|
||||||
|
assert_eq!(edit_command, expected_args);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -526,11 +531,12 @@ mod tests {
|
|||||||
"2",
|
"2",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
|
|
||||||
if let Some(Command::Radarr(RadarrCommand::Edit(edit_command))) = result.unwrap().command {
|
let Some(Command::Radarr(RadarrCommand::Edit(edit_command))) = result.unwrap().command else {
|
||||||
assert_eq!(edit_command, expected_args);
|
panic!("Unexpected command type");
|
||||||
}
|
};
|
||||||
|
assert_eq!(edit_command, expected_args);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -578,18 +584,19 @@ mod tests {
|
|||||||
"25",
|
"25",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
|
|
||||||
if let Some(Command::Radarr(RadarrCommand::Edit(edit_command))) = result.unwrap().command {
|
let Some(Command::Radarr(RadarrCommand::Edit(edit_command))) = result.unwrap().command else {
|
||||||
assert_eq!(edit_command, expected_args);
|
panic!("Unexpected command type");
|
||||||
}
|
};
|
||||||
|
assert_eq!(edit_command, expected_args);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_edit_movie_requires_arguments() {
|
fn test_edit_movie_requires_arguments() {
|
||||||
let result = Cli::command().try_get_matches_from(["managarr", "radarr", "edit", "movie"]);
|
let result = Cli::command().try_get_matches_from(["managarr", "radarr", "edit", "movie"]);
|
||||||
|
|
||||||
assert!(result.is_err());
|
assert_err!(&result);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
result.unwrap_err().kind(),
|
result.unwrap_err().kind(),
|
||||||
ErrorKind::MissingRequiredArgument
|
ErrorKind::MissingRequiredArgument
|
||||||
@@ -607,7 +614,7 @@ mod tests {
|
|||||||
"1",
|
"1",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_err());
|
assert_err!(&result);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
result.unwrap_err().kind(),
|
result.unwrap_err().kind(),
|
||||||
ErrorKind::MissingRequiredArgument
|
ErrorKind::MissingRequiredArgument
|
||||||
@@ -627,7 +634,7 @@ mod tests {
|
|||||||
"--disable-monitoring",
|
"--disable-monitoring",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_err());
|
assert_err!(&result);
|
||||||
assert_eq!(result.unwrap_err().kind(), ErrorKind::ArgumentConflict);
|
assert_eq!(result.unwrap_err().kind(), ErrorKind::ArgumentConflict);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -645,7 +652,7 @@ mod tests {
|
|||||||
"--clear-tags",
|
"--clear-tags",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_err());
|
assert_err!(&result);
|
||||||
assert_eq!(result.unwrap_err().kind(), ErrorKind::ArgumentConflict);
|
assert_eq!(result.unwrap_err().kind(), ErrorKind::ArgumentConflict);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -669,7 +676,7 @@ mod tests {
|
|||||||
flag,
|
flag,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_err());
|
assert_err!(&result);
|
||||||
assert_eq!(result.unwrap_err().kind(), ErrorKind::InvalidValue);
|
assert_eq!(result.unwrap_err().kind(), ErrorKind::InvalidValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -686,7 +693,7 @@ mod tests {
|
|||||||
"test",
|
"test",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_err());
|
assert_err!(&result);
|
||||||
assert_eq!(result.unwrap_err().kind(), ErrorKind::InvalidValue);
|
assert_eq!(result.unwrap_err().kind(), ErrorKind::InvalidValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -714,11 +721,12 @@ mod tests {
|
|||||||
"/nfs/test",
|
"/nfs/test",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
|
|
||||||
if let Some(Command::Radarr(RadarrCommand::Edit(edit_command))) = result.unwrap().command {
|
let Some(Command::Radarr(RadarrCommand::Edit(edit_command))) = result.unwrap().command else {
|
||||||
assert_eq!(edit_command, expected_args);
|
panic!("Unexpected command type");
|
||||||
}
|
};
|
||||||
|
assert_eq!(edit_command, expected_args);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -747,11 +755,12 @@ mod tests {
|
|||||||
"2",
|
"2",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
|
|
||||||
if let Some(Command::Radarr(RadarrCommand::Edit(edit_command))) = result.unwrap().command {
|
let Some(Command::Radarr(RadarrCommand::Edit(edit_command))) = result.unwrap().command else {
|
||||||
assert_eq!(edit_command, expected_args);
|
panic!("Unexpected command type");
|
||||||
}
|
};
|
||||||
|
assert_eq!(edit_command, expected_args);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -787,11 +796,12 @@ mod tests {
|
|||||||
"2",
|
"2",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
|
|
||||||
if let Some(Command::Radarr(RadarrCommand::Edit(edit_command))) = result.unwrap().command {
|
let Some(Command::Radarr(RadarrCommand::Edit(edit_command))) = result.unwrap().command else {
|
||||||
assert_eq!(edit_command, expected_args);
|
panic!("Unexpected command type");
|
||||||
}
|
};
|
||||||
|
assert_eq!(edit_command, expected_args);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -805,18 +815,18 @@ mod tests {
|
|||||||
use crate::{
|
use crate::{
|
||||||
app::App,
|
app::App,
|
||||||
cli::{
|
cli::{
|
||||||
radarr::edit_command_handler::{RadarrEditCommand, RadarrEditCommandHandler},
|
|
||||||
CliCommandHandler,
|
CliCommandHandler,
|
||||||
|
radarr::edit_command_handler::{RadarrEditCommand, RadarrEditCommandHandler},
|
||||||
},
|
},
|
||||||
models::{
|
models::{
|
||||||
|
Serdeable,
|
||||||
radarr_models::{
|
radarr_models::{
|
||||||
EditCollectionParams, EditMovieParams, IndexerSettings, MinimumAvailability,
|
EditCollectionParams, EditMovieParams, IndexerSettings, MinimumAvailability,
|
||||||
RadarrSerdeable,
|
RadarrSerdeable,
|
||||||
},
|
},
|
||||||
servarr_models::EditIndexerParams,
|
servarr_models::EditIndexerParams,
|
||||||
Serdeable,
|
|
||||||
},
|
},
|
||||||
network::{radarr_network::RadarrEvent, MockNetworkTrait, NetworkEvent},
|
network::{MockNetworkTrait, NetworkEvent, radarr_network::RadarrEvent},
|
||||||
};
|
};
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
@@ -887,7 +897,7 @@ mod tests {
|
|||||||
.handle()
|
.handle()
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
@@ -958,12 +968,12 @@ mod tests {
|
|||||||
.handle()
|
.handle()
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn test_handle_edit_all_indexer_settings_command_unprovided_values_default_to_previous_values(
|
async fn test_handle_edit_all_indexer_settings_command_unprovided_values_default_to_previous_values()
|
||||||
) {
|
{
|
||||||
let expected_edit_all_indexer_settings = IndexerSettings {
|
let expected_edit_all_indexer_settings = IndexerSettings {
|
||||||
allow_hardcoded_subs: true,
|
allow_hardcoded_subs: true,
|
||||||
availability_delay: 2,
|
availability_delay: 2,
|
||||||
@@ -1030,7 +1040,7 @@ mod tests {
|
|||||||
.handle()
|
.handle()
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
@@ -1072,7 +1082,7 @@ mod tests {
|
|||||||
.handle()
|
.handle()
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
@@ -1114,7 +1124,7 @@ mod tests {
|
|||||||
.handle()
|
.handle()
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
@@ -1156,7 +1166,7 @@ mod tests {
|
|||||||
.handle()
|
.handle()
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
@@ -1210,7 +1220,7 @@ mod tests {
|
|||||||
.handle()
|
.handle()
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
@@ -1264,7 +1274,7 @@ mod tests {
|
|||||||
.handle()
|
.handle()
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
@@ -1318,7 +1328,7 @@ mod tests {
|
|||||||
.handle()
|
.handle()
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
@@ -1361,7 +1371,7 @@ mod tests {
|
|||||||
.handle()
|
.handle()
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
@@ -1404,7 +1414,7 @@ mod tests {
|
|||||||
.handle()
|
.handle()
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
@@ -1447,7 +1457,7 @@ mod tests {
|
|||||||
.handle()
|
.handle()
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use clap::{command, Subcommand};
|
use clap::{Subcommand, command};
|
||||||
use tokio::sync::Mutex;
|
use tokio::sync::Mutex;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
app::App,
|
app::App,
|
||||||
cli::{CliCommandHandler, Command},
|
cli::{CliCommandHandler, Command},
|
||||||
network::{radarr_network::RadarrEvent, NetworkTrait},
|
network::{NetworkTrait, radarr_network::RadarrEvent},
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::RadarrCommand;
|
use super::RadarrCommand;
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use clap::error::ErrorKind;
|
|
||||||
use clap::CommandFactory;
|
use clap::CommandFactory;
|
||||||
|
use clap::error::ErrorKind;
|
||||||
|
|
||||||
use crate::cli::radarr::get_command_handler::RadarrGetCommand;
|
|
||||||
use crate::cli::radarr::RadarrCommand;
|
|
||||||
use crate::cli::Command;
|
|
||||||
use crate::Cli;
|
use crate::Cli;
|
||||||
|
use crate::cli::Command;
|
||||||
|
use crate::cli::radarr::RadarrCommand;
|
||||||
|
use crate::cli::radarr::get_command_handler::RadarrGetCommand;
|
||||||
use pretty_assertions::assert_eq;
|
use pretty_assertions::assert_eq;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -27,7 +27,7 @@ mod tests {
|
|||||||
let result =
|
let result =
|
||||||
Cli::command().try_get_matches_from(["managarr", "radarr", "get", "all-indexer-settings"]);
|
Cli::command().try_get_matches_from(["managarr", "radarr", "get", "all-indexer-settings"]);
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -35,7 +35,7 @@ mod tests {
|
|||||||
let result =
|
let result =
|
||||||
Cli::command().try_get_matches_from(["managarr", "radarr", "get", "host-config"]);
|
Cli::command().try_get_matches_from(["managarr", "radarr", "get", "host-config"]);
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -43,7 +43,7 @@ mod tests {
|
|||||||
let result =
|
let result =
|
||||||
Cli::command().try_get_matches_from(["managarr", "radarr", "get", "movie-details"]);
|
Cli::command().try_get_matches_from(["managarr", "radarr", "get", "movie-details"]);
|
||||||
|
|
||||||
assert!(result.is_err());
|
assert_err!(&result);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
result.unwrap_err().kind(),
|
result.unwrap_err().kind(),
|
||||||
ErrorKind::MissingRequiredArgument
|
ErrorKind::MissingRequiredArgument
|
||||||
@@ -61,7 +61,7 @@ mod tests {
|
|||||||
"1",
|
"1",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -69,7 +69,7 @@ mod tests {
|
|||||||
let result =
|
let result =
|
||||||
Cli::command().try_get_matches_from(["managarr", "radarr", "get", "movie-history"]);
|
Cli::command().try_get_matches_from(["managarr", "radarr", "get", "movie-history"]);
|
||||||
|
|
||||||
assert!(result.is_err());
|
assert_err!(&result);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
result.unwrap_err().kind(),
|
result.unwrap_err().kind(),
|
||||||
ErrorKind::MissingRequiredArgument
|
ErrorKind::MissingRequiredArgument
|
||||||
@@ -87,7 +87,7 @@ mod tests {
|
|||||||
"1",
|
"1",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -95,7 +95,7 @@ mod tests {
|
|||||||
let result =
|
let result =
|
||||||
Cli::command().try_get_matches_from(["managarr", "radarr", "get", "security-config"]);
|
Cli::command().try_get_matches_from(["managarr", "radarr", "get", "security-config"]);
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -103,7 +103,7 @@ mod tests {
|
|||||||
let result =
|
let result =
|
||||||
Cli::command().try_get_matches_from(["managarr", "radarr", "get", "system-status"]);
|
Cli::command().try_get_matches_from(["managarr", "radarr", "get", "system-status"]);
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -117,11 +117,11 @@ mod tests {
|
|||||||
use crate::{
|
use crate::{
|
||||||
app::App,
|
app::App,
|
||||||
cli::{
|
cli::{
|
||||||
radarr::get_command_handler::{RadarrGetCommand, RadarrGetCommandHandler},
|
|
||||||
CliCommandHandler,
|
CliCommandHandler,
|
||||||
|
radarr::get_command_handler::{RadarrGetCommand, RadarrGetCommandHandler},
|
||||||
},
|
},
|
||||||
models::{radarr_models::RadarrSerdeable, Serdeable},
|
models::{Serdeable, radarr_models::RadarrSerdeable},
|
||||||
network::{radarr_network::RadarrEvent, MockNetworkTrait, NetworkEvent},
|
network::{MockNetworkTrait, NetworkEvent, radarr_network::RadarrEvent},
|
||||||
};
|
};
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
@@ -149,7 +149,7 @@ mod tests {
|
|||||||
.handle()
|
.handle()
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
@@ -172,7 +172,7 @@ mod tests {
|
|||||||
.handle()
|
.handle()
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
@@ -198,7 +198,7 @@ mod tests {
|
|||||||
.handle()
|
.handle()
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
@@ -224,7 +224,7 @@ mod tests {
|
|||||||
.handle()
|
.handle()
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
@@ -247,7 +247,7 @@ mod tests {
|
|||||||
.handle()
|
.handle()
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
@@ -270,7 +270,7 @@ mod tests {
|
|||||||
.handle()
|
.handle()
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use clap::{command, Subcommand};
|
use clap::{Subcommand, command};
|
||||||
use tokio::sync::Mutex;
|
use tokio::sync::Mutex;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
app::App,
|
app::App,
|
||||||
cli::{CliCommandHandler, Command},
|
cli::{CliCommandHandler, Command},
|
||||||
network::{radarr_network::RadarrEvent, NetworkTrait},
|
network::{NetworkTrait, radarr_network::RadarrEvent},
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::RadarrCommand;
|
use super::RadarrCommand;
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use clap::error::ErrorKind;
|
|
||||||
use clap::CommandFactory;
|
use clap::CommandFactory;
|
||||||
|
use clap::error::ErrorKind;
|
||||||
|
|
||||||
use crate::cli::radarr::list_command_handler::RadarrListCommand;
|
|
||||||
use crate::cli::radarr::RadarrCommand;
|
|
||||||
use crate::cli::Command;
|
|
||||||
use crate::Cli;
|
use crate::Cli;
|
||||||
|
use crate::cli::Command;
|
||||||
|
use crate::cli::radarr::RadarrCommand;
|
||||||
|
use crate::cli::radarr::list_command_handler::RadarrListCommand;
|
||||||
use pretty_assertions::assert_eq;
|
use pretty_assertions::assert_eq;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -43,7 +43,7 @@ mod tests {
|
|||||||
) {
|
) {
|
||||||
let result = Cli::command().try_get_matches_from(["managarr", "radarr", "list", subcommand]);
|
let result = Cli::command().try_get_matches_from(["managarr", "radarr", "list", subcommand]);
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -51,7 +51,7 @@ mod tests {
|
|||||||
let result =
|
let result =
|
||||||
Cli::command().try_get_matches_from(["managarr", "radarr", "list", "movie-credits"]);
|
Cli::command().try_get_matches_from(["managarr", "radarr", "list", "movie-credits"]);
|
||||||
|
|
||||||
assert!(result.is_err());
|
assert_err!(&result);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
result.unwrap_err().kind(),
|
result.unwrap_err().kind(),
|
||||||
ErrorKind::MissingRequiredArgument
|
ErrorKind::MissingRequiredArgument
|
||||||
@@ -63,7 +63,7 @@ mod tests {
|
|||||||
let result =
|
let result =
|
||||||
Cli::command().try_get_matches_from(["managarr", "radarr", "list", "downloads", "--count"]);
|
Cli::command().try_get_matches_from(["managarr", "radarr", "list", "downloads", "--count"]);
|
||||||
|
|
||||||
assert!(result.is_err());
|
assert_err!(&result);
|
||||||
assert_eq!(result.unwrap_err().kind(), ErrorKind::InvalidValue);
|
assert_eq!(result.unwrap_err().kind(), ErrorKind::InvalidValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -72,7 +72,7 @@ mod tests {
|
|||||||
let result =
|
let result =
|
||||||
Cli::command().try_get_matches_from(["managarr", "radarr", "list", "logs", "--events"]);
|
Cli::command().try_get_matches_from(["managarr", "radarr", "list", "logs", "--events"]);
|
||||||
|
|
||||||
assert!(result.is_err());
|
assert_err!(&result);
|
||||||
assert_eq!(result.unwrap_err().kind(), ErrorKind::InvalidValue);
|
assert_eq!(result.unwrap_err().kind(), ErrorKind::InvalidValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -88,11 +88,13 @@ mod tests {
|
|||||||
"1",
|
"1",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
|
|
||||||
if let Some(Command::Radarr(RadarrCommand::List(credits_command))) = result.unwrap().command {
|
let Some(Command::Radarr(RadarrCommand::List(credits_command))) = result.unwrap().command
|
||||||
assert_eq!(credits_command, expected_args);
|
else {
|
||||||
}
|
panic!("Unexpected command type");
|
||||||
|
};
|
||||||
|
assert_eq!(credits_command, expected_args);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -100,11 +102,13 @@ mod tests {
|
|||||||
let expected_args = RadarrListCommand::Downloads { count: 500 };
|
let expected_args = RadarrListCommand::Downloads { count: 500 };
|
||||||
let result = Cli::try_parse_from(["managarr", "radarr", "list", "downloads"]);
|
let result = Cli::try_parse_from(["managarr", "radarr", "list", "downloads"]);
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
|
|
||||||
if let Some(Command::Radarr(RadarrCommand::List(refresh_command))) = result.unwrap().command {
|
let Some(Command::Radarr(RadarrCommand::List(refresh_command))) = result.unwrap().command
|
||||||
assert_eq!(refresh_command, expected_args);
|
else {
|
||||||
}
|
panic!("Unexpected command type");
|
||||||
|
};
|
||||||
|
assert_eq!(refresh_command, expected_args);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -115,11 +119,13 @@ mod tests {
|
|||||||
};
|
};
|
||||||
let result = Cli::try_parse_from(["managarr", "radarr", "list", "logs"]);
|
let result = Cli::try_parse_from(["managarr", "radarr", "list", "logs"]);
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
|
|
||||||
if let Some(Command::Radarr(RadarrCommand::List(refresh_command))) = result.unwrap().command {
|
let Some(Command::Radarr(RadarrCommand::List(refresh_command))) = result.unwrap().command
|
||||||
assert_eq!(refresh_command, expected_args);
|
else {
|
||||||
}
|
panic!("Unexpected command type");
|
||||||
|
};
|
||||||
|
assert_eq!(refresh_command, expected_args);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -135,8 +141,8 @@ mod tests {
|
|||||||
use crate::{
|
use crate::{
|
||||||
app::App,
|
app::App,
|
||||||
cli::radarr::list_command_handler::{RadarrListCommand, RadarrListCommandHandler},
|
cli::radarr::list_command_handler::{RadarrListCommand, RadarrListCommandHandler},
|
||||||
models::{radarr_models::RadarrSerdeable, Serdeable},
|
models::{Serdeable, radarr_models::RadarrSerdeable},
|
||||||
network::{radarr_network::RadarrEvent, MockNetworkTrait, NetworkEvent},
|
network::{MockNetworkTrait, NetworkEvent, radarr_network::RadarrEvent},
|
||||||
};
|
};
|
||||||
|
|
||||||
#[rstest]
|
#[rstest]
|
||||||
@@ -172,7 +178,7 @@ mod tests {
|
|||||||
.handle()
|
.handle()
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
@@ -198,7 +204,7 @@ mod tests {
|
|||||||
.handle()
|
.handle()
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
@@ -224,7 +230,7 @@ mod tests {
|
|||||||
.handle()
|
.handle()
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
@@ -252,7 +258,7 @@ mod tests {
|
|||||||
.handle()
|
.handle()
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,8 +13,8 @@ use crate::app::App;
|
|||||||
|
|
||||||
use crate::cli::CliCommandHandler;
|
use crate::cli::CliCommandHandler;
|
||||||
use crate::models::radarr_models::{RadarrReleaseDownloadBody, RadarrTaskName};
|
use crate::models::radarr_models::{RadarrReleaseDownloadBody, RadarrTaskName};
|
||||||
use crate::network::radarr_network::RadarrEvent;
|
|
||||||
use crate::network::NetworkTrait;
|
use crate::network::NetworkTrait;
|
||||||
|
use crate::network::radarr_network::RadarrEvent;
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
|
|
||||||
use super::Command;
|
use super::Command;
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use clap::error::ErrorKind;
|
|
||||||
use clap::CommandFactory;
|
use clap::CommandFactory;
|
||||||
|
use clap::error::ErrorKind;
|
||||||
|
|
||||||
use crate::cli::radarr::RadarrCommand;
|
|
||||||
use crate::cli::Command;
|
|
||||||
use crate::Cli;
|
use crate::Cli;
|
||||||
|
use crate::cli::Command;
|
||||||
|
use crate::cli::radarr::RadarrCommand;
|
||||||
use pretty_assertions::assert_eq;
|
use pretty_assertions::assert_eq;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -28,7 +28,7 @@ mod tests {
|
|||||||
) {
|
) {
|
||||||
let result = Cli::command().try_get_matches_from(["managarr", "radarr", subcommand]);
|
let result = Cli::command().try_get_matches_from(["managarr", "radarr", subcommand]);
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -43,7 +43,7 @@ mod tests {
|
|||||||
"1",
|
"1",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_err());
|
assert_err!(&result);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
result.unwrap_err().kind(),
|
result.unwrap_err().kind(),
|
||||||
ErrorKind::MissingRequiredArgument
|
ErrorKind::MissingRequiredArgument
|
||||||
@@ -62,7 +62,7 @@ mod tests {
|
|||||||
"1",
|
"1",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_err());
|
assert_err!(&result);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
result.unwrap_err().kind(),
|
result.unwrap_err().kind(),
|
||||||
ErrorKind::MissingRequiredArgument
|
ErrorKind::MissingRequiredArgument
|
||||||
@@ -81,7 +81,7 @@ mod tests {
|
|||||||
"1",
|
"1",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_err());
|
assert_err!(&result);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
result.unwrap_err().kind(),
|
result.unwrap_err().kind(),
|
||||||
ErrorKind::MissingRequiredArgument
|
ErrorKind::MissingRequiredArgument
|
||||||
@@ -102,14 +102,14 @@ mod tests {
|
|||||||
"1",
|
"1",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_manual_search_requires_movie_id() {
|
fn test_manual_search_requires_movie_id() {
|
||||||
let result = Cli::command().try_get_matches_from(["managarr", "radarr", "manual-search"]);
|
let result = Cli::command().try_get_matches_from(["managarr", "radarr", "manual-search"]);
|
||||||
|
|
||||||
assert!(result.is_err());
|
assert_err!(&result);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
result.unwrap_err().kind(),
|
result.unwrap_err().kind(),
|
||||||
ErrorKind::MissingRequiredArgument
|
ErrorKind::MissingRequiredArgument
|
||||||
@@ -126,14 +126,14 @@ mod tests {
|
|||||||
"1",
|
"1",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_search_new_movie_requires_query() {
|
fn test_search_new_movie_requires_query() {
|
||||||
let result = Cli::command().try_get_matches_from(["managarr", "radarr", "search-new-movie"]);
|
let result = Cli::command().try_get_matches_from(["managarr", "radarr", "search-new-movie"]);
|
||||||
|
|
||||||
assert!(result.is_err());
|
assert_err!(&result);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
result.unwrap_err().kind(),
|
result.unwrap_err().kind(),
|
||||||
ErrorKind::MissingRequiredArgument
|
ErrorKind::MissingRequiredArgument
|
||||||
@@ -150,14 +150,14 @@ mod tests {
|
|||||||
"halo",
|
"halo",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_start_task_requires_task_name() {
|
fn test_start_task_requires_task_name() {
|
||||||
let result = Cli::command().try_get_matches_from(["managarr", "radarr", "start-task"]);
|
let result = Cli::command().try_get_matches_from(["managarr", "radarr", "start-task"]);
|
||||||
|
|
||||||
assert!(result.is_err());
|
assert_err!(&result);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
result.unwrap_err().kind(),
|
result.unwrap_err().kind(),
|
||||||
ErrorKind::MissingRequiredArgument
|
ErrorKind::MissingRequiredArgument
|
||||||
@@ -174,7 +174,7 @@ mod tests {
|
|||||||
"test",
|
"test",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_err());
|
assert_err!(&result);
|
||||||
assert_eq!(result.unwrap_err().kind(), ErrorKind::InvalidValue);
|
assert_eq!(result.unwrap_err().kind(), ErrorKind::InvalidValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -188,14 +188,14 @@ mod tests {
|
|||||||
"application-check-update",
|
"application-check-update",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_test_indexer_requires_indexer_id() {
|
fn test_test_indexer_requires_indexer_id() {
|
||||||
let result = Cli::command().try_get_matches_from(["managarr", "radarr", "test-indexer"]);
|
let result = Cli::command().try_get_matches_from(["managarr", "radarr", "test-indexer"]);
|
||||||
|
|
||||||
assert!(result.is_err());
|
assert_err!(&result);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
result.unwrap_err().kind(),
|
result.unwrap_err().kind(),
|
||||||
ErrorKind::MissingRequiredArgument
|
ErrorKind::MissingRequiredArgument
|
||||||
@@ -212,7 +212,7 @@ mod tests {
|
|||||||
"1",
|
"1",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -220,7 +220,7 @@ mod tests {
|
|||||||
let result =
|
let result =
|
||||||
Cli::command().try_get_matches_from(["managarr", "radarr", "toggle-movie-monitoring"]);
|
Cli::command().try_get_matches_from(["managarr", "radarr", "toggle-movie-monitoring"]);
|
||||||
|
|
||||||
assert!(result.is_err());
|
assert_err!(&result);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
result.unwrap_err().kind(),
|
result.unwrap_err().kind(),
|
||||||
ErrorKind::MissingRequiredArgument
|
ErrorKind::MissingRequiredArgument
|
||||||
@@ -237,7 +237,7 @@ mod tests {
|
|||||||
"1",
|
"1",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -245,7 +245,7 @@ mod tests {
|
|||||||
let result =
|
let result =
|
||||||
Cli::command().try_get_matches_from(["managarr", "radarr", "trigger-automatic-search"]);
|
Cli::command().try_get_matches_from(["managarr", "radarr", "trigger-automatic-search"]);
|
||||||
|
|
||||||
assert!(result.is_err());
|
assert_err!(&result);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
result.unwrap_err().kind(),
|
result.unwrap_err().kind(),
|
||||||
ErrorKind::MissingRequiredArgument
|
ErrorKind::MissingRequiredArgument
|
||||||
@@ -262,7 +262,7 @@ mod tests {
|
|||||||
"1",
|
"1",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -276,22 +276,22 @@ mod tests {
|
|||||||
use crate::{
|
use crate::{
|
||||||
app::App,
|
app::App,
|
||||||
cli::{
|
cli::{
|
||||||
radarr::{
|
|
||||||
add_command_handler::RadarrAddCommand, delete_command_handler::RadarrDeleteCommand,
|
|
||||||
edit_command_handler::RadarrEditCommand, get_command_handler::RadarrGetCommand,
|
|
||||||
list_command_handler::RadarrListCommand, refresh_command_handler::RadarrRefreshCommand,
|
|
||||||
RadarrCliHandler, RadarrCommand,
|
|
||||||
},
|
|
||||||
CliCommandHandler,
|
CliCommandHandler,
|
||||||
|
radarr::{
|
||||||
|
RadarrCliHandler, RadarrCommand, add_command_handler::RadarrAddCommand,
|
||||||
|
delete_command_handler::RadarrDeleteCommand, edit_command_handler::RadarrEditCommand,
|
||||||
|
get_command_handler::RadarrGetCommand, list_command_handler::RadarrListCommand,
|
||||||
|
refresh_command_handler::RadarrRefreshCommand,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
models::{
|
models::{
|
||||||
|
Serdeable,
|
||||||
radarr_models::{
|
radarr_models::{
|
||||||
BlocklistItem, BlocklistResponse, IndexerSettings, RadarrReleaseDownloadBody,
|
BlocklistItem, BlocklistResponse, IndexerSettings, RadarrReleaseDownloadBody,
|
||||||
RadarrSerdeable, RadarrTaskName,
|
RadarrSerdeable, RadarrTaskName,
|
||||||
},
|
},
|
||||||
Serdeable,
|
|
||||||
},
|
},
|
||||||
network::{radarr_network::RadarrEvent, MockNetworkTrait, NetworkEvent},
|
network::{MockNetworkTrait, NetworkEvent, radarr_network::RadarrEvent},
|
||||||
};
|
};
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
@@ -324,7 +324,7 @@ mod tests {
|
|||||||
.handle()
|
.handle()
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
@@ -357,7 +357,7 @@ mod tests {
|
|||||||
.handle()
|
.handle()
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
@@ -382,7 +382,7 @@ mod tests {
|
|||||||
.handle()
|
.handle()
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
@@ -409,7 +409,7 @@ mod tests {
|
|||||||
.handle()
|
.handle()
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
@@ -436,7 +436,7 @@ mod tests {
|
|||||||
.handle()
|
.handle()
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
@@ -461,7 +461,7 @@ mod tests {
|
|||||||
.handle()
|
.handle()
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
@@ -483,7 +483,7 @@ mod tests {
|
|||||||
.handle()
|
.handle()
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
@@ -509,7 +509,7 @@ mod tests {
|
|||||||
.handle()
|
.handle()
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
@@ -538,7 +538,7 @@ mod tests {
|
|||||||
.handle()
|
.handle()
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
@@ -565,7 +565,7 @@ mod tests {
|
|||||||
.handle()
|
.handle()
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
@@ -594,7 +594,7 @@ mod tests {
|
|||||||
.handle()
|
.handle()
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
@@ -666,7 +666,7 @@ mod tests {
|
|||||||
.handle()
|
.handle()
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
@@ -695,7 +695,7 @@ mod tests {
|
|||||||
.handle()
|
.handle()
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
@@ -721,7 +721,7 @@ mod tests {
|
|||||||
.handle()
|
.handle()
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
@@ -747,7 +747,7 @@ mod tests {
|
|||||||
.handle()
|
.handle()
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ use tokio::sync::Mutex;
|
|||||||
use crate::{
|
use crate::{
|
||||||
app::App,
|
app::App,
|
||||||
cli::{CliCommandHandler, Command},
|
cli::{CliCommandHandler, Command},
|
||||||
network::{radarr_network::RadarrEvent, NetworkTrait},
|
network::{NetworkTrait, radarr_network::RadarrEvent},
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::RadarrCommand;
|
use super::RadarrCommand;
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use clap::error::ErrorKind;
|
|
||||||
use clap::CommandFactory;
|
use clap::CommandFactory;
|
||||||
|
use clap::error::ErrorKind;
|
||||||
|
|
||||||
use crate::cli::radarr::refresh_command_handler::RadarrRefreshCommand;
|
|
||||||
use crate::cli::radarr::RadarrCommand;
|
|
||||||
use crate::cli::Command;
|
|
||||||
use crate::Cli;
|
use crate::Cli;
|
||||||
|
use crate::cli::Command;
|
||||||
|
use crate::cli::radarr::RadarrCommand;
|
||||||
|
use crate::cli::radarr::refresh_command_handler::RadarrRefreshCommand;
|
||||||
use pretty_assertions::assert_eq;
|
use pretty_assertions::assert_eq;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -31,14 +31,14 @@ mod tests {
|
|||||||
let result =
|
let result =
|
||||||
Cli::command().try_get_matches_from(["managarr", "radarr", "refresh", subcommand]);
|
Cli::command().try_get_matches_from(["managarr", "radarr", "refresh", subcommand]);
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_refresh_movie_requires_movie_id() {
|
fn test_refresh_movie_requires_movie_id() {
|
||||||
let result = Cli::command().try_get_matches_from(["managarr", "radarr", "refresh", "movie"]);
|
let result = Cli::command().try_get_matches_from(["managarr", "radarr", "refresh", "movie"]);
|
||||||
|
|
||||||
assert!(result.is_err());
|
assert_err!(&result);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
result.unwrap_err().kind(),
|
result.unwrap_err().kind(),
|
||||||
ErrorKind::MissingRequiredArgument
|
ErrorKind::MissingRequiredArgument
|
||||||
@@ -51,13 +51,13 @@ mod tests {
|
|||||||
let result =
|
let result =
|
||||||
Cli::try_parse_from(["managarr", "radarr", "refresh", "movie", "--movie-id", "1"]);
|
Cli::try_parse_from(["managarr", "radarr", "refresh", "movie", "--movie-id", "1"]);
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
|
|
||||||
if let Some(Command::Radarr(RadarrCommand::Refresh(refresh_command))) =
|
let Some(Command::Radarr(RadarrCommand::Refresh(refresh_command))) = result.unwrap().command
|
||||||
result.unwrap().command
|
else {
|
||||||
{
|
panic!("Unexpected command type");
|
||||||
assert_eq!(refresh_command, expected_args);
|
};
|
||||||
}
|
assert_eq!(refresh_command, expected_args);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -73,8 +73,8 @@ mod tests {
|
|||||||
use crate::{
|
use crate::{
|
||||||
app::App,
|
app::App,
|
||||||
cli::radarr::refresh_command_handler::{RadarrRefreshCommand, RadarrRefreshCommandHandler},
|
cli::radarr::refresh_command_handler::{RadarrRefreshCommand, RadarrRefreshCommandHandler},
|
||||||
models::{radarr_models::RadarrSerdeable, Serdeable},
|
models::{Serdeable, radarr_models::RadarrSerdeable},
|
||||||
network::{radarr_network::RadarrEvent, MockNetworkTrait, NetworkEvent},
|
network::{MockNetworkTrait, NetworkEvent, radarr_network::RadarrEvent},
|
||||||
};
|
};
|
||||||
|
|
||||||
#[rstest]
|
#[rstest]
|
||||||
@@ -102,7 +102,7 @@ mod tests {
|
|||||||
.handle()
|
.handle()
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
@@ -128,7 +128,7 @@ mod tests {
|
|||||||
.handle()
|
.handle()
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ use crate::{
|
|||||||
app::App,
|
app::App,
|
||||||
cli::{CliCommandHandler, Command},
|
cli::{CliCommandHandler, Command},
|
||||||
models::sonarr_models::{AddSeriesBody, AddSeriesOptions, SeriesMonitor, SeriesType},
|
models::sonarr_models::{AddSeriesBody, AddSeriesOptions, SeriesMonitor, SeriesType},
|
||||||
network::{sonarr_network::SonarrEvent, NetworkTrait},
|
network::{NetworkTrait, sonarr_network::SonarrEvent},
|
||||||
};
|
};
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use clap::{error::ErrorKind, CommandFactory, Parser};
|
use clap::{CommandFactory, Parser, error::ErrorKind};
|
||||||
use pretty_assertions::assert_eq;
|
use pretty_assertions::assert_eq;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
cli::{
|
|
||||||
sonarr::{add_command_handler::SonarrAddCommand, SonarrCommand},
|
|
||||||
Command,
|
|
||||||
},
|
|
||||||
Cli,
|
Cli,
|
||||||
|
cli::{
|
||||||
|
Command,
|
||||||
|
sonarr::{SonarrCommand, add_command_handler::SonarrAddCommand},
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -34,7 +34,7 @@ mod tests {
|
|||||||
let result =
|
let result =
|
||||||
Cli::command().try_get_matches_from(["managarr", "sonarr", "add", "root-folder"]);
|
Cli::command().try_get_matches_from(["managarr", "sonarr", "add", "root-folder"]);
|
||||||
|
|
||||||
assert!(result.is_err());
|
assert_err!(&result);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
result.unwrap_err().kind(),
|
result.unwrap_err().kind(),
|
||||||
ErrorKind::MissingRequiredArgument
|
ErrorKind::MissingRequiredArgument
|
||||||
@@ -56,18 +56,19 @@ mod tests {
|
|||||||
"/nfs/test",
|
"/nfs/test",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
|
|
||||||
if let Some(Command::Sonarr(SonarrCommand::Add(add_command))) = result.unwrap().command {
|
let Some(Command::Sonarr(SonarrCommand::Add(add_command))) = result.unwrap().command else {
|
||||||
assert_eq!(add_command, expected_args);
|
panic!("Unexpected command type");
|
||||||
}
|
};
|
||||||
|
assert_eq!(add_command, expected_args);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_add_series_requires_arguments() {
|
fn test_add_series_requires_arguments() {
|
||||||
let result = Cli::command().try_get_matches_from(["managarr", "sonarr", "add", "series"]);
|
let result = Cli::command().try_get_matches_from(["managarr", "sonarr", "add", "series"]);
|
||||||
|
|
||||||
assert!(result.is_err());
|
assert_err!(&result);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
result.unwrap_err().kind(),
|
result.unwrap_err().kind(),
|
||||||
ErrorKind::MissingRequiredArgument
|
ErrorKind::MissingRequiredArgument
|
||||||
@@ -91,7 +92,7 @@ mod tests {
|
|||||||
"test",
|
"test",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_err());
|
assert_err!(&result);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
result.unwrap_err().kind(),
|
result.unwrap_err().kind(),
|
||||||
ErrorKind::MissingRequiredArgument
|
ErrorKind::MissingRequiredArgument
|
||||||
@@ -115,7 +116,7 @@ mod tests {
|
|||||||
"1",
|
"1",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_err());
|
assert_err!(&result);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
result.unwrap_err().kind(),
|
result.unwrap_err().kind(),
|
||||||
ErrorKind::MissingRequiredArgument
|
ErrorKind::MissingRequiredArgument
|
||||||
@@ -139,7 +140,7 @@ mod tests {
|
|||||||
"test",
|
"test",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_err());
|
assert_err!(&result);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
result.unwrap_err().kind(),
|
result.unwrap_err().kind(),
|
||||||
ErrorKind::MissingRequiredArgument
|
ErrorKind::MissingRequiredArgument
|
||||||
@@ -163,7 +164,7 @@ mod tests {
|
|||||||
"test",
|
"test",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_err());
|
assert_err!(&result);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
result.unwrap_err().kind(),
|
result.unwrap_err().kind(),
|
||||||
ErrorKind::MissingRequiredArgument
|
ErrorKind::MissingRequiredArgument
|
||||||
@@ -187,7 +188,7 @@ mod tests {
|
|||||||
"test",
|
"test",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_err());
|
assert_err!(&result);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
result.unwrap_err().kind(),
|
result.unwrap_err().kind(),
|
||||||
ErrorKind::MissingRequiredArgument
|
ErrorKind::MissingRequiredArgument
|
||||||
@@ -216,7 +217,7 @@ mod tests {
|
|||||||
flag,
|
flag,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_err());
|
assert_err!(&result);
|
||||||
assert_eq!(result.unwrap_err().kind(), ErrorKind::InvalidValue);
|
assert_eq!(result.unwrap_err().kind(), ErrorKind::InvalidValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -239,7 +240,7 @@ mod tests {
|
|||||||
"1",
|
"1",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -263,7 +264,7 @@ mod tests {
|
|||||||
"test",
|
"test",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_err());
|
assert_err!(&result);
|
||||||
assert_eq!(result.unwrap_err().kind(), ErrorKind::InvalidValue);
|
assert_eq!(result.unwrap_err().kind(), ErrorKind::InvalidValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -288,7 +289,7 @@ mod tests {
|
|||||||
"test",
|
"test",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_err());
|
assert_err!(&result);
|
||||||
assert_eq!(result.unwrap_err().kind(), ErrorKind::InvalidValue);
|
assert_eq!(result.unwrap_err().kind(), ErrorKind::InvalidValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -325,10 +326,11 @@ mod tests {
|
|||||||
"1",
|
"1",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
if let Some(Command::Sonarr(SonarrCommand::Add(add_command))) = result.unwrap().command {
|
let Some(Command::Sonarr(SonarrCommand::Add(add_command))) = result.unwrap().command else {
|
||||||
assert_eq!(add_command, expected_args);
|
panic!("Unexpected command type");
|
||||||
}
|
};
|
||||||
|
assert_eq!(add_command, expected_args);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -368,10 +370,11 @@ mod tests {
|
|||||||
"2",
|
"2",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
if let Some(Command::Sonarr(SonarrCommand::Add(add_command))) = result.unwrap().command {
|
let Some(Command::Sonarr(SonarrCommand::Add(add_command))) = result.unwrap().command else {
|
||||||
assert_eq!(add_command, expected_args);
|
panic!("Unexpected command type");
|
||||||
}
|
};
|
||||||
|
assert_eq!(add_command, expected_args);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -418,17 +421,18 @@ mod tests {
|
|||||||
"--no-search-for-series",
|
"--no-search-for-series",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
if let Some(Command::Sonarr(SonarrCommand::Add(add_command))) = result.unwrap().command {
|
let Some(Command::Sonarr(SonarrCommand::Add(add_command))) = result.unwrap().command else {
|
||||||
assert_eq!(add_command, expected_args);
|
panic!("Unexpected command type");
|
||||||
}
|
};
|
||||||
|
assert_eq!(add_command, expected_args);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_add_tag_requires_arguments() {
|
fn test_add_tag_requires_arguments() {
|
||||||
let result = Cli::command().try_get_matches_from(["managarr", "sonarr", "add", "tag"]);
|
let result = Cli::command().try_get_matches_from(["managarr", "sonarr", "add", "tag"]);
|
||||||
|
|
||||||
assert!(result.is_err());
|
assert_err!(&result);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
result.unwrap_err().kind(),
|
result.unwrap_err().kind(),
|
||||||
ErrorKind::MissingRequiredArgument
|
ErrorKind::MissingRequiredArgument
|
||||||
@@ -443,11 +447,12 @@ mod tests {
|
|||||||
|
|
||||||
let result = Cli::try_parse_from(["managarr", "sonarr", "add", "tag", "--name", "test"]);
|
let result = Cli::try_parse_from(["managarr", "sonarr", "add", "tag", "--name", "test"]);
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
|
|
||||||
if let Some(Command::Sonarr(SonarrCommand::Add(add_command))) = result.unwrap().command {
|
let Some(Command::Sonarr(SonarrCommand::Add(add_command))) = result.unwrap().command else {
|
||||||
assert_eq!(add_command, expected_args);
|
panic!("Unexpected command type");
|
||||||
}
|
};
|
||||||
|
assert_eq!(add_command, expected_args);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -456,14 +461,14 @@ mod tests {
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
app::App,
|
app::App,
|
||||||
cli::{sonarr::add_command_handler::SonarrAddCommandHandler, CliCommandHandler},
|
cli::{CliCommandHandler, sonarr::add_command_handler::SonarrAddCommandHandler},
|
||||||
models::{
|
models::{
|
||||||
|
Serdeable,
|
||||||
sonarr_models::{
|
sonarr_models::{
|
||||||
AddSeriesBody, AddSeriesOptions, SeriesMonitor, SeriesType, SonarrSerdeable,
|
AddSeriesBody, AddSeriesOptions, SeriesMonitor, SeriesType, SonarrSerdeable,
|
||||||
},
|
},
|
||||||
Serdeable,
|
|
||||||
},
|
},
|
||||||
network::{sonarr_network::SonarrEvent, MockNetworkTrait, NetworkEvent},
|
network::{MockNetworkTrait, NetworkEvent, sonarr_network::SonarrEvent},
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
@@ -501,7 +506,7 @@ mod tests {
|
|||||||
.handle()
|
.handle()
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
@@ -554,7 +559,7 @@ mod tests {
|
|||||||
.handle()
|
.handle()
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
@@ -581,7 +586,7 @@ mod tests {
|
|||||||
.handle()
|
.handle()
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ use crate::{
|
|||||||
app::App,
|
app::App,
|
||||||
cli::{CliCommandHandler, Command},
|
cli::{CliCommandHandler, Command},
|
||||||
models::sonarr_models::DeleteSeriesParams,
|
models::sonarr_models::DeleteSeriesParams,
|
||||||
network::{sonarr_network::SonarrEvent, NetworkTrait},
|
network::{NetworkTrait, sonarr_network::SonarrEvent},
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::SonarrCommand;
|
use super::SonarrCommand;
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use crate::{
|
use crate::{
|
||||||
cli::{
|
|
||||||
sonarr::{delete_command_handler::SonarrDeleteCommand, SonarrCommand},
|
|
||||||
Command,
|
|
||||||
},
|
|
||||||
Cli,
|
Cli,
|
||||||
|
cli::{
|
||||||
|
Command,
|
||||||
|
sonarr::{SonarrCommand, delete_command_handler::SonarrDeleteCommand},
|
||||||
|
},
|
||||||
};
|
};
|
||||||
use clap::{error::ErrorKind, CommandFactory, Parser};
|
use clap::{CommandFactory, Parser, error::ErrorKind};
|
||||||
use pretty_assertions::assert_eq;
|
use pretty_assertions::assert_eq;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -30,7 +30,7 @@ mod tests {
|
|||||||
let result =
|
let result =
|
||||||
Cli::command().try_get_matches_from(["managarr", "sonarr", "delete", "blocklist-item"]);
|
Cli::command().try_get_matches_from(["managarr", "sonarr", "delete", "blocklist-item"]);
|
||||||
|
|
||||||
assert!(result.is_err());
|
assert_err!(&result);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
result.unwrap_err().kind(),
|
result.unwrap_err().kind(),
|
||||||
ErrorKind::MissingRequiredArgument
|
ErrorKind::MissingRequiredArgument
|
||||||
@@ -52,12 +52,13 @@ mod tests {
|
|||||||
"1",
|
"1",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
|
|
||||||
if let Some(Command::Sonarr(SonarrCommand::Delete(delete_command))) = result.unwrap().command
|
let Some(Command::Sonarr(SonarrCommand::Delete(delete_command))) = result.unwrap().command
|
||||||
{
|
else {
|
||||||
assert_eq!(delete_command, expected_args);
|
panic!("Unexpected command type");
|
||||||
}
|
};
|
||||||
|
assert_eq!(delete_command, expected_args);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -65,7 +66,7 @@ mod tests {
|
|||||||
let result =
|
let result =
|
||||||
Cli::command().try_get_matches_from(["managarr", "sonarr", "delete", "download"]);
|
Cli::command().try_get_matches_from(["managarr", "sonarr", "delete", "download"]);
|
||||||
|
|
||||||
assert!(result.is_err());
|
assert_err!(&result);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
result.unwrap_err().kind(),
|
result.unwrap_err().kind(),
|
||||||
ErrorKind::MissingRequiredArgument
|
ErrorKind::MissingRequiredArgument
|
||||||
@@ -85,12 +86,13 @@ mod tests {
|
|||||||
"1",
|
"1",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
|
|
||||||
if let Some(Command::Sonarr(SonarrCommand::Delete(delete_command))) = result.unwrap().command
|
let Some(Command::Sonarr(SonarrCommand::Delete(delete_command))) = result.unwrap().command
|
||||||
{
|
else {
|
||||||
assert_eq!(delete_command, expected_args);
|
panic!("Unexpected command type");
|
||||||
}
|
};
|
||||||
|
assert_eq!(delete_command, expected_args);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -98,7 +100,7 @@ mod tests {
|
|||||||
let result =
|
let result =
|
||||||
Cli::command().try_get_matches_from(["managarr", "sonarr", "delete", "episode-file"]);
|
Cli::command().try_get_matches_from(["managarr", "sonarr", "delete", "episode-file"]);
|
||||||
|
|
||||||
assert!(result.is_err());
|
assert_err!(&result);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
result.unwrap_err().kind(),
|
result.unwrap_err().kind(),
|
||||||
ErrorKind::MissingRequiredArgument
|
ErrorKind::MissingRequiredArgument
|
||||||
@@ -118,19 +120,20 @@ mod tests {
|
|||||||
"1",
|
"1",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
|
|
||||||
if let Some(Command::Sonarr(SonarrCommand::Delete(delete_command))) = result.unwrap().command
|
let Some(Command::Sonarr(SonarrCommand::Delete(delete_command))) = result.unwrap().command
|
||||||
{
|
else {
|
||||||
assert_eq!(delete_command, expected_args);
|
panic!("Unexpected command type");
|
||||||
}
|
};
|
||||||
|
assert_eq!(delete_command, expected_args);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_delete_indexer_requires_arguments() {
|
fn test_delete_indexer_requires_arguments() {
|
||||||
let result = Cli::command().try_get_matches_from(["managarr", "sonarr", "delete", "indexer"]);
|
let result = Cli::command().try_get_matches_from(["managarr", "sonarr", "delete", "indexer"]);
|
||||||
|
|
||||||
assert!(result.is_err());
|
assert_err!(&result);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
result.unwrap_err().kind(),
|
result.unwrap_err().kind(),
|
||||||
ErrorKind::MissingRequiredArgument
|
ErrorKind::MissingRequiredArgument
|
||||||
@@ -150,12 +153,13 @@ mod tests {
|
|||||||
"1",
|
"1",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
|
|
||||||
if let Some(Command::Sonarr(SonarrCommand::Delete(delete_command))) = result.unwrap().command
|
let Some(Command::Sonarr(SonarrCommand::Delete(delete_command))) = result.unwrap().command
|
||||||
{
|
else {
|
||||||
assert_eq!(delete_command, expected_args);
|
panic!("Unexpected command type");
|
||||||
}
|
};
|
||||||
|
assert_eq!(delete_command, expected_args);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -163,7 +167,7 @@ mod tests {
|
|||||||
let result =
|
let result =
|
||||||
Cli::command().try_get_matches_from(["managarr", "sonarr", "delete", "root-folder"]);
|
Cli::command().try_get_matches_from(["managarr", "sonarr", "delete", "root-folder"]);
|
||||||
|
|
||||||
assert!(result.is_err());
|
assert_err!(&result);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
result.unwrap_err().kind(),
|
result.unwrap_err().kind(),
|
||||||
ErrorKind::MissingRequiredArgument
|
ErrorKind::MissingRequiredArgument
|
||||||
@@ -183,19 +187,20 @@ mod tests {
|
|||||||
"1",
|
"1",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
|
|
||||||
if let Some(Command::Sonarr(SonarrCommand::Delete(delete_command))) = result.unwrap().command
|
let Some(Command::Sonarr(SonarrCommand::Delete(delete_command))) = result.unwrap().command
|
||||||
{
|
else {
|
||||||
assert_eq!(delete_command, expected_args);
|
panic!("Unexpected command type");
|
||||||
}
|
};
|
||||||
|
assert_eq!(delete_command, expected_args);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_delete_series_requires_arguments() {
|
fn test_delete_series_requires_arguments() {
|
||||||
let result = Cli::command().try_get_matches_from(["managarr", "sonarr", "delete", "series"]);
|
let result = Cli::command().try_get_matches_from(["managarr", "sonarr", "delete", "series"]);
|
||||||
|
|
||||||
assert!(result.is_err());
|
assert_err!(&result);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
result.unwrap_err().kind(),
|
result.unwrap_err().kind(),
|
||||||
ErrorKind::MissingRequiredArgument
|
ErrorKind::MissingRequiredArgument
|
||||||
@@ -213,12 +218,13 @@ mod tests {
|
|||||||
let result =
|
let result =
|
||||||
Cli::try_parse_from(["managarr", "sonarr", "delete", "series", "--series-id", "1"]);
|
Cli::try_parse_from(["managarr", "sonarr", "delete", "series", "--series-id", "1"]);
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
|
|
||||||
if let Some(Command::Sonarr(SonarrCommand::Delete(delete_command))) = result.unwrap().command
|
let Some(Command::Sonarr(SonarrCommand::Delete(delete_command))) = result.unwrap().command
|
||||||
{
|
else {
|
||||||
assert_eq!(delete_command, expected_args);
|
panic!("Unexpected command type");
|
||||||
}
|
};
|
||||||
|
assert_eq!(delete_command, expected_args);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -240,19 +246,20 @@ mod tests {
|
|||||||
"--add-list-exclusion",
|
"--add-list-exclusion",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
|
|
||||||
if let Some(Command::Sonarr(SonarrCommand::Delete(delete_command))) = result.unwrap().command
|
let Some(Command::Sonarr(SonarrCommand::Delete(delete_command))) = result.unwrap().command
|
||||||
{
|
else {
|
||||||
assert_eq!(delete_command, expected_args);
|
panic!("Unexpected command type");
|
||||||
}
|
};
|
||||||
|
assert_eq!(delete_command, expected_args);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_delete_tag_requires_arguments() {
|
fn test_delete_tag_requires_arguments() {
|
||||||
let result = Cli::command().try_get_matches_from(["managarr", "sonarr", "delete", "tag"]);
|
let result = Cli::command().try_get_matches_from(["managarr", "sonarr", "delete", "tag"]);
|
||||||
|
|
||||||
assert!(result.is_err());
|
assert_err!(&result);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
result.unwrap_err().kind(),
|
result.unwrap_err().kind(),
|
||||||
ErrorKind::MissingRequiredArgument
|
ErrorKind::MissingRequiredArgument
|
||||||
@@ -265,12 +272,13 @@ mod tests {
|
|||||||
|
|
||||||
let result = Cli::try_parse_from(["managarr", "sonarr", "delete", "tag", "--tag-id", "1"]);
|
let result = Cli::try_parse_from(["managarr", "sonarr", "delete", "tag", "--tag-id", "1"]);
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
|
|
||||||
if let Some(Command::Sonarr(SonarrCommand::Delete(delete_command))) = result.unwrap().command
|
let Some(Command::Sonarr(SonarrCommand::Delete(delete_command))) = result.unwrap().command
|
||||||
{
|
else {
|
||||||
assert_eq!(delete_command, expected_args);
|
panic!("Unexpected command type");
|
||||||
}
|
};
|
||||||
|
assert_eq!(delete_command, expected_args);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -284,14 +292,14 @@ mod tests {
|
|||||||
use crate::{
|
use crate::{
|
||||||
app::App,
|
app::App,
|
||||||
cli::{
|
cli::{
|
||||||
sonarr::delete_command_handler::{SonarrDeleteCommand, SonarrDeleteCommandHandler},
|
|
||||||
CliCommandHandler,
|
CliCommandHandler,
|
||||||
|
sonarr::delete_command_handler::{SonarrDeleteCommand, SonarrDeleteCommandHandler},
|
||||||
},
|
},
|
||||||
models::{
|
models::{
|
||||||
sonarr_models::{DeleteSeriesParams, SonarrSerdeable},
|
|
||||||
Serdeable,
|
Serdeable,
|
||||||
|
sonarr_models::{DeleteSeriesParams, SonarrSerdeable},
|
||||||
},
|
},
|
||||||
network::{sonarr_network::SonarrEvent, MockNetworkTrait, NetworkEvent},
|
network::{MockNetworkTrait, NetworkEvent, sonarr_network::SonarrEvent},
|
||||||
};
|
};
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
@@ -322,7 +330,7 @@ mod tests {
|
|||||||
.handle()
|
.handle()
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
@@ -348,7 +356,7 @@ mod tests {
|
|||||||
.handle()
|
.handle()
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
@@ -374,7 +382,7 @@ mod tests {
|
|||||||
.handle()
|
.handle()
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
@@ -400,7 +408,7 @@ mod tests {
|
|||||||
.handle()
|
.handle()
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
@@ -426,7 +434,7 @@ mod tests {
|
|||||||
.handle()
|
.handle()
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
@@ -460,7 +468,7 @@ mod tests {
|
|||||||
.handle()
|
.handle()
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
@@ -486,7 +494,7 @@ mod tests {
|
|||||||
.handle()
|
.handle()
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ use crate::{
|
|||||||
app::App,
|
app::App,
|
||||||
cli::{CliCommandHandler, Command},
|
cli::{CliCommandHandler, Command},
|
||||||
models::sonarr_models::SonarrReleaseDownloadBody,
|
models::sonarr_models::SonarrReleaseDownloadBody,
|
||||||
network::{sonarr_network::SonarrEvent, NetworkTrait},
|
network::{NetworkTrait, sonarr_network::SonarrEvent},
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::SonarrCommand;
|
use super::SonarrCommand;
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use crate::{
|
use crate::{
|
||||||
cli::{
|
|
||||||
sonarr::{download_command_handler::SonarrDownloadCommand, SonarrCommand},
|
|
||||||
Command,
|
|
||||||
},
|
|
||||||
Cli,
|
Cli,
|
||||||
|
cli::{
|
||||||
|
Command,
|
||||||
|
sonarr::{SonarrCommand, download_command_handler::SonarrDownloadCommand},
|
||||||
|
},
|
||||||
};
|
};
|
||||||
use clap::CommandFactory;
|
use clap::CommandFactory;
|
||||||
use pretty_assertions::assert_eq;
|
use pretty_assertions::assert_eq;
|
||||||
@@ -41,7 +41,7 @@ mod tests {
|
|||||||
"1",
|
"1",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_err());
|
assert_err!(&result);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
result.unwrap_err().kind(),
|
result.unwrap_err().kind(),
|
||||||
ErrorKind::MissingRequiredArgument
|
ErrorKind::MissingRequiredArgument
|
||||||
@@ -61,7 +61,7 @@ mod tests {
|
|||||||
"1",
|
"1",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_err());
|
assert_err!(&result);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
result.unwrap_err().kind(),
|
result.unwrap_err().kind(),
|
||||||
ErrorKind::MissingRequiredArgument
|
ErrorKind::MissingRequiredArgument
|
||||||
@@ -81,7 +81,7 @@ mod tests {
|
|||||||
"1",
|
"1",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_err());
|
assert_err!(&result);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
result.unwrap_err().kind(),
|
result.unwrap_err().kind(),
|
||||||
ErrorKind::MissingRequiredArgument
|
ErrorKind::MissingRequiredArgument
|
||||||
@@ -103,7 +103,7 @@ mod tests {
|
|||||||
"1",
|
"1",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -121,7 +121,7 @@ mod tests {
|
|||||||
"1",
|
"1",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_err());
|
assert_err!(&result);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
result.unwrap_err().kind(),
|
result.unwrap_err().kind(),
|
||||||
ErrorKind::MissingRequiredArgument
|
ErrorKind::MissingRequiredArgument
|
||||||
@@ -143,7 +143,7 @@ mod tests {
|
|||||||
"1",
|
"1",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_err());
|
assert_err!(&result);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
result.unwrap_err().kind(),
|
result.unwrap_err().kind(),
|
||||||
ErrorKind::MissingRequiredArgument
|
ErrorKind::MissingRequiredArgument
|
||||||
@@ -165,7 +165,7 @@ mod tests {
|
|||||||
"1",
|
"1",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_err());
|
assert_err!(&result);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
result.unwrap_err().kind(),
|
result.unwrap_err().kind(),
|
||||||
ErrorKind::MissingRequiredArgument
|
ErrorKind::MissingRequiredArgument
|
||||||
@@ -187,7 +187,7 @@ mod tests {
|
|||||||
"1",
|
"1",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_err());
|
assert_err!(&result);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
result.unwrap_err().kind(),
|
result.unwrap_err().kind(),
|
||||||
ErrorKind::MissingRequiredArgument
|
ErrorKind::MissingRequiredArgument
|
||||||
@@ -211,7 +211,7 @@ mod tests {
|
|||||||
"1",
|
"1",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -227,7 +227,7 @@ mod tests {
|
|||||||
"1",
|
"1",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_err());
|
assert_err!(&result);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
result.unwrap_err().kind(),
|
result.unwrap_err().kind(),
|
||||||
ErrorKind::MissingRequiredArgument
|
ErrorKind::MissingRequiredArgument
|
||||||
@@ -247,7 +247,7 @@ mod tests {
|
|||||||
"1",
|
"1",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_err());
|
assert_err!(&result);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
result.unwrap_err().kind(),
|
result.unwrap_err().kind(),
|
||||||
ErrorKind::MissingRequiredArgument
|
ErrorKind::MissingRequiredArgument
|
||||||
@@ -267,7 +267,7 @@ mod tests {
|
|||||||
"1",
|
"1",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_err());
|
assert_err!(&result);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
result.unwrap_err().kind(),
|
result.unwrap_err().kind(),
|
||||||
ErrorKind::MissingRequiredArgument
|
ErrorKind::MissingRequiredArgument
|
||||||
@@ -289,7 +289,7 @@ mod tests {
|
|||||||
"1",
|
"1",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -303,14 +303,14 @@ mod tests {
|
|||||||
use crate::{
|
use crate::{
|
||||||
app::App,
|
app::App,
|
||||||
cli::{
|
cli::{
|
||||||
sonarr::download_command_handler::{SonarrDownloadCommand, SonarrDownloadCommandHandler},
|
|
||||||
CliCommandHandler,
|
CliCommandHandler,
|
||||||
|
sonarr::download_command_handler::{SonarrDownloadCommand, SonarrDownloadCommandHandler},
|
||||||
},
|
},
|
||||||
models::{
|
models::{
|
||||||
sonarr_models::{SonarrReleaseDownloadBody, SonarrSerdeable},
|
|
||||||
Serdeable,
|
Serdeable,
|
||||||
|
sonarr_models::{SonarrReleaseDownloadBody, SonarrSerdeable},
|
||||||
},
|
},
|
||||||
network::{sonarr_network::SonarrEvent, MockNetworkTrait, NetworkEvent},
|
network::{MockNetworkTrait, NetworkEvent, sonarr_network::SonarrEvent},
|
||||||
};
|
};
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
@@ -345,7 +345,7 @@ mod tests {
|
|||||||
.handle()
|
.handle()
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
@@ -382,7 +382,7 @@ mod tests {
|
|||||||
.handle()
|
.handle()
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
@@ -417,7 +417,7 @@ mod tests {
|
|||||||
.handle()
|
.handle()
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,13 +6,13 @@ use tokio::sync::Mutex;
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
app::App,
|
app::App,
|
||||||
cli::{mutex_flags_or_option, CliCommandHandler, Command},
|
cli::{CliCommandHandler, Command, mutex_flags_or_option},
|
||||||
models::{
|
models::{
|
||||||
|
Serdeable,
|
||||||
servarr_models::EditIndexerParams,
|
servarr_models::EditIndexerParams,
|
||||||
sonarr_models::{EditSeriesParams, IndexerSettings, SeriesType, SonarrSerdeable},
|
sonarr_models::{EditSeriesParams, IndexerSettings, SeriesType, SonarrSerdeable},
|
||||||
Serdeable,
|
|
||||||
},
|
},
|
||||||
network::{sonarr_network::SonarrEvent, NetworkTrait},
|
network::{NetworkTrait, sonarr_network::SonarrEvent},
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::SonarrCommand;
|
use super::SonarrCommand;
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use crate::cli::{
|
use crate::cli::{
|
||||||
sonarr::{edit_command_handler::SonarrEditCommand, SonarrCommand},
|
|
||||||
Command,
|
Command,
|
||||||
|
sonarr::{SonarrCommand, edit_command_handler::SonarrEditCommand},
|
||||||
};
|
};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -20,10 +20,10 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
mod cli {
|
mod cli {
|
||||||
use crate::{models::sonarr_models::SeriesType, Cli};
|
use crate::{Cli, models::sonarr_models::SeriesType};
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
use clap::{error::ErrorKind, CommandFactory, Parser};
|
use clap::{CommandFactory, Parser, error::ErrorKind};
|
||||||
use pretty_assertions::assert_eq;
|
use pretty_assertions::assert_eq;
|
||||||
use rstest::rstest;
|
use rstest::rstest;
|
||||||
|
|
||||||
@@ -32,7 +32,7 @@ mod tests {
|
|||||||
let result =
|
let result =
|
||||||
Cli::command().try_get_matches_from(["managarr", "sonarr", "edit", "all-indexer-settings"]);
|
Cli::command().try_get_matches_from(["managarr", "sonarr", "edit", "all-indexer-settings"]);
|
||||||
|
|
||||||
assert!(result.is_err());
|
assert_err!(&result);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
result.unwrap_err().kind(),
|
result.unwrap_err().kind(),
|
||||||
ErrorKind::MissingRequiredArgument
|
ErrorKind::MissingRequiredArgument
|
||||||
@@ -57,7 +57,7 @@ mod tests {
|
|||||||
flag,
|
flag,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_err());
|
assert_err!(&result);
|
||||||
assert_eq!(result.unwrap_err().kind(), ErrorKind::InvalidValue);
|
assert_eq!(result.unwrap_err().kind(), ErrorKind::InvalidValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -78,11 +78,12 @@ mod tests {
|
|||||||
"1",
|
"1",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
|
|
||||||
if let Some(Command::Sonarr(SonarrCommand::Edit(edit_command))) = result.unwrap().command {
|
let Some(Command::Sonarr(SonarrCommand::Edit(edit_command))) = result.unwrap().command else {
|
||||||
assert_eq!(edit_command, expected_args);
|
panic!("Unexpected command type");
|
||||||
}
|
};
|
||||||
|
assert_eq!(edit_command, expected_args);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -108,18 +109,19 @@ mod tests {
|
|||||||
"1",
|
"1",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
|
|
||||||
if let Some(Command::Sonarr(SonarrCommand::Edit(edit_command))) = result.unwrap().command {
|
let Some(Command::Sonarr(SonarrCommand::Edit(edit_command))) = result.unwrap().command else {
|
||||||
assert_eq!(edit_command, expected_args);
|
panic!("Unexpected command type");
|
||||||
}
|
};
|
||||||
|
assert_eq!(edit_command, expected_args);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_edit_indexer_requires_arguments() {
|
fn test_edit_indexer_requires_arguments() {
|
||||||
let result = Cli::command().try_get_matches_from(["managarr", "sonarr", "edit", "indexer"]);
|
let result = Cli::command().try_get_matches_from(["managarr", "sonarr", "edit", "indexer"]);
|
||||||
|
|
||||||
assert!(result.is_err());
|
assert_err!(&result);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
result.unwrap_err().kind(),
|
result.unwrap_err().kind(),
|
||||||
ErrorKind::MissingRequiredArgument
|
ErrorKind::MissingRequiredArgument
|
||||||
@@ -137,7 +139,7 @@ mod tests {
|
|||||||
"1",
|
"1",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_err());
|
assert_err!(&result);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
result.unwrap_err().kind(),
|
result.unwrap_err().kind(),
|
||||||
ErrorKind::MissingRequiredArgument
|
ErrorKind::MissingRequiredArgument
|
||||||
@@ -157,7 +159,7 @@ mod tests {
|
|||||||
"--disable-rss",
|
"--disable-rss",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_err());
|
assert_err!(&result);
|
||||||
assert_eq!(result.unwrap_err().kind(), ErrorKind::ArgumentConflict);
|
assert_eq!(result.unwrap_err().kind(), ErrorKind::ArgumentConflict);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -174,7 +176,7 @@ mod tests {
|
|||||||
"--disable-automatic-search",
|
"--disable-automatic-search",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_err());
|
assert_err!(&result);
|
||||||
assert_eq!(result.unwrap_err().kind(), ErrorKind::ArgumentConflict);
|
assert_eq!(result.unwrap_err().kind(), ErrorKind::ArgumentConflict);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -191,7 +193,7 @@ mod tests {
|
|||||||
"--disable-interactive-search",
|
"--disable-interactive-search",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_err());
|
assert_err!(&result);
|
||||||
assert_eq!(result.unwrap_err().kind(), ErrorKind::ArgumentConflict);
|
assert_eq!(result.unwrap_err().kind(), ErrorKind::ArgumentConflict);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -209,7 +211,7 @@ mod tests {
|
|||||||
"--clear-tags",
|
"--clear-tags",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_err());
|
assert_err!(&result);
|
||||||
assert_eq!(result.unwrap_err().kind(), ErrorKind::ArgumentConflict);
|
assert_eq!(result.unwrap_err().kind(), ErrorKind::ArgumentConflict);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -227,7 +229,7 @@ mod tests {
|
|||||||
flag,
|
flag,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_err());
|
assert_err!(&result);
|
||||||
assert_eq!(result.unwrap_err().kind(), ErrorKind::InvalidValue);
|
assert_eq!(result.unwrap_err().kind(), ErrorKind::InvalidValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -261,11 +263,12 @@ mod tests {
|
|||||||
"Test",
|
"Test",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
|
|
||||||
if let Some(Command::Sonarr(SonarrCommand::Edit(edit_command))) = result.unwrap().command {
|
let Some(Command::Sonarr(SonarrCommand::Edit(edit_command))) = result.unwrap().command else {
|
||||||
assert_eq!(edit_command, expected_args);
|
panic!("Unexpected command type");
|
||||||
}
|
};
|
||||||
|
assert_eq!(edit_command, expected_args);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -300,11 +303,12 @@ mod tests {
|
|||||||
"2",
|
"2",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
|
|
||||||
if let Some(Command::Sonarr(SonarrCommand::Edit(edit_command))) = result.unwrap().command {
|
let Some(Command::Sonarr(SonarrCommand::Edit(edit_command))) = result.unwrap().command else {
|
||||||
assert_eq!(edit_command, expected_args);
|
panic!("Unexpected command type");
|
||||||
}
|
};
|
||||||
|
assert_eq!(edit_command, expected_args);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -352,18 +356,19 @@ mod tests {
|
|||||||
"25",
|
"25",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
|
|
||||||
if let Some(Command::Sonarr(SonarrCommand::Edit(edit_command))) = result.unwrap().command {
|
let Some(Command::Sonarr(SonarrCommand::Edit(edit_command))) = result.unwrap().command else {
|
||||||
assert_eq!(edit_command, expected_args);
|
panic!("Unexpected command type");
|
||||||
}
|
};
|
||||||
|
assert_eq!(edit_command, expected_args);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_edit_series_requires_arguments() {
|
fn test_edit_series_requires_arguments() {
|
||||||
let result = Cli::command().try_get_matches_from(["managarr", "sonarr", "edit", "series"]);
|
let result = Cli::command().try_get_matches_from(["managarr", "sonarr", "edit", "series"]);
|
||||||
|
|
||||||
assert!(result.is_err());
|
assert_err!(&result);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
result.unwrap_err().kind(),
|
result.unwrap_err().kind(),
|
||||||
ErrorKind::MissingRequiredArgument
|
ErrorKind::MissingRequiredArgument
|
||||||
@@ -381,7 +386,7 @@ mod tests {
|
|||||||
"1",
|
"1",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_err());
|
assert_err!(&result);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
result.unwrap_err().kind(),
|
result.unwrap_err().kind(),
|
||||||
ErrorKind::MissingRequiredArgument
|
ErrorKind::MissingRequiredArgument
|
||||||
@@ -401,7 +406,7 @@ mod tests {
|
|||||||
"--disable-monitoring",
|
"--disable-monitoring",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_err());
|
assert_err!(&result);
|
||||||
assert_eq!(result.unwrap_err().kind(), ErrorKind::ArgumentConflict);
|
assert_eq!(result.unwrap_err().kind(), ErrorKind::ArgumentConflict);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -418,7 +423,7 @@ mod tests {
|
|||||||
"--disable-season-folders",
|
"--disable-season-folders",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_err());
|
assert_err!(&result);
|
||||||
assert_eq!(result.unwrap_err().kind(), ErrorKind::ArgumentConflict);
|
assert_eq!(result.unwrap_err().kind(), ErrorKind::ArgumentConflict);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -436,7 +441,7 @@ mod tests {
|
|||||||
"--clear-tags",
|
"--clear-tags",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_err());
|
assert_err!(&result);
|
||||||
assert_eq!(result.unwrap_err().kind(), ErrorKind::ArgumentConflict);
|
assert_eq!(result.unwrap_err().kind(), ErrorKind::ArgumentConflict);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -461,7 +466,7 @@ mod tests {
|
|||||||
flag,
|
flag,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_err());
|
assert_err!(&result);
|
||||||
assert_eq!(result.unwrap_err().kind(), ErrorKind::InvalidValue);
|
assert_eq!(result.unwrap_err().kind(), ErrorKind::InvalidValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -478,7 +483,7 @@ mod tests {
|
|||||||
"test",
|
"test",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_err());
|
assert_err!(&result);
|
||||||
assert_eq!(result.unwrap_err().kind(), ErrorKind::InvalidValue);
|
assert_eq!(result.unwrap_err().kind(), ErrorKind::InvalidValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -509,11 +514,12 @@ mod tests {
|
|||||||
"/nfs/test",
|
"/nfs/test",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
|
|
||||||
if let Some(Command::Sonarr(SonarrCommand::Edit(edit_command))) = result.unwrap().command {
|
let Some(Command::Sonarr(SonarrCommand::Edit(edit_command))) = result.unwrap().command else {
|
||||||
assert_eq!(edit_command, expected_args);
|
panic!("Unexpected command type");
|
||||||
}
|
};
|
||||||
|
assert_eq!(edit_command, expected_args);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -545,11 +551,12 @@ mod tests {
|
|||||||
"2",
|
"2",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
|
|
||||||
if let Some(Command::Sonarr(SonarrCommand::Edit(edit_command))) = result.unwrap().command {
|
let Some(Command::Sonarr(SonarrCommand::Edit(edit_command))) = result.unwrap().command else {
|
||||||
assert_eq!(edit_command, expected_args);
|
panic!("Unexpected command type");
|
||||||
}
|
};
|
||||||
|
assert_eq!(edit_command, expected_args);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -591,11 +598,12 @@ mod tests {
|
|||||||
"2",
|
"2",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
|
|
||||||
if let Some(Command::Sonarr(SonarrCommand::Edit(edit_command))) = result.unwrap().command {
|
let Some(Command::Sonarr(SonarrCommand::Edit(edit_command))) = result.unwrap().command else {
|
||||||
assert_eq!(edit_command, expected_args);
|
panic!("Unexpected command type");
|
||||||
}
|
};
|
||||||
|
assert_eq!(edit_command, expected_args);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -609,15 +617,15 @@ mod tests {
|
|||||||
use crate::{
|
use crate::{
|
||||||
app::App,
|
app::App,
|
||||||
cli::{
|
cli::{
|
||||||
sonarr::edit_command_handler::{SonarrEditCommand, SonarrEditCommandHandler},
|
|
||||||
CliCommandHandler,
|
CliCommandHandler,
|
||||||
|
sonarr::edit_command_handler::{SonarrEditCommand, SonarrEditCommandHandler},
|
||||||
},
|
},
|
||||||
models::{
|
models::{
|
||||||
|
Serdeable,
|
||||||
servarr_models::EditIndexerParams,
|
servarr_models::EditIndexerParams,
|
||||||
sonarr_models::{EditSeriesParams, IndexerSettings, SeriesType, SonarrSerdeable},
|
sonarr_models::{EditSeriesParams, IndexerSettings, SeriesType, SonarrSerdeable},
|
||||||
Serdeable,
|
|
||||||
},
|
},
|
||||||
network::{sonarr_network::SonarrEvent, MockNetworkTrait, NetworkEvent},
|
network::{MockNetworkTrait, NetworkEvent, sonarr_network::SonarrEvent},
|
||||||
};
|
};
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
@@ -674,7 +682,7 @@ mod tests {
|
|||||||
.handle()
|
.handle()
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
@@ -728,7 +736,7 @@ mod tests {
|
|||||||
.handle()
|
.handle()
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
@@ -776,7 +784,7 @@ mod tests {
|
|||||||
.handle()
|
.handle()
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
@@ -824,7 +832,7 @@ mod tests {
|
|||||||
.handle()
|
.handle()
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
@@ -872,7 +880,7 @@ mod tests {
|
|||||||
.handle()
|
.handle()
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ use tokio::sync::Mutex;
|
|||||||
use crate::{
|
use crate::{
|
||||||
app::App,
|
app::App,
|
||||||
cli::{CliCommandHandler, Command},
|
cli::{CliCommandHandler, Command},
|
||||||
network::{sonarr_network::SonarrEvent, NetworkTrait},
|
network::{NetworkTrait, sonarr_network::SonarrEvent},
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::SonarrCommand;
|
use super::SonarrCommand;
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use crate::cli::{
|
|
||||||
sonarr::{get_command_handler::SonarrGetCommand, SonarrCommand},
|
|
||||||
Command,
|
|
||||||
};
|
|
||||||
use crate::Cli;
|
use crate::Cli;
|
||||||
|
use crate::cli::{
|
||||||
|
Command,
|
||||||
|
sonarr::{SonarrCommand, get_command_handler::SonarrGetCommand},
|
||||||
|
};
|
||||||
use clap::CommandFactory;
|
use clap::CommandFactory;
|
||||||
use pretty_assertions::assert_eq;
|
use pretty_assertions::assert_eq;
|
||||||
|
|
||||||
@@ -28,7 +28,7 @@ mod tests {
|
|||||||
let result =
|
let result =
|
||||||
Cli::command().try_get_matches_from(["managarr", "sonarr", "get", "all-indexer-settings"]);
|
Cli::command().try_get_matches_from(["managarr", "sonarr", "get", "all-indexer-settings"]);
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -36,7 +36,7 @@ mod tests {
|
|||||||
let result =
|
let result =
|
||||||
Cli::command().try_get_matches_from(["managarr", "sonarr", "get", "system-status"]);
|
Cli::command().try_get_matches_from(["managarr", "sonarr", "get", "system-status"]);
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -44,7 +44,7 @@ mod tests {
|
|||||||
let result =
|
let result =
|
||||||
Cli::command().try_get_matches_from(["managarr", "sonarr", "get", "episode-details"]);
|
Cli::command().try_get_matches_from(["managarr", "sonarr", "get", "episode-details"]);
|
||||||
|
|
||||||
assert!(result.is_err());
|
assert_err!(&result);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
result.unwrap_err().kind(),
|
result.unwrap_err().kind(),
|
||||||
ErrorKind::MissingRequiredArgument
|
ErrorKind::MissingRequiredArgument
|
||||||
@@ -62,7 +62,7 @@ mod tests {
|
|||||||
"1",
|
"1",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -70,7 +70,7 @@ mod tests {
|
|||||||
let result =
|
let result =
|
||||||
Cli::command().try_get_matches_from(["managarr", "sonarr", "get", "host-config"]);
|
Cli::command().try_get_matches_from(["managarr", "sonarr", "get", "host-config"]);
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -78,7 +78,7 @@ mod tests {
|
|||||||
let result =
|
let result =
|
||||||
Cli::command().try_get_matches_from(["managarr", "sonarr", "get", "security-config"]);
|
Cli::command().try_get_matches_from(["managarr", "sonarr", "get", "security-config"]);
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -86,7 +86,7 @@ mod tests {
|
|||||||
let result =
|
let result =
|
||||||
Cli::command().try_get_matches_from(["managarr", "sonarr", "get", "series-details"]);
|
Cli::command().try_get_matches_from(["managarr", "sonarr", "get", "series-details"]);
|
||||||
|
|
||||||
assert!(result.is_err());
|
assert_err!(&result);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
result.unwrap_err().kind(),
|
result.unwrap_err().kind(),
|
||||||
ErrorKind::MissingRequiredArgument
|
ErrorKind::MissingRequiredArgument
|
||||||
@@ -104,7 +104,7 @@ mod tests {
|
|||||||
"1",
|
"1",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -118,11 +118,11 @@ mod tests {
|
|||||||
use crate::{
|
use crate::{
|
||||||
app::App,
|
app::App,
|
||||||
cli::{
|
cli::{
|
||||||
sonarr::get_command_handler::{SonarrGetCommand, SonarrGetCommandHandler},
|
|
||||||
CliCommandHandler,
|
CliCommandHandler,
|
||||||
|
sonarr::get_command_handler::{SonarrGetCommand, SonarrGetCommandHandler},
|
||||||
},
|
},
|
||||||
models::{sonarr_models::SonarrSerdeable, Serdeable},
|
models::{Serdeable, sonarr_models::SonarrSerdeable},
|
||||||
network::{sonarr_network::SonarrEvent, MockNetworkTrait, NetworkEvent},
|
network::{MockNetworkTrait, NetworkEvent, sonarr_network::SonarrEvent},
|
||||||
};
|
};
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
@@ -150,7 +150,7 @@ mod tests {
|
|||||||
.handle()
|
.handle()
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
@@ -176,7 +176,7 @@ mod tests {
|
|||||||
.handle()
|
.handle()
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
@@ -199,7 +199,7 @@ mod tests {
|
|||||||
.handle()
|
.handle()
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
@@ -222,7 +222,7 @@ mod tests {
|
|||||||
.handle()
|
.handle()
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
@@ -248,7 +248,7 @@ mod tests {
|
|||||||
.handle()
|
.handle()
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
@@ -271,7 +271,7 @@ mod tests {
|
|||||||
.handle()
|
.handle()
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ use tokio::sync::Mutex;
|
|||||||
use crate::{
|
use crate::{
|
||||||
app::App,
|
app::App,
|
||||||
cli::{CliCommandHandler, Command},
|
cli::{CliCommandHandler, Command},
|
||||||
network::{sonarr_network::SonarrEvent, NetworkTrait},
|
network::{NetworkTrait, sonarr_network::SonarrEvent},
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::SonarrCommand;
|
use super::SonarrCommand;
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use crate::cli::{
|
|
||||||
sonarr::{list_command_handler::SonarrListCommand, SonarrCommand},
|
|
||||||
Command,
|
|
||||||
};
|
|
||||||
use crate::Cli;
|
use crate::Cli;
|
||||||
|
use crate::cli::{
|
||||||
|
Command,
|
||||||
|
sonarr::{SonarrCommand, list_command_handler::SonarrListCommand},
|
||||||
|
};
|
||||||
use clap::CommandFactory;
|
use clap::CommandFactory;
|
||||||
use pretty_assertions::assert_eq;
|
use pretty_assertions::assert_eq;
|
||||||
|
|
||||||
@@ -19,7 +19,7 @@ mod tests {
|
|||||||
|
|
||||||
mod cli {
|
mod cli {
|
||||||
use super::*;
|
use super::*;
|
||||||
use clap::{error::ErrorKind, Parser};
|
use clap::{Parser, error::ErrorKind};
|
||||||
use pretty_assertions::assert_eq;
|
use pretty_assertions::assert_eq;
|
||||||
use rstest::rstest;
|
use rstest::rstest;
|
||||||
|
|
||||||
@@ -42,14 +42,14 @@ mod tests {
|
|||||||
) {
|
) {
|
||||||
let result = Cli::command().try_get_matches_from(["managarr", "sonarr", "list", subcommand]);
|
let result = Cli::command().try_get_matches_from(["managarr", "sonarr", "list", subcommand]);
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_list_episodes_requires_series_id() {
|
fn test_list_episodes_requires_series_id() {
|
||||||
let result = Cli::command().try_get_matches_from(["managarr", "sonarr", "list", "episodes"]);
|
let result = Cli::command().try_get_matches_from(["managarr", "sonarr", "list", "episodes"]);
|
||||||
|
|
||||||
assert!(result.is_err());
|
assert_err!(&result);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
result.unwrap_err().kind(),
|
result.unwrap_err().kind(),
|
||||||
ErrorKind::MissingRequiredArgument
|
ErrorKind::MissingRequiredArgument
|
||||||
@@ -61,7 +61,7 @@ mod tests {
|
|||||||
let result =
|
let result =
|
||||||
Cli::command().try_get_matches_from(["managarr", "sonarr", "list", "episode-files"]);
|
Cli::command().try_get_matches_from(["managarr", "sonarr", "list", "episode-files"]);
|
||||||
|
|
||||||
assert!(result.is_err());
|
assert_err!(&result);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
result.unwrap_err().kind(),
|
result.unwrap_err().kind(),
|
||||||
ErrorKind::MissingRequiredArgument
|
ErrorKind::MissingRequiredArgument
|
||||||
@@ -73,7 +73,7 @@ mod tests {
|
|||||||
let result =
|
let result =
|
||||||
Cli::command().try_get_matches_from(["managarr", "sonarr", "list", "episode-history"]);
|
Cli::command().try_get_matches_from(["managarr", "sonarr", "list", "episode-history"]);
|
||||||
|
|
||||||
assert!(result.is_err());
|
assert_err!(&result);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
result.unwrap_err().kind(),
|
result.unwrap_err().kind(),
|
||||||
ErrorKind::MissingRequiredArgument
|
ErrorKind::MissingRequiredArgument
|
||||||
@@ -92,13 +92,14 @@ mod tests {
|
|||||||
"1",
|
"1",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
|
|
||||||
if let Some(Command::Sonarr(SonarrCommand::List(episode_history_command))) =
|
let Some(Command::Sonarr(SonarrCommand::List(episode_history_command))) =
|
||||||
result.unwrap().command
|
result.unwrap().command
|
||||||
{
|
else {
|
||||||
assert_eq!(episode_history_command, expected_args);
|
panic!("Unexpected command type");
|
||||||
}
|
};
|
||||||
|
assert_eq!(episode_history_command, expected_args);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -106,7 +107,7 @@ mod tests {
|
|||||||
let result =
|
let result =
|
||||||
Cli::command().try_get_matches_from(["managarr", "sonarr", "list", "downloads", "--count"]);
|
Cli::command().try_get_matches_from(["managarr", "sonarr", "list", "downloads", "--count"]);
|
||||||
|
|
||||||
assert!(result.is_err());
|
assert_err!(&result);
|
||||||
assert_eq!(result.unwrap_err().kind(), ErrorKind::InvalidValue);
|
assert_eq!(result.unwrap_err().kind(), ErrorKind::InvalidValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -115,12 +116,13 @@ mod tests {
|
|||||||
let expected_args = SonarrListCommand::Downloads { count: 500 };
|
let expected_args = SonarrListCommand::Downloads { count: 500 };
|
||||||
let result = Cli::try_parse_from(["managarr", "sonarr", "list", "downloads"]);
|
let result = Cli::try_parse_from(["managarr", "sonarr", "list", "downloads"]);
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
|
|
||||||
if let Some(Command::Sonarr(SonarrCommand::List(downloads_command))) = result.unwrap().command
|
let Some(Command::Sonarr(SonarrCommand::List(downloads_command))) = result.unwrap().command
|
||||||
{
|
else {
|
||||||
assert_eq!(downloads_command, expected_args);
|
panic!("Unexpected command type");
|
||||||
}
|
};
|
||||||
|
assert_eq!(downloads_command, expected_args);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -128,7 +130,7 @@ mod tests {
|
|||||||
let result =
|
let result =
|
||||||
Cli::command().try_get_matches_from(["managarr", "sonarr", "list", "history", "--events"]);
|
Cli::command().try_get_matches_from(["managarr", "sonarr", "list", "history", "--events"]);
|
||||||
|
|
||||||
assert!(result.is_err());
|
assert_err!(&result);
|
||||||
assert_eq!(result.unwrap_err().kind(), ErrorKind::InvalidValue);
|
assert_eq!(result.unwrap_err().kind(), ErrorKind::InvalidValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -137,11 +139,13 @@ mod tests {
|
|||||||
let expected_args = SonarrListCommand::History { events: 500 };
|
let expected_args = SonarrListCommand::History { events: 500 };
|
||||||
let result = Cli::try_parse_from(["managarr", "sonarr", "list", "history"]);
|
let result = Cli::try_parse_from(["managarr", "sonarr", "list", "history"]);
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
|
|
||||||
if let Some(Command::Sonarr(SonarrCommand::List(history_command))) = result.unwrap().command {
|
let Some(Command::Sonarr(SonarrCommand::List(history_command))) = result.unwrap().command
|
||||||
assert_eq!(history_command, expected_args);
|
else {
|
||||||
}
|
panic!("Unexpected command type");
|
||||||
|
};
|
||||||
|
assert_eq!(history_command, expected_args);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -149,7 +153,7 @@ mod tests {
|
|||||||
let result =
|
let result =
|
||||||
Cli::command().try_get_matches_from(["managarr", "sonarr", "list", "logs", "--events"]);
|
Cli::command().try_get_matches_from(["managarr", "sonarr", "list", "logs", "--events"]);
|
||||||
|
|
||||||
assert!(result.is_err());
|
assert_err!(&result);
|
||||||
assert_eq!(result.unwrap_err().kind(), ErrorKind::InvalidValue);
|
assert_eq!(result.unwrap_err().kind(), ErrorKind::InvalidValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -161,11 +165,12 @@ mod tests {
|
|||||||
};
|
};
|
||||||
let result = Cli::try_parse_from(["managarr", "sonarr", "list", "logs"]);
|
let result = Cli::try_parse_from(["managarr", "sonarr", "list", "logs"]);
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
|
|
||||||
if let Some(Command::Sonarr(SonarrCommand::List(logs_command))) = result.unwrap().command {
|
let Some(Command::Sonarr(SonarrCommand::List(logs_command))) = result.unwrap().command else {
|
||||||
assert_eq!(logs_command, expected_args);
|
panic!("Unexpected command type");
|
||||||
}
|
};
|
||||||
|
assert_eq!(logs_command, expected_args);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -174,12 +179,13 @@ mod tests {
|
|||||||
let result =
|
let result =
|
||||||
Cli::try_parse_from(["managarr", "sonarr", "list", "episodes", "--series-id", "1"]);
|
Cli::try_parse_from(["managarr", "sonarr", "list", "episodes", "--series-id", "1"]);
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
|
|
||||||
if let Some(Command::Sonarr(SonarrCommand::List(episodes_command))) = result.unwrap().command
|
let Some(Command::Sonarr(SonarrCommand::List(episodes_command))) = result.unwrap().command
|
||||||
{
|
else {
|
||||||
assert_eq!(episodes_command, expected_args);
|
panic!("Unexpected command type");
|
||||||
}
|
};
|
||||||
|
assert_eq!(episodes_command, expected_args);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -194,13 +200,14 @@ mod tests {
|
|||||||
"1",
|
"1",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
|
|
||||||
if let Some(Command::Sonarr(SonarrCommand::List(episode_files_command))) =
|
let Some(Command::Sonarr(SonarrCommand::List(episode_files_command))) =
|
||||||
result.unwrap().command
|
result.unwrap().command
|
||||||
{
|
else {
|
||||||
assert_eq!(episode_files_command, expected_args);
|
panic!("Unexpected command type");
|
||||||
}
|
};
|
||||||
|
assert_eq!(episode_files_command, expected_args);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -214,7 +221,7 @@ mod tests {
|
|||||||
"1",
|
"1",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_err());
|
assert_err!(&result);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
result.unwrap_err().kind(),
|
result.unwrap_err().kind(),
|
||||||
ErrorKind::MissingRequiredArgument
|
ErrorKind::MissingRequiredArgument
|
||||||
@@ -232,7 +239,7 @@ mod tests {
|
|||||||
"1",
|
"1",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_err());
|
assert_err!(&result);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
result.unwrap_err().kind(),
|
result.unwrap_err().kind(),
|
||||||
ErrorKind::MissingRequiredArgument
|
ErrorKind::MissingRequiredArgument
|
||||||
@@ -252,7 +259,7 @@ mod tests {
|
|||||||
"1",
|
"1",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -260,7 +267,7 @@ mod tests {
|
|||||||
let result =
|
let result =
|
||||||
Cli::command().try_get_matches_from(["managarr", "sonarr", "list", "series-history"]);
|
Cli::command().try_get_matches_from(["managarr", "sonarr", "list", "series-history"]);
|
||||||
|
|
||||||
assert!(result.is_err());
|
assert_err!(&result);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
result.unwrap_err().kind(),
|
result.unwrap_err().kind(),
|
||||||
ErrorKind::MissingRequiredArgument
|
ErrorKind::MissingRequiredArgument
|
||||||
@@ -279,11 +286,13 @@ mod tests {
|
|||||||
"1",
|
"1",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
|
|
||||||
if let Some(Command::Sonarr(SonarrCommand::List(series_command))) = result.unwrap().command {
|
let Some(Command::Sonarr(SonarrCommand::List(series_command))) = result.unwrap().command
|
||||||
assert_eq!(series_command, expected_args);
|
else {
|
||||||
}
|
panic!("Unexpected command type");
|
||||||
|
};
|
||||||
|
assert_eq!(series_command, expected_args);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -296,10 +305,10 @@ mod tests {
|
|||||||
use serde_json::json;
|
use serde_json::json;
|
||||||
use tokio::sync::Mutex;
|
use tokio::sync::Mutex;
|
||||||
|
|
||||||
use crate::cli::sonarr::list_command_handler::{SonarrListCommand, SonarrListCommandHandler};
|
|
||||||
use crate::cli::CliCommandHandler;
|
use crate::cli::CliCommandHandler;
|
||||||
use crate::models::sonarr_models::SonarrSerdeable;
|
use crate::cli::sonarr::list_command_handler::{SonarrListCommand, SonarrListCommandHandler};
|
||||||
use crate::models::Serdeable;
|
use crate::models::Serdeable;
|
||||||
|
use crate::models::sonarr_models::SonarrSerdeable;
|
||||||
use crate::network::sonarr_network::SonarrEvent;
|
use crate::network::sonarr_network::SonarrEvent;
|
||||||
use crate::{
|
use crate::{
|
||||||
app::App,
|
app::App,
|
||||||
@@ -339,7 +348,7 @@ mod tests {
|
|||||||
.handle()
|
.handle()
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
@@ -365,7 +374,7 @@ mod tests {
|
|||||||
.handle()
|
.handle()
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
@@ -391,7 +400,7 @@ mod tests {
|
|||||||
.handle()
|
.handle()
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
@@ -417,7 +426,7 @@ mod tests {
|
|||||||
.handle()
|
.handle()
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
@@ -443,7 +452,7 @@ mod tests {
|
|||||||
.handle()
|
.handle()
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
@@ -471,7 +480,7 @@ mod tests {
|
|||||||
.handle()
|
.handle()
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
@@ -497,7 +506,7 @@ mod tests {
|
|||||||
.handle()
|
.handle()
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
@@ -523,7 +532,7 @@ mod tests {
|
|||||||
.handle()
|
.handle()
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
@@ -553,7 +562,7 @@ mod tests {
|
|||||||
.handle()
|
.handle()
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ use tokio::sync::Mutex;
|
|||||||
use crate::{
|
use crate::{
|
||||||
app::App,
|
app::App,
|
||||||
cli::{CliCommandHandler, Command},
|
cli::{CliCommandHandler, Command},
|
||||||
network::{sonarr_network::SonarrEvent, NetworkTrait},
|
network::{NetworkTrait, sonarr_network::SonarrEvent},
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::SonarrCommand;
|
use super::SonarrCommand;
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use crate::cli::{
|
|
||||||
sonarr::{manual_search_command_handler::SonarrManualSearchCommand, SonarrCommand},
|
|
||||||
Command,
|
|
||||||
};
|
|
||||||
use crate::Cli;
|
use crate::Cli;
|
||||||
|
use crate::cli::{
|
||||||
|
Command,
|
||||||
|
sonarr::{SonarrCommand, manual_search_command_handler::SonarrManualSearchCommand},
|
||||||
|
};
|
||||||
use clap::CommandFactory;
|
use clap::CommandFactory;
|
||||||
use pretty_assertions::assert_eq;
|
use pretty_assertions::assert_eq;
|
||||||
|
|
||||||
@@ -36,7 +36,7 @@ mod tests {
|
|||||||
"1",
|
"1",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_err());
|
assert_err!(&result);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
result.unwrap_err().kind(),
|
result.unwrap_err().kind(),
|
||||||
ErrorKind::MissingRequiredArgument
|
ErrorKind::MissingRequiredArgument
|
||||||
@@ -54,7 +54,7 @@ mod tests {
|
|||||||
"1",
|
"1",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_err());
|
assert_err!(&result);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
result.unwrap_err().kind(),
|
result.unwrap_err().kind(),
|
||||||
ErrorKind::MissingRequiredArgument
|
ErrorKind::MissingRequiredArgument
|
||||||
@@ -74,7 +74,7 @@ mod tests {
|
|||||||
"1",
|
"1",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -82,7 +82,7 @@ mod tests {
|
|||||||
let result =
|
let result =
|
||||||
Cli::command().try_get_matches_from(["managarr", "sonarr", "manual-search", "episode"]);
|
Cli::command().try_get_matches_from(["managarr", "sonarr", "manual-search", "episode"]);
|
||||||
|
|
||||||
assert!(result.is_err());
|
assert_err!(&result);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
result.unwrap_err().kind(),
|
result.unwrap_err().kind(),
|
||||||
ErrorKind::MissingRequiredArgument
|
ErrorKind::MissingRequiredArgument
|
||||||
@@ -100,7 +100,7 @@ mod tests {
|
|||||||
"1",
|
"1",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -114,13 +114,13 @@ mod tests {
|
|||||||
use crate::{
|
use crate::{
|
||||||
app::App,
|
app::App,
|
||||||
cli::{
|
cli::{
|
||||||
|
CliCommandHandler,
|
||||||
sonarr::manual_search_command_handler::{
|
sonarr::manual_search_command_handler::{
|
||||||
SonarrManualSearchCommand, SonarrManualSearchCommandHandler,
|
SonarrManualSearchCommand, SonarrManualSearchCommandHandler,
|
||||||
},
|
},
|
||||||
CliCommandHandler,
|
|
||||||
},
|
},
|
||||||
models::{sonarr_models::SonarrSerdeable, Serdeable},
|
models::{Serdeable, sonarr_models::SonarrSerdeable},
|
||||||
network::{sonarr_network::SonarrEvent, MockNetworkTrait, NetworkEvent},
|
network::{MockNetworkTrait, NetworkEvent, sonarr_network::SonarrEvent},
|
||||||
};
|
};
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
@@ -149,7 +149,7 @@ mod tests {
|
|||||||
.handle()
|
.handle()
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
@@ -182,7 +182,7 @@ mod tests {
|
|||||||
.handle()
|
.handle()
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ use trigger_automatic_search_command_handler::{
|
|||||||
use crate::{
|
use crate::{
|
||||||
app::App,
|
app::App,
|
||||||
models::sonarr_models::SonarrTaskName,
|
models::sonarr_models::SonarrTaskName,
|
||||||
network::{sonarr_network::SonarrEvent, NetworkTrait},
|
network::{NetworkTrait, sonarr_network::SonarrEvent},
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::{CliCommandHandler, Command};
|
use super::{CliCommandHandler, Command};
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ use tokio::sync::Mutex;
|
|||||||
use crate::{
|
use crate::{
|
||||||
app::App,
|
app::App,
|
||||||
cli::{CliCommandHandler, Command},
|
cli::{CliCommandHandler, Command},
|
||||||
network::{sonarr_network::SonarrEvent, NetworkTrait},
|
network::{NetworkTrait, sonarr_network::SonarrEvent},
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::SonarrCommand;
|
use super::SonarrCommand;
|
||||||
|
|||||||
@@ -2,11 +2,11 @@
|
|||||||
mod tests {
|
mod tests {
|
||||||
use pretty_assertions::assert_eq;
|
use pretty_assertions::assert_eq;
|
||||||
|
|
||||||
use crate::cli::{
|
|
||||||
sonarr::{refresh_command_handler::SonarrRefreshCommand, SonarrCommand},
|
|
||||||
Command,
|
|
||||||
};
|
|
||||||
use crate::Cli;
|
use crate::Cli;
|
||||||
|
use crate::cli::{
|
||||||
|
Command,
|
||||||
|
sonarr::{SonarrCommand, refresh_command_handler::SonarrRefreshCommand},
|
||||||
|
};
|
||||||
use clap::CommandFactory;
|
use clap::CommandFactory;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -20,7 +20,7 @@ mod tests {
|
|||||||
|
|
||||||
mod cli {
|
mod cli {
|
||||||
use super::*;
|
use super::*;
|
||||||
use clap::{error::ErrorKind, Parser};
|
use clap::{Parser, error::ErrorKind};
|
||||||
use pretty_assertions::assert_eq;
|
use pretty_assertions::assert_eq;
|
||||||
use rstest::rstest;
|
use rstest::rstest;
|
||||||
|
|
||||||
@@ -31,14 +31,14 @@ mod tests {
|
|||||||
let result =
|
let result =
|
||||||
Cli::command().try_get_matches_from(["managarr", "sonarr", "refresh", subcommand]);
|
Cli::command().try_get_matches_from(["managarr", "sonarr", "refresh", subcommand]);
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_refresh_series_requires_series_id() {
|
fn test_refresh_series_requires_series_id() {
|
||||||
let result = Cli::command().try_get_matches_from(["managarr", "sonarr", "refresh", "series"]);
|
let result = Cli::command().try_get_matches_from(["managarr", "sonarr", "refresh", "series"]);
|
||||||
|
|
||||||
assert!(result.is_err());
|
assert_err!(&result);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
result.unwrap_err().kind(),
|
result.unwrap_err().kind(),
|
||||||
ErrorKind::MissingRequiredArgument
|
ErrorKind::MissingRequiredArgument
|
||||||
@@ -57,13 +57,13 @@ mod tests {
|
|||||||
"1",
|
"1",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
|
|
||||||
if let Some(Command::Sonarr(SonarrCommand::Refresh(refresh_command))) =
|
let Some(Command::Sonarr(SonarrCommand::Refresh(refresh_command))) = result.unwrap().command
|
||||||
result.unwrap().command
|
else {
|
||||||
{
|
panic!("Unexpected command type");
|
||||||
assert_eq!(refresh_command, expected_args);
|
};
|
||||||
}
|
assert_eq!(refresh_command, expected_args);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -77,11 +77,11 @@ mod tests {
|
|||||||
|
|
||||||
use crate::{app::App, cli::sonarr::refresh_command_handler::SonarrRefreshCommandHandler};
|
use crate::{app::App, cli::sonarr::refresh_command_handler::SonarrRefreshCommandHandler};
|
||||||
use crate::{
|
use crate::{
|
||||||
cli::{sonarr::refresh_command_handler::SonarrRefreshCommand, CliCommandHandler},
|
cli::{CliCommandHandler, sonarr::refresh_command_handler::SonarrRefreshCommand},
|
||||||
network::sonarr_network::SonarrEvent,
|
network::sonarr_network::SonarrEvent,
|
||||||
};
|
};
|
||||||
use crate::{
|
use crate::{
|
||||||
models::{sonarr_models::SonarrSerdeable, Serdeable},
|
models::{Serdeable, sonarr_models::SonarrSerdeable},
|
||||||
network::{MockNetworkTrait, NetworkEvent},
|
network::{MockNetworkTrait, NetworkEvent},
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -109,7 +109,7 @@ mod tests {
|
|||||||
.handle()
|
.handle()
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
@@ -135,7 +135,7 @@ mod tests {
|
|||||||
.handle()
|
.handle()
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use crate::cli::{
|
|
||||||
sonarr::{list_command_handler::SonarrListCommand, SonarrCommand},
|
|
||||||
Command,
|
|
||||||
};
|
|
||||||
use crate::Cli;
|
use crate::Cli;
|
||||||
|
use crate::cli::{
|
||||||
|
Command,
|
||||||
|
sonarr::{SonarrCommand, list_command_handler::SonarrListCommand},
|
||||||
|
};
|
||||||
use clap::CommandFactory;
|
use clap::CommandFactory;
|
||||||
use pretty_assertions::assert_eq;
|
use pretty_assertions::assert_eq;
|
||||||
|
|
||||||
@@ -29,7 +29,7 @@ mod tests {
|
|||||||
) {
|
) {
|
||||||
let result = Cli::command().try_get_matches_from(["managarr", "sonarr", subcommand]);
|
let result = Cli::command().try_get_matches_from(["managarr", "sonarr", subcommand]);
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -37,7 +37,7 @@ mod tests {
|
|||||||
let result =
|
let result =
|
||||||
Cli::command().try_get_matches_from(["managarr", "sonarr", "mark-history-item-as-failed"]);
|
Cli::command().try_get_matches_from(["managarr", "sonarr", "mark-history-item-as-failed"]);
|
||||||
|
|
||||||
assert!(result.is_err());
|
assert_err!(&result);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
result.unwrap_err().kind(),
|
result.unwrap_err().kind(),
|
||||||
ErrorKind::MissingRequiredArgument
|
ErrorKind::MissingRequiredArgument
|
||||||
@@ -54,14 +54,14 @@ mod tests {
|
|||||||
"1",
|
"1",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_search_new_series_requires_query() {
|
fn test_search_new_series_requires_query() {
|
||||||
let result = Cli::command().try_get_matches_from(["managarr", "sonarr", "search-new-series"]);
|
let result = Cli::command().try_get_matches_from(["managarr", "sonarr", "search-new-series"]);
|
||||||
|
|
||||||
assert!(result.is_err());
|
assert_err!(&result);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
result.unwrap_err().kind(),
|
result.unwrap_err().kind(),
|
||||||
ErrorKind::MissingRequiredArgument
|
ErrorKind::MissingRequiredArgument
|
||||||
@@ -78,14 +78,14 @@ mod tests {
|
|||||||
"halo",
|
"halo",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_start_task_requires_task_name() {
|
fn test_start_task_requires_task_name() {
|
||||||
let result = Cli::command().try_get_matches_from(["managarr", "sonarr", "start-task"]);
|
let result = Cli::command().try_get_matches_from(["managarr", "sonarr", "start-task"]);
|
||||||
|
|
||||||
assert!(result.is_err());
|
assert_err!(&result);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
result.unwrap_err().kind(),
|
result.unwrap_err().kind(),
|
||||||
ErrorKind::MissingRequiredArgument
|
ErrorKind::MissingRequiredArgument
|
||||||
@@ -102,7 +102,7 @@ mod tests {
|
|||||||
"test",
|
"test",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_err());
|
assert_err!(&result);
|
||||||
assert_eq!(result.unwrap_err().kind(), ErrorKind::InvalidValue);
|
assert_eq!(result.unwrap_err().kind(), ErrorKind::InvalidValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -116,14 +116,14 @@ mod tests {
|
|||||||
"application-update-check",
|
"application-update-check",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_test_indexer_requires_indexer_id() {
|
fn test_test_indexer_requires_indexer_id() {
|
||||||
let result = Cli::command().try_get_matches_from(["managarr", "sonarr", "test-indexer"]);
|
let result = Cli::command().try_get_matches_from(["managarr", "sonarr", "test-indexer"]);
|
||||||
|
|
||||||
assert!(result.is_err());
|
assert_err!(&result);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
result.unwrap_err().kind(),
|
result.unwrap_err().kind(),
|
||||||
ErrorKind::MissingRequiredArgument
|
ErrorKind::MissingRequiredArgument
|
||||||
@@ -140,7 +140,7 @@ mod tests {
|
|||||||
"1",
|
"1",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -148,7 +148,7 @@ mod tests {
|
|||||||
let result =
|
let result =
|
||||||
Cli::command().try_get_matches_from(["managarr", "sonarr", "toggle-episode-monitoring"]);
|
Cli::command().try_get_matches_from(["managarr", "sonarr", "toggle-episode-monitoring"]);
|
||||||
|
|
||||||
assert!(result.is_err());
|
assert_err!(&result);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
result.unwrap_err().kind(),
|
result.unwrap_err().kind(),
|
||||||
ErrorKind::MissingRequiredArgument
|
ErrorKind::MissingRequiredArgument
|
||||||
@@ -165,7 +165,7 @@ mod tests {
|
|||||||
"1",
|
"1",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -178,7 +178,7 @@ mod tests {
|
|||||||
"1",
|
"1",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_err());
|
assert_err!(&result);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
result.unwrap_err().kind(),
|
result.unwrap_err().kind(),
|
||||||
ErrorKind::MissingRequiredArgument
|
ErrorKind::MissingRequiredArgument
|
||||||
@@ -195,7 +195,7 @@ mod tests {
|
|||||||
"1",
|
"1",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_err());
|
assert_err!(&result);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
result.unwrap_err().kind(),
|
result.unwrap_err().kind(),
|
||||||
ErrorKind::MissingRequiredArgument
|
ErrorKind::MissingRequiredArgument
|
||||||
@@ -214,7 +214,7 @@ mod tests {
|
|||||||
"1",
|
"1",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -222,7 +222,7 @@ mod tests {
|
|||||||
let result =
|
let result =
|
||||||
Cli::command().try_get_matches_from(["managarr", "sonarr", "toggle-series-monitoring"]);
|
Cli::command().try_get_matches_from(["managarr", "sonarr", "toggle-series-monitoring"]);
|
||||||
|
|
||||||
assert!(result.is_err());
|
assert_err!(&result);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
result.unwrap_err().kind(),
|
result.unwrap_err().kind(),
|
||||||
ErrorKind::MissingRequiredArgument
|
ErrorKind::MissingRequiredArgument
|
||||||
@@ -239,7 +239,7 @@ mod tests {
|
|||||||
"1",
|
"1",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -253,25 +253,25 @@ mod tests {
|
|||||||
use crate::{
|
use crate::{
|
||||||
app::App,
|
app::App,
|
||||||
cli::{
|
cli::{
|
||||||
|
CliCommandHandler,
|
||||||
sonarr::{
|
sonarr::{
|
||||||
add_command_handler::SonarrAddCommand, delete_command_handler::SonarrDeleteCommand,
|
SonarrCliHandler, SonarrCommand, add_command_handler::SonarrAddCommand,
|
||||||
|
delete_command_handler::SonarrDeleteCommand,
|
||||||
download_command_handler::SonarrDownloadCommand, edit_command_handler::SonarrEditCommand,
|
download_command_handler::SonarrDownloadCommand, edit_command_handler::SonarrEditCommand,
|
||||||
get_command_handler::SonarrGetCommand, list_command_handler::SonarrListCommand,
|
get_command_handler::SonarrGetCommand, list_command_handler::SonarrListCommand,
|
||||||
manual_search_command_handler::SonarrManualSearchCommand,
|
manual_search_command_handler::SonarrManualSearchCommand,
|
||||||
refresh_command_handler::SonarrRefreshCommand,
|
refresh_command_handler::SonarrRefreshCommand,
|
||||||
trigger_automatic_search_command_handler::SonarrTriggerAutomaticSearchCommand,
|
trigger_automatic_search_command_handler::SonarrTriggerAutomaticSearchCommand,
|
||||||
SonarrCliHandler, SonarrCommand,
|
|
||||||
},
|
},
|
||||||
CliCommandHandler,
|
|
||||||
},
|
},
|
||||||
models::{
|
models::{
|
||||||
|
Serdeable,
|
||||||
sonarr_models::{
|
sonarr_models::{
|
||||||
BlocklistItem, BlocklistResponse, IndexerSettings, Series, SonarrReleaseDownloadBody,
|
BlocklistItem, BlocklistResponse, IndexerSettings, Series, SonarrReleaseDownloadBody,
|
||||||
SonarrSerdeable, SonarrTaskName,
|
SonarrSerdeable, SonarrTaskName,
|
||||||
},
|
},
|
||||||
Serdeable,
|
|
||||||
},
|
},
|
||||||
network::{sonarr_network::SonarrEvent, MockNetworkTrait, NetworkEvent},
|
network::{MockNetworkTrait, NetworkEvent, sonarr_network::SonarrEvent},
|
||||||
};
|
};
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
@@ -304,7 +304,7 @@ mod tests {
|
|||||||
.handle()
|
.handle()
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
@@ -334,7 +334,7 @@ mod tests {
|
|||||||
.handle()
|
.handle()
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
@@ -361,7 +361,7 @@ mod tests {
|
|||||||
.handle()
|
.handle()
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
@@ -390,7 +390,7 @@ mod tests {
|
|||||||
.handle()
|
.handle()
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
@@ -426,7 +426,7 @@ mod tests {
|
|||||||
.handle()
|
.handle()
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
@@ -484,12 +484,12 @@ mod tests {
|
|||||||
.handle()
|
.handle()
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn test_sonarr_cli_handler_delegates_manual_search_commands_to_the_manual_search_command_handler(
|
async fn test_sonarr_cli_handler_delegates_manual_search_commands_to_the_manual_search_command_handler()
|
||||||
) {
|
{
|
||||||
let expected_episode_id = 1;
|
let expected_episode_id = 1;
|
||||||
let mut mock_network = MockNetworkTrait::new();
|
let mut mock_network = MockNetworkTrait::new();
|
||||||
mock_network
|
mock_network
|
||||||
@@ -512,12 +512,12 @@ mod tests {
|
|||||||
.handle()
|
.handle()
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn test_sonarr_cli_handler_delegates_trigger_automatic_search_commands_to_the_trigger_automatic_search_command_handler(
|
async fn test_sonarr_cli_handler_delegates_trigger_automatic_search_commands_to_the_trigger_automatic_search_command_handler()
|
||||||
) {
|
{
|
||||||
let expected_episode_id = 1;
|
let expected_episode_id = 1;
|
||||||
let mut mock_network = MockNetworkTrait::new();
|
let mut mock_network = MockNetworkTrait::new();
|
||||||
mock_network
|
mock_network
|
||||||
@@ -542,7 +542,7 @@ mod tests {
|
|||||||
.handle()
|
.handle()
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
@@ -564,7 +564,7 @@ mod tests {
|
|||||||
.handle()
|
.handle()
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
@@ -586,7 +586,7 @@ mod tests {
|
|||||||
.handle()
|
.handle()
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
@@ -612,7 +612,7 @@ mod tests {
|
|||||||
.handle()
|
.handle()
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
@@ -639,7 +639,7 @@ mod tests {
|
|||||||
.handle()
|
.handle()
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
@@ -666,7 +666,7 @@ mod tests {
|
|||||||
.handle()
|
.handle()
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
@@ -691,7 +691,7 @@ mod tests {
|
|||||||
.handle()
|
.handle()
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
@@ -713,7 +713,7 @@ mod tests {
|
|||||||
.handle()
|
.handle()
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
@@ -743,7 +743,7 @@ mod tests {
|
|||||||
.handle()
|
.handle()
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
@@ -776,7 +776,7 @@ mod tests {
|
|||||||
.handle()
|
.handle()
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
@@ -805,7 +805,7 @@ mod tests {
|
|||||||
.handle()
|
.handle()
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ use tokio::sync::Mutex;
|
|||||||
use crate::{
|
use crate::{
|
||||||
app::App,
|
app::App,
|
||||||
cli::{CliCommandHandler, Command},
|
cli::{CliCommandHandler, Command},
|
||||||
network::{sonarr_network::SonarrEvent, NetworkTrait},
|
network::{NetworkTrait, sonarr_network::SonarrEvent},
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::SonarrCommand;
|
use super::SonarrCommand;
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use crate::cli::{
|
|
||||||
sonarr::{
|
|
||||||
trigger_automatic_search_command_handler::SonarrTriggerAutomaticSearchCommand, SonarrCommand,
|
|
||||||
},
|
|
||||||
Command,
|
|
||||||
};
|
|
||||||
use crate::Cli;
|
use crate::Cli;
|
||||||
|
use crate::cli::{
|
||||||
|
Command,
|
||||||
|
sonarr::{
|
||||||
|
SonarrCommand, trigger_automatic_search_command_handler::SonarrTriggerAutomaticSearchCommand,
|
||||||
|
},
|
||||||
|
};
|
||||||
use clap::CommandFactory;
|
use clap::CommandFactory;
|
||||||
use pretty_assertions::assert_eq;
|
use pretty_assertions::assert_eq;
|
||||||
|
|
||||||
@@ -36,7 +36,7 @@ mod tests {
|
|||||||
"series",
|
"series",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_err());
|
assert_err!(&result);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
result.unwrap_err().kind(),
|
result.unwrap_err().kind(),
|
||||||
ErrorKind::MissingRequiredArgument
|
ErrorKind::MissingRequiredArgument
|
||||||
@@ -54,7 +54,7 @@ mod tests {
|
|||||||
"1",
|
"1",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -68,7 +68,7 @@ mod tests {
|
|||||||
"1",
|
"1",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_err());
|
assert_err!(&result);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
result.unwrap_err().kind(),
|
result.unwrap_err().kind(),
|
||||||
ErrorKind::MissingRequiredArgument
|
ErrorKind::MissingRequiredArgument
|
||||||
@@ -86,7 +86,7 @@ mod tests {
|
|||||||
"1",
|
"1",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_err());
|
assert_err!(&result);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
result.unwrap_err().kind(),
|
result.unwrap_err().kind(),
|
||||||
ErrorKind::MissingRequiredArgument
|
ErrorKind::MissingRequiredArgument
|
||||||
@@ -106,7 +106,7 @@ mod tests {
|
|||||||
"1",
|
"1",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -118,7 +118,7 @@ mod tests {
|
|||||||
"episode",
|
"episode",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_err());
|
assert_err!(&result);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
result.unwrap_err().kind(),
|
result.unwrap_err().kind(),
|
||||||
ErrorKind::MissingRequiredArgument
|
ErrorKind::MissingRequiredArgument
|
||||||
@@ -136,7 +136,7 @@ mod tests {
|
|||||||
"1",
|
"1",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -150,13 +150,13 @@ mod tests {
|
|||||||
use crate::{
|
use crate::{
|
||||||
app::App,
|
app::App,
|
||||||
cli::{
|
cli::{
|
||||||
|
CliCommandHandler,
|
||||||
sonarr::trigger_automatic_search_command_handler::{
|
sonarr::trigger_automatic_search_command_handler::{
|
||||||
SonarrTriggerAutomaticSearchCommand, SonarrTriggerAutomaticSearchCommandHandler,
|
SonarrTriggerAutomaticSearchCommand, SonarrTriggerAutomaticSearchCommandHandler,
|
||||||
},
|
},
|
||||||
CliCommandHandler,
|
|
||||||
},
|
},
|
||||||
models::{sonarr_models::SonarrSerdeable, Serdeable},
|
models::{Serdeable, sonarr_models::SonarrSerdeable},
|
||||||
network::{sonarr_network::SonarrEvent, MockNetworkTrait, NetworkEvent},
|
network::{MockNetworkTrait, NetworkEvent, sonarr_network::SonarrEvent},
|
||||||
};
|
};
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
@@ -186,7 +186,7 @@ mod tests {
|
|||||||
.handle()
|
.handle()
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
@@ -220,7 +220,7 @@ mod tests {
|
|||||||
.handle()
|
.handle()
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
@@ -250,7 +250,7 @@ mod tests {
|
|||||||
.handle()
|
.handle()
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert_ok!(&result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,14 +28,14 @@ impl Events {
|
|||||||
let timeout = tick_rate
|
let timeout = tick_rate
|
||||||
.checked_sub(last_tick.elapsed())
|
.checked_sub(last_tick.elapsed())
|
||||||
.unwrap_or_else(|| Duration::from_secs(0));
|
.unwrap_or_else(|| Duration::from_secs(0));
|
||||||
if event::poll(timeout).unwrap() {
|
if event::poll(timeout).unwrap()
|
||||||
if let CrosstermEvent::Key(key_event) = event::read().unwrap() {
|
&& let CrosstermEvent::Key(key_event) = event::read().unwrap()
|
||||||
// Only process the key event if it's a press event
|
{
|
||||||
// Source: https://ratatui.rs/faq/ Why am I getting duplicate key events on Windows?
|
// Only process the key event if it's a press event
|
||||||
if key_event.kind == KeyEventKind::Press {
|
// Source: https://ratatui.rs/faq/ Why am I getting duplicate key events on Windows?
|
||||||
let key = Key::from(key_event);
|
if key_event.kind == KeyEventKind::Press {
|
||||||
tx.send(InputEvent::KeyEvent(key)).unwrap();
|
let key = Key::from(key_event);
|
||||||
}
|
tx.send(InputEvent::KeyEvent(key)).unwrap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,221 @@
|
|||||||
|
#[cfg(test)]
|
||||||
|
mod property_tests {
|
||||||
|
use proptest::prelude::*;
|
||||||
|
|
||||||
|
use crate::app::App;
|
||||||
|
use crate::handlers::handler_test_utils::test_utils::proptest_helpers::*;
|
||||||
|
use crate::models::servarr_data::radarr::radarr_data::ActiveRadarrBlock;
|
||||||
|
use crate::models::stateful_table::StatefulTable;
|
||||||
|
use crate::models::radarr_models::Movie;
|
||||||
|
use crate::models::{Scrollable, Paginated};
|
||||||
|
|
||||||
|
proptest! {
|
||||||
|
/// Property test: Table never panics on index selection
|
||||||
|
#[test]
|
||||||
|
fn test_table_index_selection_safety(
|
||||||
|
list_size in list_size(),
|
||||||
|
index in 0usize..1000
|
||||||
|
) {
|
||||||
|
let mut table = StatefulTable::<Movie>::default();
|
||||||
|
let movies: Vec<Movie> = (0..list_size).map(|i| {
|
||||||
|
let mut movie = Movie::default();
|
||||||
|
movie.id = i as i64;
|
||||||
|
movie
|
||||||
|
}).collect();
|
||||||
|
|
||||||
|
table.set_items(movies);
|
||||||
|
|
||||||
|
// Try to select an arbitrary index
|
||||||
|
if index < list_size {
|
||||||
|
table.select_index(Some(index));
|
||||||
|
let selected = table.current_selection();
|
||||||
|
prop_assert_eq!(selected.id, index as i64);
|
||||||
|
} else {
|
||||||
|
// Out of bounds selection should be safe
|
||||||
|
table.select_index(Some(index));
|
||||||
|
// Should not panic, selection stays valid
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Property test: Table state remains consistent after scroll operations
|
||||||
|
#[test]
|
||||||
|
fn test_table_scroll_consistency(
|
||||||
|
list_size in list_size(),
|
||||||
|
scroll_amount in 0usize..20
|
||||||
|
) {
|
||||||
|
let mut table = StatefulTable::<Movie>::default();
|
||||||
|
let movies: Vec<Movie> = (0..list_size).map(|i| {
|
||||||
|
let mut movie = Movie::default();
|
||||||
|
movie.id = i as i64;
|
||||||
|
movie
|
||||||
|
}).collect();
|
||||||
|
|
||||||
|
table.set_items(movies);
|
||||||
|
let initial_id = table.current_selection().id;
|
||||||
|
|
||||||
|
// Scroll down multiple times
|
||||||
|
for _ in 0..scroll_amount {
|
||||||
|
table.scroll_down();
|
||||||
|
}
|
||||||
|
let after_down_id = table.current_selection().id;
|
||||||
|
|
||||||
|
// Position should increase (up to max)
|
||||||
|
prop_assert!(after_down_id >= initial_id);
|
||||||
|
prop_assert!(after_down_id < list_size as i64);
|
||||||
|
|
||||||
|
// Scroll back up
|
||||||
|
for _ in 0..scroll_amount {
|
||||||
|
table.scroll_up();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Should return to initial position (or 0 if we hit the top)
|
||||||
|
prop_assert!(table.current_selection().id <= initial_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Property test: Empty tables handle operations gracefully
|
||||||
|
#[test]
|
||||||
|
fn test_empty_table_safety(_scroll_ops in 0usize..50) {
|
||||||
|
let table = StatefulTable::<Movie>::default();
|
||||||
|
|
||||||
|
// Empty table operations should be safe
|
||||||
|
prop_assert!(table.is_empty());
|
||||||
|
prop_assert!(table.items.is_empty());
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Property test: Navigation operations maintain consistency
|
||||||
|
#[test]
|
||||||
|
fn test_navigation_consistency(pushes in 1usize..20) {
|
||||||
|
let mut app = App::test_default();
|
||||||
|
let initial_route = app.get_current_route();
|
||||||
|
|
||||||
|
// Push multiple routes
|
||||||
|
let routes = vec![
|
||||||
|
ActiveRadarrBlock::Movies,
|
||||||
|
ActiveRadarrBlock::Collections,
|
||||||
|
ActiveRadarrBlock::Downloads,
|
||||||
|
ActiveRadarrBlock::Blocklist,
|
||||||
|
];
|
||||||
|
|
||||||
|
for i in 0..pushes {
|
||||||
|
let route = routes[i % routes.len()];
|
||||||
|
app.push_navigation_stack(route.into());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Current route should be the last pushed
|
||||||
|
let last_pushed = routes[(pushes - 1) % routes.len()];
|
||||||
|
prop_assert_eq!(app.get_current_route(), last_pushed.into());
|
||||||
|
|
||||||
|
// Pop all routes
|
||||||
|
for _ in 0..pushes {
|
||||||
|
app.pop_navigation_stack();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Should return to initial route
|
||||||
|
prop_assert_eq!(app.get_current_route(), initial_route);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Property test: String input handling is safe
|
||||||
|
#[test]
|
||||||
|
fn test_string_input_safety(input in text_input_string()) {
|
||||||
|
// String operations should never panic
|
||||||
|
let _lowercase = input.to_lowercase();
|
||||||
|
let _uppercase = input.to_uppercase();
|
||||||
|
let _trimmed = input.trim();
|
||||||
|
let _len = input.len();
|
||||||
|
let _chars: Vec<char> = input.chars().collect();
|
||||||
|
|
||||||
|
// All operations completed without panic
|
||||||
|
prop_assert!(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Property test: Table maintains data integrity after operations
|
||||||
|
#[test]
|
||||||
|
fn test_table_data_integrity(
|
||||||
|
list_size in 1usize..100
|
||||||
|
) {
|
||||||
|
let mut table = StatefulTable::<Movie>::default();
|
||||||
|
let movies: Vec<Movie> = (0..list_size).map(|i| {
|
||||||
|
let mut movie = Movie::default();
|
||||||
|
movie.id = i as i64;
|
||||||
|
movie.title = format!("Movie {}", i).into();
|
||||||
|
movie
|
||||||
|
}).collect();
|
||||||
|
|
||||||
|
table.set_items(movies.clone());
|
||||||
|
let original_count = table.items.len();
|
||||||
|
|
||||||
|
// Count should remain the same after various operations
|
||||||
|
prop_assert_eq!(table.items.len(), original_count);
|
||||||
|
|
||||||
|
// All original items should still be present
|
||||||
|
for movie in &movies {
|
||||||
|
prop_assert!(table.items.iter().any(|m| m.id == movie.id));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Property test: Page up/down maintains bounds
|
||||||
|
#[test]
|
||||||
|
fn test_page_navigation_bounds(
|
||||||
|
list_size in list_size(),
|
||||||
|
page_ops in 0usize..10
|
||||||
|
) {
|
||||||
|
let mut table = StatefulTable::<Movie>::default();
|
||||||
|
let movies: Vec<Movie> = (0..list_size).map(|i| {
|
||||||
|
let mut movie = Movie::default();
|
||||||
|
movie.id = i as i64;
|
||||||
|
movie
|
||||||
|
}).collect();
|
||||||
|
|
||||||
|
table.set_items(movies);
|
||||||
|
|
||||||
|
// Perform page operations
|
||||||
|
for i in 0..page_ops {
|
||||||
|
if i % 2 == 0 {
|
||||||
|
table.page_down();
|
||||||
|
} else {
|
||||||
|
table.page_up();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Should never exceed bounds
|
||||||
|
let current = table.current_selection();
|
||||||
|
prop_assert!(current.id >= 0);
|
||||||
|
prop_assert!(current.id < list_size as i64);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Property test: Table filtering reduces or maintains size
|
||||||
|
#[test]
|
||||||
|
fn test_table_filter_size_invariant(
|
||||||
|
list_size in list_size(),
|
||||||
|
filter_term in text_input_string()
|
||||||
|
) {
|
||||||
|
let mut table = StatefulTable::<Movie>::default();
|
||||||
|
let movies: Vec<Movie> = (0..list_size).map(|i| {
|
||||||
|
let mut movie = Movie::default();
|
||||||
|
movie.id = i as i64;
|
||||||
|
movie.title = format!("Test Movie {}", i % 10).into();
|
||||||
|
movie
|
||||||
|
}).collect();
|
||||||
|
|
||||||
|
table.set_items(movies.clone());
|
||||||
|
let original_size = table.items.len();
|
||||||
|
|
||||||
|
// Apply filter
|
||||||
|
if !filter_term.is_empty() {
|
||||||
|
let filtered: Vec<Movie> = movies.into_iter()
|
||||||
|
.filter(|m| m.title.text.to_lowercase().contains(&filter_term.to_lowercase()))
|
||||||
|
.collect();
|
||||||
|
table.set_items(filtered);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Filtered size should be <= original
|
||||||
|
prop_assert!(table.items.len() <= original_size);
|
||||||
|
|
||||||
|
// Selection should still be valid if table not empty
|
||||||
|
if !table.items.is_empty() {
|
||||||
|
let current = table.current_selection();
|
||||||
|
prop_assert!(current.id >= 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -452,4 +452,40 @@ mod test_utils {
|
|||||||
assert!(app.should_refresh);
|
assert!(app.should_refresh);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[macro_export]
|
||||||
|
macro_rules! assert_modal_present {
|
||||||
|
($modal:expr) => {
|
||||||
|
assert!($modal.is_some(), "Expected modal to be present");
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#[macro_export]
|
||||||
|
macro_rules! assert_modal_absent {
|
||||||
|
($modal:expr) => {
|
||||||
|
assert!($modal.is_none(), "Expected modal to be absent");
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#[macro_export]
|
||||||
|
macro_rules! assert_navigation_pushed {
|
||||||
|
($app:expr, $expected_route:expr) => {
|
||||||
|
pretty_assertions::assert_eq!(
|
||||||
|
$app.get_current_route(),
|
||||||
|
$expected_route,
|
||||||
|
"Expected route to be pushed onto navigation stack"
|
||||||
|
);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#[macro_export]
|
||||||
|
macro_rules! assert_navigation_popped {
|
||||||
|
($app:expr, $expected_route:expr) => {
|
||||||
|
pretty_assertions::assert_eq!(
|
||||||
|
$app.get_current_route(),
|
||||||
|
$expected_route,
|
||||||
|
"Expected route after popping navigation stack"
|
||||||
|
);
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,27 +1,30 @@
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
|
use crate::assert_modal_absent;
|
||||||
|
use crate::assert_navigation_pushed;
|
||||||
use crate::models::radarr_models::Movie;
|
use crate::models::radarr_models::Movie;
|
||||||
use crate::models::sonarr_models::Series;
|
use crate::models::sonarr_models::Series;
|
||||||
|
use crate::{assert_modal_present, assert_navigation_popped};
|
||||||
use pretty_assertions::assert_eq;
|
use pretty_assertions::assert_eq;
|
||||||
use rstest::rstest;
|
use rstest::rstest;
|
||||||
use tokio_util::sync::CancellationToken;
|
use tokio_util::sync::CancellationToken;
|
||||||
|
|
||||||
|
use crate::app::App;
|
||||||
use crate::app::context_clues::SERVARR_CONTEXT_CLUES;
|
use crate::app::context_clues::SERVARR_CONTEXT_CLUES;
|
||||||
use crate::app::key_binding::{KeyBinding, DEFAULT_KEYBINDINGS};
|
use crate::app::key_binding::{DEFAULT_KEYBINDINGS, KeyBinding};
|
||||||
use crate::app::radarr::radarr_context_clues::{
|
use crate::app::radarr::radarr_context_clues::{
|
||||||
LIBRARY_CONTEXT_CLUES, MOVIE_DETAILS_CONTEXT_CLUES,
|
LIBRARY_CONTEXT_CLUES, MOVIE_DETAILS_CONTEXT_CLUES,
|
||||||
};
|
};
|
||||||
use crate::app::App;
|
|
||||||
use crate::event::Key;
|
use crate::event::Key;
|
||||||
use crate::handlers::{handle_clear_errors, handle_prompt_toggle};
|
use crate::handlers::{handle_clear_errors, handle_prompt_toggle};
|
||||||
use crate::handlers::{handle_events, populate_keymapping_table};
|
use crate::handlers::{handle_events, populate_keymapping_table};
|
||||||
use crate::models::servarr_data::radarr::radarr_data::{ActiveRadarrBlock, RadarrData};
|
|
||||||
use crate::models::servarr_data::sonarr::sonarr_data::ActiveSonarrBlock;
|
|
||||||
use crate::models::servarr_data::ActiveKeybindingBlock;
|
|
||||||
use crate::models::servarr_models::KeybindingItem;
|
|
||||||
use crate::models::stateful_table::StatefulTable;
|
|
||||||
use crate::models::HorizontallyScrollableText;
|
use crate::models::HorizontallyScrollableText;
|
||||||
use crate::models::Route;
|
use crate::models::Route;
|
||||||
|
use crate::models::servarr_data::ActiveKeybindingBlock;
|
||||||
|
use crate::models::servarr_data::radarr::radarr_data::{ActiveRadarrBlock, RadarrData};
|
||||||
|
use crate::models::servarr_data::sonarr::sonarr_data::ActiveSonarrBlock;
|
||||||
|
use crate::models::servarr_models::KeybindingItem;
|
||||||
|
use crate::models::stateful_table::StatefulTable;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_handle_clear_errors() {
|
fn test_handle_clear_errors() {
|
||||||
@@ -30,7 +33,7 @@ mod tests {
|
|||||||
|
|
||||||
handle_clear_errors(&mut app);
|
handle_clear_errors(&mut app);
|
||||||
|
|
||||||
assert!(app.error.text.is_empty());
|
assert_is_empty!(app.error.text);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[rstest]
|
#[rstest]
|
||||||
@@ -53,7 +56,7 @@ mod tests {
|
|||||||
|
|
||||||
handle_events(DEFAULT_KEYBINDINGS.esc.key, &mut app);
|
handle_events(DEFAULT_KEYBINDINGS.esc.key, &mut app);
|
||||||
|
|
||||||
assert_eq!(app.get_current_route(), base_block);
|
assert_navigation_popped!(app, base_block);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[rstest]
|
#[rstest]
|
||||||
@@ -70,7 +73,7 @@ mod tests {
|
|||||||
handle_events(DEFAULT_KEYBINDINGS.previous_servarr.key, &mut app);
|
handle_events(DEFAULT_KEYBINDINGS.previous_servarr.key, &mut app);
|
||||||
|
|
||||||
assert_eq!(app.server_tabs.get_active_route(), left_block.into());
|
assert_eq!(app.server_tabs.get_active_route(), left_block.into());
|
||||||
assert_eq!(app.get_current_route(), left_block.into());
|
assert_navigation_pushed!(app, left_block.into());
|
||||||
assert!(app.is_first_render);
|
assert!(app.is_first_render);
|
||||||
assert_eq!(app.error, HorizontallyScrollableText::default());
|
assert_eq!(app.error, HorizontallyScrollableText::default());
|
||||||
assert!(app.cancellation_token.is_cancelled());
|
assert!(app.cancellation_token.is_cancelled());
|
||||||
@@ -83,7 +86,7 @@ mod tests {
|
|||||||
handle_events(DEFAULT_KEYBINDINGS.next_servarr.key, &mut app);
|
handle_events(DEFAULT_KEYBINDINGS.next_servarr.key, &mut app);
|
||||||
|
|
||||||
assert_eq!(app.server_tabs.get_active_route(), right_block.into());
|
assert_eq!(app.server_tabs.get_active_route(), right_block.into());
|
||||||
assert_eq!(app.get_current_route(), right_block.into());
|
assert_navigation_pushed!(app, right_block.into());
|
||||||
assert!(app.is_first_render);
|
assert!(app.is_first_render);
|
||||||
assert_eq!(app.error, HorizontallyScrollableText::default());
|
assert_eq!(app.error, HorizontallyScrollableText::default());
|
||||||
assert!(app.cancellation_token.is_cancelled());
|
assert!(app.cancellation_token.is_cancelled());
|
||||||
@@ -100,7 +103,7 @@ mod tests {
|
|||||||
|
|
||||||
handle_events(DEFAULT_KEYBINDINGS.help.key, &mut app);
|
handle_events(DEFAULT_KEYBINDINGS.help.key, &mut app);
|
||||||
|
|
||||||
assert!(app.keymapping_table.is_some());
|
assert_modal_present!(app.keymapping_table);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
expected_keybinding_items,
|
expected_keybinding_items,
|
||||||
app.keymapping_table.unwrap().items
|
app.keymapping_table.unwrap().items
|
||||||
@@ -115,12 +118,12 @@ mod tests {
|
|||||||
|
|
||||||
handle_events(DEFAULT_KEYBINDINGS.help.key, &mut app);
|
handle_events(DEFAULT_KEYBINDINGS.help.key, &mut app);
|
||||||
|
|
||||||
assert!(app.keymapping_table.is_none());
|
assert_modal_absent!(app.keymapping_table);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_handle_empties_keybindings_table_on_help_button_press_when_keybindings_table_is_already_populated(
|
fn test_handle_empties_keybindings_table_on_help_button_press_when_keybindings_table_is_already_populated()
|
||||||
) {
|
{
|
||||||
let mut app = App::test_default();
|
let mut app = App::test_default();
|
||||||
let keybinding_items = Vec::from(SERVARR_CONTEXT_CLUES)
|
let keybinding_items = Vec::from(SERVARR_CONTEXT_CLUES)
|
||||||
.iter()
|
.iter()
|
||||||
@@ -133,7 +136,7 @@ mod tests {
|
|||||||
|
|
||||||
handle_events(DEFAULT_KEYBINDINGS.help.key, &mut app);
|
handle_events(DEFAULT_KEYBINDINGS.help.key, &mut app);
|
||||||
|
|
||||||
assert!(app.keymapping_table.is_none());
|
assert_modal_absent!(app.keymapping_table);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -158,7 +161,7 @@ mod tests {
|
|||||||
|
|
||||||
handle_events(DEFAULT_KEYBINDINGS.down.key, &mut app);
|
handle_events(DEFAULT_KEYBINDINGS.down.key, &mut app);
|
||||||
|
|
||||||
assert!(app.keymapping_table.is_some());
|
assert_modal_present!(app.keymapping_table);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
&expected_selection,
|
&expected_selection,
|
||||||
app.keymapping_table.unwrap().current_selection()
|
app.keymapping_table.unwrap().current_selection()
|
||||||
@@ -219,7 +222,7 @@ mod tests {
|
|||||||
|
|
||||||
populate_keymapping_table(&mut app);
|
populate_keymapping_table(&mut app);
|
||||||
|
|
||||||
assert!(app.keymapping_table.is_some());
|
assert_modal_present!(app.keymapping_table);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
expected_keybinding_items,
|
expected_keybinding_items,
|
||||||
app.keymapping_table.unwrap().items
|
app.keymapping_table.unwrap().items
|
||||||
@@ -243,7 +246,7 @@ mod tests {
|
|||||||
|
|
||||||
populate_keymapping_table(&mut app);
|
populate_keymapping_table(&mut app);
|
||||||
|
|
||||||
assert!(app.keymapping_table.is_some());
|
assert_modal_present!(app.keymapping_table);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
expected_keybinding_items,
|
expected_keybinding_items,
|
||||||
app.keymapping_table.unwrap().items
|
app.keymapping_table.unwrap().items
|
||||||
@@ -251,8 +254,8 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_populate_keymapping_table_populates_delegated_servarr_context_provider_options_before_global_options(
|
fn test_populate_keymapping_table_populates_delegated_servarr_context_provider_options_before_global_options()
|
||||||
) {
|
{
|
||||||
let mut expected_keybinding_items = MOVIE_DETAILS_CONTEXT_CLUES
|
let mut expected_keybinding_items = MOVIE_DETAILS_CONTEXT_CLUES
|
||||||
.iter()
|
.iter()
|
||||||
.map(|(key, desc)| context_clue_to_keybinding_item(key, desc))
|
.map(|(key, desc)| context_clue_to_keybinding_item(key, desc))
|
||||||
@@ -268,7 +271,7 @@ mod tests {
|
|||||||
|
|
||||||
populate_keymapping_table(&mut app);
|
populate_keymapping_table(&mut app);
|
||||||
|
|
||||||
assert!(app.keymapping_table.is_some());
|
assert_modal_present!(app.keymapping_table);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
expected_keybinding_items,
|
expected_keybinding_items,
|
||||||
app.keymapping_table.unwrap().items
|
app.keymapping_table.unwrap().items
|
||||||
|
|||||||
@@ -1,10 +1,8 @@
|
|||||||
use crate::app::App;
|
use crate::app::App;
|
||||||
use crate::event::Key;
|
use crate::event::Key;
|
||||||
use crate::handle_table_events;
|
|
||||||
use crate::handlers::table_handler::TableHandlingConfig;
|
|
||||||
use crate::handlers::KeyEventHandler;
|
use crate::handlers::KeyEventHandler;
|
||||||
|
use crate::handlers::table_handler::{TableHandlingConfig, handle_table};
|
||||||
use crate::models::servarr_data::ActiveKeybindingBlock;
|
use crate::models::servarr_data::ActiveKeybindingBlock;
|
||||||
use crate::models::servarr_models::KeybindingItem;
|
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
#[path = "keybinding_handler_tests.rs"]
|
#[path = "keybinding_handler_tests.rs"]
|
||||||
@@ -15,20 +13,15 @@ pub(super) struct KeybindingHandler<'a, 'b> {
|
|||||||
app: &'a mut App<'b>,
|
app: &'a mut App<'b>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl KeybindingHandler<'_, '_> {
|
|
||||||
handle_table_events!(
|
|
||||||
self,
|
|
||||||
keybindings,
|
|
||||||
self.app.keymapping_table.as_mut().unwrap(),
|
|
||||||
KeybindingItem
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveKeybindingBlock> for KeybindingHandler<'a, 'b> {
|
impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveKeybindingBlock> for KeybindingHandler<'a, 'b> {
|
||||||
fn handle(&mut self) {
|
fn handle(&mut self) {
|
||||||
let keybinding_table_handling_config = TableHandlingConfig::new(self.app.get_current_route());
|
let keybinding_table_handling_config = TableHandlingConfig::new(self.app.get_current_route());
|
||||||
|
|
||||||
if !self.handle_keybindings_table_events(keybinding_table_handling_config) {
|
if !handle_table(
|
||||||
|
self,
|
||||||
|
|app| app.keymapping_table.as_mut().unwrap(),
|
||||||
|
keybinding_table_handling_config,
|
||||||
|
) {
|
||||||
self.handle_key_event();
|
self.handle_key_event();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -77,4 +70,12 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveKeybindingBlock> for KeybindingHandle
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn handle_char_key_event(&mut self) {}
|
fn handle_char_key_event(&mut self) {}
|
||||||
|
|
||||||
|
fn app_mut(&mut self) -> &mut App<'b> {
|
||||||
|
self.app
|
||||||
|
}
|
||||||
|
|
||||||
|
fn current_route(&self) -> crate::models::Route {
|
||||||
|
self.app.get_current_route()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use crate::app::key_binding::DEFAULT_KEYBINDINGS;
|
|
||||||
use crate::app::App;
|
use crate::app::App;
|
||||||
|
use crate::app::key_binding::DEFAULT_KEYBINDINGS;
|
||||||
use crate::event::Key;
|
use crate::event::Key;
|
||||||
use crate::handlers::KeyEventHandler;
|
use crate::handlers::KeyEventHandler;
|
||||||
use crate::handlers::KeybindingHandler;
|
use crate::handlers::KeybindingHandler;
|
||||||
@@ -11,6 +11,7 @@ mod tests {
|
|||||||
|
|
||||||
mod test_handle_esc {
|
mod test_handle_esc {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
use crate::assert_modal_absent;
|
||||||
use crate::models::servarr_data::radarr::radarr_data::ActiveRadarrBlock;
|
use crate::models::servarr_data::radarr::radarr_data::ActiveRadarrBlock;
|
||||||
use pretty_assertions::assert_eq;
|
use pretty_assertions::assert_eq;
|
||||||
|
|
||||||
@@ -25,7 +26,7 @@ mod tests {
|
|||||||
KeybindingHandler::new(ESC_KEY, &mut app, ActiveKeybindingBlock::Help, None).handle();
|
KeybindingHandler::new(ESC_KEY, &mut app, ActiveKeybindingBlock::Help, None).handle();
|
||||||
|
|
||||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Movies.into());
|
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Movies.into());
|
||||||
assert!(app.keymapping_table.is_none());
|
assert_modal_absent!(app.keymapping_table);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+5
-3
@@ -1,11 +1,11 @@
|
|||||||
use radarr_handlers::RadarrHandler;
|
use radarr_handlers::RadarrHandler;
|
||||||
use sonarr_handlers::SonarrHandler;
|
use sonarr_handlers::SonarrHandler;
|
||||||
|
|
||||||
|
use crate::app::App;
|
||||||
use crate::app::context_clues::{
|
use crate::app::context_clues::{
|
||||||
ContextClueProvider, ServarrContextClueProvider, SERVARR_CONTEXT_CLUES,
|
ContextClueProvider, SERVARR_CONTEXT_CLUES, ServarrContextClueProvider,
|
||||||
};
|
};
|
||||||
use crate::app::key_binding::KeyBinding;
|
use crate::app::key_binding::KeyBinding;
|
||||||
use crate::app::App;
|
|
||||||
use crate::event::Key;
|
use crate::event::Key;
|
||||||
use crate::handlers::keybinding_handler::KeybindingHandler;
|
use crate::handlers::keybinding_handler::KeybindingHandler;
|
||||||
use crate::matches_key;
|
use crate::matches_key;
|
||||||
@@ -93,6 +93,8 @@ pub trait KeyEventHandler<'a, 'b, T: Into<Route> + Copy> {
|
|||||||
fn handle_submit(&mut self);
|
fn handle_submit(&mut self);
|
||||||
fn handle_esc(&mut self);
|
fn handle_esc(&mut self);
|
||||||
fn handle_char_key_event(&mut self);
|
fn handle_char_key_event(&mut self);
|
||||||
|
fn app_mut(&mut self) -> &mut App<'b>;
|
||||||
|
fn current_route(&self) -> Route;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn handle_events(key: Key, app: &mut App<'_>) {
|
pub fn handle_events(key: Key, app: &mut App<'_>) {
|
||||||
@@ -128,7 +130,7 @@ pub fn handle_events(key: Key, app: &mut App<'_>) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn populate_keymapping_table(app: &mut App<'_>) {
|
pub fn populate_keymapping_table(app: &mut App<'_>) {
|
||||||
let context_clue_to_keybinding_item = |key: &KeyBinding, desc: &&str| {
|
let context_clue_to_keybinding_item = |key: &KeyBinding, desc: &&str| {
|
||||||
let (key, alt_key) = if key.alt.is_some() {
|
let (key, alt_key) = if key.alt.is_some() {
|
||||||
(key.key.to_string(), key.alt.as_ref().unwrap().to_string())
|
(key.key.to_string(), key.alt.as_ref().unwrap().to_string())
|
||||||
|
|||||||
@@ -7,11 +7,12 @@ mod tests {
|
|||||||
use rstest::rstest;
|
use rstest::rstest;
|
||||||
use strum::IntoEnumIterator;
|
use strum::IntoEnumIterator;
|
||||||
|
|
||||||
use crate::app::key_binding::DEFAULT_KEYBINDINGS;
|
|
||||||
use crate::app::App;
|
use crate::app::App;
|
||||||
|
use crate::app::key_binding::DEFAULT_KEYBINDINGS;
|
||||||
|
use crate::assert_navigation_pushed;
|
||||||
use crate::event::Key;
|
use crate::event::Key;
|
||||||
use crate::handlers::radarr_handlers::blocklist::{blocklist_sorting_options, BlocklistHandler};
|
|
||||||
use crate::handlers::KeyEventHandler;
|
use crate::handlers::KeyEventHandler;
|
||||||
|
use crate::handlers::radarr_handlers::blocklist::{BlocklistHandler, blocklist_sorting_options};
|
||||||
use crate::models::radarr_models::{BlocklistItem, BlocklistItemMovie};
|
use crate::models::radarr_models::{BlocklistItem, BlocklistItemMovie};
|
||||||
use crate::models::servarr_data::radarr::radarr_data::{ActiveRadarrBlock, BLOCKLIST_BLOCKS};
|
use crate::models::servarr_data::radarr::radarr_data::{ActiveRadarrBlock, BLOCKLIST_BLOCKS};
|
||||||
use crate::models::servarr_models::{Language, Quality, QualityWrapper};
|
use crate::models::servarr_models::{Language, Quality, QualityWrapper};
|
||||||
@@ -30,10 +31,7 @@ mod tests {
|
|||||||
|
|
||||||
BlocklistHandler::new(DELETE_KEY, &mut app, ActiveRadarrBlock::Blocklist, None).handle();
|
BlocklistHandler::new(DELETE_KEY, &mut app, ActiveRadarrBlock::Blocklist, None).handle();
|
||||||
|
|
||||||
assert_eq!(
|
assert_navigation_pushed!(app, ActiveRadarrBlock::DeleteBlocklistItemPrompt.into());
|
||||||
app.get_current_route(),
|
|
||||||
ActiveRadarrBlock::DeleteBlocklistItemPrompt.into()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -54,6 +52,7 @@ mod tests {
|
|||||||
use rstest::rstest;
|
use rstest::rstest;
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
use crate::assert_navigation_pushed;
|
||||||
|
|
||||||
#[rstest]
|
#[rstest]
|
||||||
fn test_blocklist_tab_left(#[values(true, false)] is_ready: bool) {
|
fn test_blocklist_tab_left(#[values(true, false)] is_ready: bool) {
|
||||||
@@ -73,7 +72,7 @@ mod tests {
|
|||||||
app.data.radarr_data.main_tabs.get_active_route(),
|
app.data.radarr_data.main_tabs.get_active_route(),
|
||||||
ActiveRadarrBlock::Downloads.into()
|
ActiveRadarrBlock::Downloads.into()
|
||||||
);
|
);
|
||||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Downloads.into());
|
assert_navigation_pushed!(app, ActiveRadarrBlock::Downloads.into());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[rstest]
|
#[rstest]
|
||||||
@@ -94,10 +93,7 @@ mod tests {
|
|||||||
app.data.radarr_data.main_tabs.get_active_route(),
|
app.data.radarr_data.main_tabs.get_active_route(),
|
||||||
ActiveRadarrBlock::RootFolders.into()
|
ActiveRadarrBlock::RootFolders.into()
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_navigation_pushed!(app, ActiveRadarrBlock::RootFolders.into());
|
||||||
app.get_current_route(),
|
|
||||||
ActiveRadarrBlock::RootFolders.into()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[rstest]
|
#[rstest]
|
||||||
@@ -122,11 +118,11 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
mod test_handle_submit {
|
mod test_handle_submit {
|
||||||
|
use crate::assert_navigation_popped;
|
||||||
|
use crate::network::radarr_network::RadarrEvent;
|
||||||
use pretty_assertions::assert_eq;
|
use pretty_assertions::assert_eq;
|
||||||
use rstest::rstest;
|
use rstest::rstest;
|
||||||
|
|
||||||
use crate::network::radarr_network::RadarrEvent;
|
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
const SUBMIT_KEY: Key = DEFAULT_KEYBINDINGS.submit.key;
|
const SUBMIT_KEY: Key = DEFAULT_KEYBINDINGS.submit.key;
|
||||||
@@ -139,10 +135,7 @@ mod tests {
|
|||||||
|
|
||||||
BlocklistHandler::new(SUBMIT_KEY, &mut app, ActiveRadarrBlock::Blocklist, None).handle();
|
BlocklistHandler::new(SUBMIT_KEY, &mut app, ActiveRadarrBlock::Blocklist, None).handle();
|
||||||
|
|
||||||
assert_eq!(
|
assert_navigation_pushed!(app, ActiveRadarrBlock::BlocklistItemDetails.into());
|
||||||
app.get_current_route(),
|
|
||||||
ActiveRadarrBlock::BlocklistItemDetails.into()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -186,7 +179,7 @@ mod tests {
|
|||||||
app.data.radarr_data.prompt_confirm_action,
|
app.data.radarr_data.prompt_confirm_action,
|
||||||
Some(expected_action)
|
Some(expected_action)
|
||||||
);
|
);
|
||||||
assert_eq!(app.get_current_route(), base_route.into());
|
assert_navigation_popped!(app, base_route.into());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[rstest]
|
#[rstest]
|
||||||
@@ -205,18 +198,18 @@ mod tests {
|
|||||||
BlocklistHandler::new(SUBMIT_KEY, &mut app, prompt_block, None).handle();
|
BlocklistHandler::new(SUBMIT_KEY, &mut app, prompt_block, None).handle();
|
||||||
|
|
||||||
assert!(!app.data.radarr_data.prompt_confirm);
|
assert!(!app.data.radarr_data.prompt_confirm);
|
||||||
assert_eq!(app.data.radarr_data.prompt_confirm_action, None);
|
assert_none!(app.data.radarr_data.prompt_confirm_action);
|
||||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Blocklist.into());
|
assert_navigation_popped!(app, ActiveRadarrBlock::Blocklist.into());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mod test_handle_esc {
|
mod test_handle_esc {
|
||||||
use pretty_assertions::assert_eq;
|
|
||||||
use rstest::rstest;
|
use rstest::rstest;
|
||||||
|
|
||||||
use crate::handlers::radarr_handlers::downloads::DownloadsHandler;
|
use crate::handlers::radarr_handlers::downloads::DownloadsHandler;
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
use crate::assert_navigation_popped;
|
||||||
|
|
||||||
const ESC_KEY: Key = DEFAULT_KEYBINDINGS.esc.key;
|
const ESC_KEY: Key = DEFAULT_KEYBINDINGS.esc.key;
|
||||||
|
|
||||||
@@ -240,7 +233,7 @@ mod tests {
|
|||||||
|
|
||||||
BlocklistHandler::new(ESC_KEY, &mut app, prompt_block, None).handle();
|
BlocklistHandler::new(ESC_KEY, &mut app, prompt_block, None).handle();
|
||||||
|
|
||||||
assert_eq!(app.get_current_route(), base_block.into());
|
assert_navigation_popped!(app, base_block.into());
|
||||||
assert!(!app.data.radarr_data.prompt_confirm);
|
assert!(!app.data.radarr_data.prompt_confirm);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -258,7 +251,7 @@ mod tests {
|
|||||||
)
|
)
|
||||||
.handle();
|
.handle();
|
||||||
|
|
||||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Blocklist.into());
|
assert_navigation_popped!(app, ActiveRadarrBlock::Blocklist.into());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[rstest]
|
#[rstest]
|
||||||
@@ -271,7 +264,7 @@ mod tests {
|
|||||||
|
|
||||||
DownloadsHandler::new(ESC_KEY, &mut app, ActiveRadarrBlock::Blocklist, None).handle();
|
DownloadsHandler::new(ESC_KEY, &mut app, ActiveRadarrBlock::Blocklist, None).handle();
|
||||||
|
|
||||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Blocklist.into());
|
assert_navigation_popped!(app, ActiveRadarrBlock::Blocklist.into());
|
||||||
assert!(app.error.text.is_empty());
|
assert!(app.error.text.is_empty());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -283,6 +276,7 @@ mod tests {
|
|||||||
use crate::network::radarr_network::RadarrEvent;
|
use crate::network::radarr_network::RadarrEvent;
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
use crate::{assert_navigation_popped, assert_navigation_pushed};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_refresh_blocklist_key() {
|
fn test_refresh_blocklist_key() {
|
||||||
@@ -298,7 +292,7 @@ mod tests {
|
|||||||
)
|
)
|
||||||
.handle();
|
.handle();
|
||||||
|
|
||||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Blocklist.into());
|
assert_navigation_pushed!(app, ActiveRadarrBlock::Blocklist.into());
|
||||||
assert!(app.should_refresh);
|
assert!(app.should_refresh);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -334,10 +328,7 @@ mod tests {
|
|||||||
)
|
)
|
||||||
.handle();
|
.handle();
|
||||||
|
|
||||||
assert_eq!(
|
assert_navigation_pushed!(app, ActiveRadarrBlock::BlocklistClearAllItemsPrompt.into());
|
||||||
app.get_current_route(),
|
|
||||||
ActiveRadarrBlock::BlocklistClearAllItemsPrompt.into()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -392,7 +383,7 @@ mod tests {
|
|||||||
app.data.radarr_data.prompt_confirm_action,
|
app.data.radarr_data.prompt_confirm_action,
|
||||||
Some(expected_action)
|
Some(expected_action)
|
||||||
);
|
);
|
||||||
assert_eq!(app.get_current_route(), base_route.into());
|
assert_navigation_popped!(app, base_route.into());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
use crate::app::App;
|
use crate::app::App;
|
||||||
use crate::event::Key;
|
use crate::event::Key;
|
||||||
use crate::handlers::radarr_handlers::handle_change_tab_left_right_keys;
|
use crate::handlers::radarr_handlers::handle_change_tab_left_right_keys;
|
||||||
use crate::handlers::table_handler::TableHandlingConfig;
|
use crate::handlers::table_handler::{TableHandlingConfig, handle_table};
|
||||||
use crate::handlers::{handle_clear_errors, handle_prompt_toggle, KeyEventHandler};
|
use crate::handlers::{KeyEventHandler, handle_clear_errors, handle_prompt_toggle};
|
||||||
|
use crate::matches_key;
|
||||||
use crate::models::radarr_models::BlocklistItem;
|
use crate::models::radarr_models::BlocklistItem;
|
||||||
use crate::models::servarr_data::radarr::radarr_data::{ActiveRadarrBlock, BLOCKLIST_BLOCKS};
|
use crate::models::servarr_data::radarr::radarr_data::{ActiveRadarrBlock, BLOCKLIST_BLOCKS};
|
||||||
use crate::models::stateful_table::SortOption;
|
use crate::models::stateful_table::SortOption;
|
||||||
use crate::network::radarr_network::RadarrEvent;
|
use crate::network::radarr_network::RadarrEvent;
|
||||||
use crate::{handle_table_events, matches_key};
|
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
#[path = "blocklist_handler_tests.rs"]
|
#[path = "blocklist_handler_tests.rs"]
|
||||||
@@ -21,13 +21,6 @@ pub(super) struct BlocklistHandler<'a, 'b> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl BlocklistHandler<'_, '_> {
|
impl BlocklistHandler<'_, '_> {
|
||||||
handle_table_events!(
|
|
||||||
self,
|
|
||||||
blocklist,
|
|
||||||
self.app.data.radarr_data.blocklist,
|
|
||||||
BlocklistItem
|
|
||||||
);
|
|
||||||
|
|
||||||
fn extract_blocklist_item_id(&self) -> i64 {
|
fn extract_blocklist_item_id(&self) -> i64 {
|
||||||
self.app.data.radarr_data.blocklist.current_selection().id
|
self.app.data.radarr_data.blocklist.current_selection().id
|
||||||
}
|
}
|
||||||
@@ -38,10 +31,13 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for BlocklistHandler<'a,
|
|||||||
let blocklist_table_handling_config =
|
let blocklist_table_handling_config =
|
||||||
TableHandlingConfig::new(ActiveRadarrBlock::Blocklist.into())
|
TableHandlingConfig::new(ActiveRadarrBlock::Blocklist.into())
|
||||||
.sorting_block(ActiveRadarrBlock::BlocklistSortPrompt.into())
|
.sorting_block(ActiveRadarrBlock::BlocklistSortPrompt.into())
|
||||||
.sort_by_fn(|a: &BlocklistItem, b: &BlocklistItem| a.id.cmp(&b.id))
|
|
||||||
.sort_options(blocklist_sorting_options());
|
.sort_options(blocklist_sorting_options());
|
||||||
|
|
||||||
if !self.handle_blocklist_table_events(blocklist_table_handling_config) {
|
if !handle_table(
|
||||||
|
self,
|
||||||
|
|app| &mut app.data.radarr_data.blocklist,
|
||||||
|
blocklist_table_handling_config,
|
||||||
|
) {
|
||||||
self.handle_key_event();
|
self.handle_key_event();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -177,6 +173,14 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for BlocklistHandler<'a,
|
|||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn app_mut(&mut self) -> &mut App<'b> {
|
||||||
|
self.app
|
||||||
|
}
|
||||||
|
|
||||||
|
fn current_route(&self) -> crate::models::Route {
|
||||||
|
self.app.get_current_route()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn blocklist_sorting_options() -> Vec<SortOption<BlocklistItem>> {
|
fn blocklist_sorting_options() -> Vec<SortOption<BlocklistItem>> {
|
||||||
|
|||||||
@@ -1,15 +1,14 @@
|
|||||||
use crate::app::App;
|
use crate::app::App;
|
||||||
use crate::event::Key;
|
use crate::event::Key;
|
||||||
use crate::handlers::table_handler::TableHandlingConfig;
|
|
||||||
use crate::handlers::KeyEventHandler;
|
use crate::handlers::KeyEventHandler;
|
||||||
use crate::models::radarr_models::CollectionMovie;
|
use crate::handlers::table_handler::{TableHandlingConfig, handle_table};
|
||||||
|
use crate::matches_key;
|
||||||
|
use crate::models::BlockSelectionState;
|
||||||
use crate::models::servarr_data::radarr::radarr_data::{
|
use crate::models::servarr_data::radarr::radarr_data::{
|
||||||
ActiveRadarrBlock, ADD_MOVIE_SELECTION_BLOCKS, COLLECTION_DETAILS_BLOCKS,
|
ADD_MOVIE_SELECTION_BLOCKS, ActiveRadarrBlock, COLLECTION_DETAILS_BLOCKS,
|
||||||
EDIT_COLLECTION_SELECTION_BLOCKS,
|
EDIT_COLLECTION_SELECTION_BLOCKS,
|
||||||
};
|
};
|
||||||
use crate::models::stateful_table::StatefulTable;
|
use crate::models::stateful_table::StatefulTable;
|
||||||
use crate::models::BlockSelectionState;
|
|
||||||
use crate::{handle_table_events, matches_key};
|
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
#[path = "collection_details_handler_tests.rs"]
|
#[path = "collection_details_handler_tests.rs"]
|
||||||
@@ -22,21 +21,18 @@ pub(super) struct CollectionDetailsHandler<'a, 'b> {
|
|||||||
_context: Option<ActiveRadarrBlock>,
|
_context: Option<ActiveRadarrBlock>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CollectionDetailsHandler<'_, '_> {
|
impl CollectionDetailsHandler<'_, '_> {}
|
||||||
handle_table_events!(
|
|
||||||
self,
|
|
||||||
collection_movies,
|
|
||||||
self.app.data.radarr_data.collection_movies,
|
|
||||||
CollectionMovie
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for CollectionDetailsHandler<'a, 'b> {
|
impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for CollectionDetailsHandler<'a, 'b> {
|
||||||
fn handle(&mut self) {
|
fn handle(&mut self) {
|
||||||
let collection_movies_table_handling_config =
|
let collection_movies_table_handling_config =
|
||||||
TableHandlingConfig::new(ActiveRadarrBlock::CollectionDetails.into());
|
TableHandlingConfig::new(ActiveRadarrBlock::CollectionDetails.into());
|
||||||
|
|
||||||
if !self.handle_collection_movies_table_events(collection_movies_table_handling_config) {
|
if !handle_table(
|
||||||
|
self,
|
||||||
|
|app| &mut app.data.radarr_data.collection_movies,
|
||||||
|
collection_movies_table_handling_config,
|
||||||
|
) {
|
||||||
self.handle_key_event();
|
self.handle_key_event();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -147,4 +143,12 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for CollectionDetailsHan
|
|||||||
BlockSelectionState::new(EDIT_COLLECTION_SELECTION_BLOCKS);
|
BlockSelectionState::new(EDIT_COLLECTION_SELECTION_BLOCKS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn app_mut(&mut self) -> &mut App<'b> {
|
||||||
|
self.app
|
||||||
|
}
|
||||||
|
|
||||||
|
fn current_route(&self) -> crate::models::Route {
|
||||||
|
self.app.get_current_route()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,23 +4,24 @@ mod tests {
|
|||||||
use rstest::rstest;
|
use rstest::rstest;
|
||||||
use strum::IntoEnumIterator;
|
use strum::IntoEnumIterator;
|
||||||
|
|
||||||
use crate::app::key_binding::DEFAULT_KEYBINDINGS;
|
|
||||||
use crate::app::App;
|
use crate::app::App;
|
||||||
|
use crate::app::key_binding::DEFAULT_KEYBINDINGS;
|
||||||
|
use crate::assert_modal_absent;
|
||||||
use crate::event::Key;
|
use crate::event::Key;
|
||||||
use crate::handlers::radarr_handlers::collections::collection_details_handler::CollectionDetailsHandler;
|
|
||||||
use crate::handlers::KeyEventHandler;
|
use crate::handlers::KeyEventHandler;
|
||||||
|
use crate::handlers::radarr_handlers::collections::collection_details_handler::CollectionDetailsHandler;
|
||||||
use crate::models::radarr_models::CollectionMovie;
|
use crate::models::radarr_models::CollectionMovie;
|
||||||
use crate::models::servarr_data::radarr::radarr_data::{
|
use crate::models::servarr_data::radarr::radarr_data::{
|
||||||
ActiveRadarrBlock, COLLECTION_DETAILS_BLOCKS,
|
ActiveRadarrBlock, COLLECTION_DETAILS_BLOCKS,
|
||||||
};
|
};
|
||||||
|
|
||||||
mod test_handle_submit {
|
mod test_handle_submit {
|
||||||
use bimap::BiMap;
|
use crate::assert_navigation_pushed;
|
||||||
use pretty_assertions::assert_eq;
|
use crate::models::BlockSelectionState;
|
||||||
|
|
||||||
use crate::models::radarr_models::Movie;
|
use crate::models::radarr_models::Movie;
|
||||||
use crate::models::servarr_data::radarr::radarr_data::ADD_MOVIE_SELECTION_BLOCKS;
|
use crate::models::servarr_data::radarr::radarr_data::ADD_MOVIE_SELECTION_BLOCKS;
|
||||||
use crate::models::BlockSelectionState;
|
use bimap::BiMap;
|
||||||
|
use pretty_assertions::assert_eq;
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
@@ -51,45 +52,51 @@ mod tests {
|
|||||||
)
|
)
|
||||||
.handle();
|
.handle();
|
||||||
|
|
||||||
assert_eq!(
|
assert_navigation_pushed!(
|
||||||
app.get_current_route(),
|
app,
|
||||||
(
|
(
|
||||||
ActiveRadarrBlock::AddMoviePrompt,
|
ActiveRadarrBlock::AddMoviePrompt,
|
||||||
Some(ActiveRadarrBlock::CollectionDetails)
|
Some(ActiveRadarrBlock::CollectionDetails)
|
||||||
)
|
)
|
||||||
.into()
|
.into()
|
||||||
);
|
);
|
||||||
assert!(!app
|
assert!(
|
||||||
.data
|
!app
|
||||||
.radarr_data
|
.data
|
||||||
.add_movie_modal
|
.radarr_data
|
||||||
.as_ref()
|
.add_movie_modal
|
||||||
.unwrap()
|
.as_ref()
|
||||||
.monitor_list
|
.unwrap()
|
||||||
.items
|
.monitor_list
|
||||||
.is_empty());
|
.items
|
||||||
|
.is_empty()
|
||||||
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
app.data.radarr_data.selected_block.get_active_block(),
|
app.data.radarr_data.selected_block.get_active_block(),
|
||||||
ActiveRadarrBlock::AddMovieSelectRootFolder
|
ActiveRadarrBlock::AddMovieSelectRootFolder
|
||||||
);
|
);
|
||||||
assert!(!app
|
assert!(
|
||||||
.data
|
!app
|
||||||
.radarr_data
|
.data
|
||||||
.add_movie_modal
|
.radarr_data
|
||||||
.as_ref()
|
.add_movie_modal
|
||||||
.unwrap()
|
.as_ref()
|
||||||
.minimum_availability_list
|
.unwrap()
|
||||||
.items
|
.minimum_availability_list
|
||||||
.is_empty());
|
.items
|
||||||
assert!(!app
|
.is_empty()
|
||||||
.data
|
);
|
||||||
.radarr_data
|
assert!(
|
||||||
.add_movie_modal
|
!app
|
||||||
.as_ref()
|
.data
|
||||||
.unwrap()
|
.radarr_data
|
||||||
.quality_profile_list
|
.add_movie_modal
|
||||||
.items
|
.as_ref()
|
||||||
.is_empty());
|
.unwrap()
|
||||||
|
.quality_profile_list
|
||||||
|
.items
|
||||||
|
.is_empty()
|
||||||
|
);
|
||||||
assert_str_eq!(
|
assert_str_eq!(
|
||||||
app
|
app
|
||||||
.data
|
.data
|
||||||
@@ -126,7 +133,7 @@ mod tests {
|
|||||||
app.get_current_route(),
|
app.get_current_route(),
|
||||||
ActiveRadarrBlock::CollectionDetails.into()
|
ActiveRadarrBlock::CollectionDetails.into()
|
||||||
);
|
);
|
||||||
assert!(app.data.radarr_data.add_movie_modal.is_none());
|
assert_modal_absent!(app.data.radarr_data.add_movie_modal);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -151,16 +158,13 @@ mod tests {
|
|||||||
)
|
)
|
||||||
.handle();
|
.handle();
|
||||||
|
|
||||||
assert_eq!(
|
assert_navigation_pushed!(app, ActiveRadarrBlock::ViewMovieOverview.into());
|
||||||
app.get_current_route(),
|
|
||||||
ActiveRadarrBlock::ViewMovieOverview.into()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mod test_handle_esc {
|
mod test_handle_esc {
|
||||||
use super::*;
|
use super::*;
|
||||||
use pretty_assertions::assert_eq;
|
use crate::assert_navigation_popped;
|
||||||
use rstest::rstest;
|
use rstest::rstest;
|
||||||
|
|
||||||
const ESC_KEY: Key = DEFAULT_KEYBINDINGS.esc.key;
|
const ESC_KEY: Key = DEFAULT_KEYBINDINGS.esc.key;
|
||||||
@@ -185,11 +189,8 @@ mod tests {
|
|||||||
)
|
)
|
||||||
.handle();
|
.handle();
|
||||||
|
|
||||||
assert_eq!(
|
assert_navigation_popped!(app, ActiveRadarrBlock::Collections.into());
|
||||||
app.get_current_route(),
|
assert_is_empty!(app.data.radarr_data.collection_movies.items);
|
||||||
ActiveRadarrBlock::Collections.into()
|
|
||||||
);
|
|
||||||
assert!(app.data.radarr_data.collection_movies.items.is_empty());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -206,10 +207,7 @@ mod tests {
|
|||||||
)
|
)
|
||||||
.handle();
|
.handle();
|
||||||
|
|
||||||
assert_eq!(
|
assert_navigation_popped!(app, ActiveRadarrBlock::CollectionDetails.into());
|
||||||
app.get_current_route(),
|
|
||||||
ActiveRadarrBlock::CollectionDetails.into()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -221,7 +219,7 @@ mod tests {
|
|||||||
use crate::models::radarr_models::{Collection, MinimumAvailability};
|
use crate::models::radarr_models::{Collection, MinimumAvailability};
|
||||||
use crate::models::servarr_data::radarr::radarr_data::radarr_test_utils::utils::create_test_radarr_data;
|
use crate::models::servarr_data::radarr::radarr_data::radarr_test_utils::utils::create_test_radarr_data;
|
||||||
use crate::models::servarr_data::radarr::radarr_data::{
|
use crate::models::servarr_data::radarr::radarr_data::{
|
||||||
RadarrData, EDIT_COLLECTION_SELECTION_BLOCKS,
|
EDIT_COLLECTION_SELECTION_BLOCKS, RadarrData,
|
||||||
};
|
};
|
||||||
use crate::test_edit_collection_key;
|
use crate::test_edit_collection_key;
|
||||||
|
|
||||||
@@ -264,7 +262,7 @@ mod tests {
|
|||||||
app.get_current_route(),
|
app.get_current_route(),
|
||||||
ActiveRadarrBlock::CollectionDetails.into()
|
ActiveRadarrBlock::CollectionDetails.into()
|
||||||
);
|
);
|
||||||
assert!(app.data.radarr_data.edit_collection_modal.is_none());
|
assert_modal_absent!(app.data.radarr_data.edit_collection_modal);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,16 +7,18 @@ mod tests {
|
|||||||
use rstest::rstest;
|
use rstest::rstest;
|
||||||
use strum::IntoEnumIterator;
|
use strum::IntoEnumIterator;
|
||||||
|
|
||||||
use crate::app::key_binding::DEFAULT_KEYBINDINGS;
|
|
||||||
use crate::app::App;
|
use crate::app::App;
|
||||||
|
use crate::app::key_binding::DEFAULT_KEYBINDINGS;
|
||||||
|
use crate::assert_modal_absent;
|
||||||
|
use crate::assert_navigation_pushed;
|
||||||
use crate::event::Key;
|
use crate::event::Key;
|
||||||
use crate::handlers::radarr_handlers::collections::{
|
|
||||||
collections_sorting_options, CollectionsHandler,
|
|
||||||
};
|
|
||||||
use crate::handlers::KeyEventHandler;
|
use crate::handlers::KeyEventHandler;
|
||||||
|
use crate::handlers::radarr_handlers::collections::{
|
||||||
|
CollectionsHandler, collections_sorting_options,
|
||||||
|
};
|
||||||
use crate::models::radarr_models::{Collection, CollectionMovie};
|
use crate::models::radarr_models::{Collection, CollectionMovie};
|
||||||
use crate::models::servarr_data::radarr::radarr_data::{
|
use crate::models::servarr_data::radarr::radarr_data::{
|
||||||
ActiveRadarrBlock, COLLECTIONS_BLOCKS, COLLECTION_DETAILS_BLOCKS, EDIT_COLLECTION_BLOCKS,
|
ActiveRadarrBlock, COLLECTION_DETAILS_BLOCKS, COLLECTIONS_BLOCKS, EDIT_COLLECTION_BLOCKS,
|
||||||
};
|
};
|
||||||
use crate::test_handler_delegation;
|
use crate::test_handler_delegation;
|
||||||
|
|
||||||
@@ -25,6 +27,7 @@ mod tests {
|
|||||||
use rstest::rstest;
|
use rstest::rstest;
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
use crate::assert_navigation_pushed;
|
||||||
|
|
||||||
#[rstest]
|
#[rstest]
|
||||||
fn test_collections_tab_left(#[values(true, false)] is_ready: bool) {
|
fn test_collections_tab_left(#[values(true, false)] is_ready: bool) {
|
||||||
@@ -44,7 +47,7 @@ mod tests {
|
|||||||
app.data.radarr_data.main_tabs.get_active_route(),
|
app.data.radarr_data.main_tabs.get_active_route(),
|
||||||
ActiveRadarrBlock::Movies.into()
|
ActiveRadarrBlock::Movies.into()
|
||||||
);
|
);
|
||||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Movies.into());
|
assert_navigation_pushed!(app, ActiveRadarrBlock::Movies.into());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[rstest]
|
#[rstest]
|
||||||
@@ -65,7 +68,7 @@ mod tests {
|
|||||||
app.data.radarr_data.main_tabs.get_active_route(),
|
app.data.radarr_data.main_tabs.get_active_route(),
|
||||||
ActiveRadarrBlock::Downloads.into()
|
ActiveRadarrBlock::Downloads.into()
|
||||||
);
|
);
|
||||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Downloads.into());
|
assert_navigation_pushed!(app, ActiveRadarrBlock::Downloads.into());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[rstest]
|
#[rstest]
|
||||||
@@ -97,9 +100,9 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
mod test_handle_submit {
|
mod test_handle_submit {
|
||||||
use pretty_assertions::assert_eq;
|
use crate::assert_navigation_popped;
|
||||||
|
|
||||||
use crate::network::radarr_network::RadarrEvent;
|
use crate::network::radarr_network::RadarrEvent;
|
||||||
|
use pretty_assertions::assert_eq;
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
@@ -116,10 +119,7 @@ mod tests {
|
|||||||
|
|
||||||
CollectionsHandler::new(SUBMIT_KEY, &mut app, ActiveRadarrBlock::Collections, None).handle();
|
CollectionsHandler::new(SUBMIT_KEY, &mut app, ActiveRadarrBlock::Collections, None).handle();
|
||||||
|
|
||||||
assert_eq!(
|
assert_navigation_pushed!(app, ActiveRadarrBlock::CollectionDetails.into());
|
||||||
app.get_current_route(),
|
|
||||||
ActiveRadarrBlock::CollectionDetails.into()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -166,10 +166,7 @@ mod tests {
|
|||||||
app.data.radarr_data.prompt_confirm_action,
|
app.data.radarr_data.prompt_confirm_action,
|
||||||
Some(RadarrEvent::UpdateCollections)
|
Some(RadarrEvent::UpdateCollections)
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_navigation_popped!(app, ActiveRadarrBlock::Collections.into());
|
||||||
app.get_current_route(),
|
|
||||||
ActiveRadarrBlock::Collections.into()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -192,17 +189,13 @@ mod tests {
|
|||||||
.handle();
|
.handle();
|
||||||
|
|
||||||
assert!(!app.data.radarr_data.prompt_confirm);
|
assert!(!app.data.radarr_data.prompt_confirm);
|
||||||
assert_eq!(app.data.radarr_data.prompt_confirm_action, None);
|
assert_none!(app.data.radarr_data.prompt_confirm_action);
|
||||||
assert_eq!(
|
assert_navigation_popped!(app, ActiveRadarrBlock::Collections.into());
|
||||||
app.get_current_route(),
|
|
||||||
ActiveRadarrBlock::Collections.into()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mod test_handle_esc {
|
mod test_handle_esc {
|
||||||
use pretty_assertions::assert_eq;
|
use crate::assert_navigation_popped;
|
||||||
|
|
||||||
use crate::models::servarr_data::radarr::radarr_data::radarr_test_utils::utils::create_test_radarr_data;
|
use crate::models::servarr_data::radarr::radarr_data::radarr_test_utils::utils::create_test_radarr_data;
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
@@ -224,10 +217,7 @@ mod tests {
|
|||||||
)
|
)
|
||||||
.handle();
|
.handle();
|
||||||
|
|
||||||
assert_eq!(
|
assert_navigation_popped!(app, ActiveRadarrBlock::Collections.into());
|
||||||
app.get_current_route(),
|
|
||||||
ActiveRadarrBlock::Collections.into()
|
|
||||||
);
|
|
||||||
assert!(!app.data.radarr_data.prompt_confirm);
|
assert!(!app.data.radarr_data.prompt_confirm);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -242,11 +232,8 @@ mod tests {
|
|||||||
|
|
||||||
CollectionsHandler::new(ESC_KEY, &mut app, ActiveRadarrBlock::Collections, None).handle();
|
CollectionsHandler::new(ESC_KEY, &mut app, ActiveRadarrBlock::Collections, None).handle();
|
||||||
|
|
||||||
assert_eq!(
|
assert_navigation_popped!(app, ActiveRadarrBlock::Collections.into());
|
||||||
app.get_current_route(),
|
assert_is_empty!(app.error.text);
|
||||||
ActiveRadarrBlock::Collections.into()
|
|
||||||
);
|
|
||||||
assert!(app.error.text.is_empty());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -258,10 +245,10 @@ mod tests {
|
|||||||
use crate::models::radarr_models::MinimumAvailability;
|
use crate::models::radarr_models::MinimumAvailability;
|
||||||
use crate::models::servarr_data::radarr::radarr_data::radarr_test_utils::utils::create_test_radarr_data;
|
use crate::models::servarr_data::radarr::radarr_data::radarr_test_utils::utils::create_test_radarr_data;
|
||||||
use crate::models::servarr_data::radarr::radarr_data::{
|
use crate::models::servarr_data::radarr::radarr_data::{
|
||||||
RadarrData, EDIT_COLLECTION_SELECTION_BLOCKS,
|
EDIT_COLLECTION_SELECTION_BLOCKS, RadarrData,
|
||||||
};
|
};
|
||||||
use crate::network::radarr_network::RadarrEvent;
|
use crate::network::radarr_network::RadarrEvent;
|
||||||
use crate::test_edit_collection_key;
|
use crate::{assert_navigation_popped, test_edit_collection_key};
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
@@ -298,7 +285,7 @@ mod tests {
|
|||||||
app.get_current_route(),
|
app.get_current_route(),
|
||||||
ActiveRadarrBlock::Collections.into()
|
ActiveRadarrBlock::Collections.into()
|
||||||
);
|
);
|
||||||
assert!(app.data.radarr_data.edit_collection_modal.is_none());
|
assert_modal_absent!(app.data.radarr_data.edit_collection_modal);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -318,10 +305,7 @@ mod tests {
|
|||||||
)
|
)
|
||||||
.handle();
|
.handle();
|
||||||
|
|
||||||
assert_eq!(
|
assert_navigation_pushed!(app, ActiveRadarrBlock::UpdateAllCollectionsPrompt.into());
|
||||||
app.get_current_route(),
|
|
||||||
ActiveRadarrBlock::UpdateAllCollectionsPrompt.into()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -367,10 +351,7 @@ mod tests {
|
|||||||
)
|
)
|
||||||
.handle();
|
.handle();
|
||||||
|
|
||||||
assert_eq!(
|
assert_navigation_pushed!(app, ActiveRadarrBlock::Collections.into());
|
||||||
app.get_current_route(),
|
|
||||||
ActiveRadarrBlock::Collections.into()
|
|
||||||
);
|
|
||||||
assert!(app.should_refresh);
|
assert!(app.should_refresh);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -424,10 +405,7 @@ mod tests {
|
|||||||
app.data.radarr_data.prompt_confirm_action,
|
app.data.radarr_data.prompt_confirm_action,
|
||||||
Some(RadarrEvent::UpdateCollections)
|
Some(RadarrEvent::UpdateCollections)
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_navigation_popped!(app, ActiveRadarrBlock::Collections.into());
|
||||||
app.get_current_route(),
|
|
||||||
ActiveRadarrBlock::Collections.into()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
use crate::app::App;
|
use crate::app::App;
|
||||||
use crate::event::Key;
|
use crate::event::Key;
|
||||||
use crate::handlers::{handle_prompt_toggle, KeyEventHandler};
|
use crate::handlers::{KeyEventHandler, handle_prompt_toggle};
|
||||||
|
use crate::models::Scrollable;
|
||||||
use crate::models::radarr_models::EditCollectionParams;
|
use crate::models::radarr_models::EditCollectionParams;
|
||||||
use crate::models::servarr_data::radarr::modals::EditCollectionModal;
|
use crate::models::servarr_data::radarr::modals::EditCollectionModal;
|
||||||
use crate::models::servarr_data::radarr::radarr_data::{ActiveRadarrBlock, EDIT_COLLECTION_BLOCKS};
|
use crate::models::servarr_data::radarr::radarr_data::{ActiveRadarrBlock, EDIT_COLLECTION_BLOCKS};
|
||||||
use crate::models::Scrollable;
|
|
||||||
use crate::network::radarr_network::RadarrEvent;
|
use crate::network::radarr_network::RadarrEvent;
|
||||||
use crate::{handle_text_box_keys, handle_text_box_left_right_keys, matches_key};
|
use crate::{handle_text_box_keys, handle_text_box_left_right_keys, matches_key};
|
||||||
|
|
||||||
@@ -371,4 +371,12 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for EditCollectionHandle
|
|||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn app_mut(&mut self) -> &mut App<'b> {
|
||||||
|
self.app
|
||||||
|
}
|
||||||
|
|
||||||
|
fn current_route(&self) -> crate::models::Route {
|
||||||
|
self.app.get_current_route()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,12 +5,14 @@ mod tests {
|
|||||||
use rstest::rstest;
|
use rstest::rstest;
|
||||||
use strum::IntoEnumIterator;
|
use strum::IntoEnumIterator;
|
||||||
|
|
||||||
use crate::app::key_binding::DEFAULT_KEYBINDINGS;
|
|
||||||
use crate::app::App;
|
use crate::app::App;
|
||||||
|
use crate::app::key_binding::DEFAULT_KEYBINDINGS;
|
||||||
|
use crate::assert_modal_absent;
|
||||||
|
use crate::assert_navigation_pushed;
|
||||||
use crate::event::Key;
|
use crate::event::Key;
|
||||||
|
use crate::handlers::KeyEventHandler;
|
||||||
use crate::handlers::radarr_handlers::collections::edit_collection_handler::EditCollectionHandler;
|
use crate::handlers::radarr_handlers::collections::edit_collection_handler::EditCollectionHandler;
|
||||||
use crate::handlers::radarr_handlers::radarr_handler_test_utils::utils::collection;
|
use crate::handlers::radarr_handlers::radarr_handler_test_utils::utils::collection;
|
||||||
use crate::handlers::KeyEventHandler;
|
|
||||||
use crate::models::radarr_models::{Collection, EditCollectionParams, MinimumAvailability};
|
use crate::models::radarr_models::{Collection, EditCollectionParams, MinimumAvailability};
|
||||||
use crate::models::servarr_data::radarr::modals::EditCollectionModal;
|
use crate::models::servarr_data::radarr::modals::EditCollectionModal;
|
||||||
use crate::models::servarr_data::radarr::radarr_data::{
|
use crate::models::servarr_data::radarr::radarr_data::{
|
||||||
@@ -22,9 +24,9 @@ mod tests {
|
|||||||
use rstest::rstest;
|
use rstest::rstest;
|
||||||
use strum::IntoEnumIterator;
|
use strum::IntoEnumIterator;
|
||||||
|
|
||||||
|
use crate::models::BlockSelectionState;
|
||||||
use crate::models::servarr_data::radarr::modals::EditCollectionModal;
|
use crate::models::servarr_data::radarr::modals::EditCollectionModal;
|
||||||
use crate::models::servarr_data::radarr::radarr_data::EDIT_COLLECTION_SELECTION_BLOCKS;
|
use crate::models::servarr_data::radarr::radarr_data::EDIT_COLLECTION_SELECTION_BLOCKS;
|
||||||
use crate::models::BlockSelectionState;
|
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
@@ -443,13 +445,13 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
mod test_handle_submit {
|
mod test_handle_submit {
|
||||||
use pretty_assertions::assert_eq;
|
use crate::assert_navigation_popped;
|
||||||
use rstest::rstest;
|
|
||||||
|
|
||||||
use crate::models::servarr_data::radarr::modals::EditCollectionModal;
|
use crate::models::servarr_data::radarr::modals::EditCollectionModal;
|
||||||
use crate::models::servarr_data::radarr::radarr_data::EDIT_COLLECTION_SELECTION_BLOCKS;
|
use crate::models::servarr_data::radarr::radarr_data::EDIT_COLLECTION_SELECTION_BLOCKS;
|
||||||
use crate::models::{BlockSelectionState, Route};
|
use crate::models::{BlockSelectionState, Route};
|
||||||
use crate::network::radarr_network::RadarrEvent;
|
use crate::network::radarr_network::RadarrEvent;
|
||||||
|
use pretty_assertions::assert_eq;
|
||||||
|
use rstest::rstest;
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
@@ -475,19 +477,18 @@ mod tests {
|
|||||||
.handle();
|
.handle();
|
||||||
|
|
||||||
assert!(!app.ignore_special_keys_for_textbox_input);
|
assert!(!app.ignore_special_keys_for_textbox_input);
|
||||||
assert!(!app
|
assert!(
|
||||||
.data
|
!app
|
||||||
.radarr_data
|
.data
|
||||||
.edit_collection_modal
|
.radarr_data
|
||||||
.as_ref()
|
.edit_collection_modal
|
||||||
.unwrap()
|
.as_ref()
|
||||||
.path
|
.unwrap()
|
||||||
.text
|
.path
|
||||||
.is_empty());
|
.text
|
||||||
assert_eq!(
|
.is_empty()
|
||||||
app.get_current_route(),
|
|
||||||
ActiveRadarrBlock::EditCollectionPrompt.into()
|
|
||||||
);
|
);
|
||||||
|
assert_navigation_popped!(app, ActiveRadarrBlock::EditCollectionPrompt.into());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -512,11 +513,8 @@ mod tests {
|
|||||||
)
|
)
|
||||||
.handle();
|
.handle();
|
||||||
|
|
||||||
assert_eq!(
|
assert_navigation_popped!(app, ActiveRadarrBlock::Collections.into());
|
||||||
app.get_current_route(),
|
assert_none!(app.data.radarr_data.prompt_confirm_action);
|
||||||
ActiveRadarrBlock::Collections.into()
|
|
||||||
);
|
|
||||||
assert_eq!(app.data.radarr_data.prompt_confirm_action, None);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -569,16 +567,13 @@ mod tests {
|
|||||||
)
|
)
|
||||||
.handle();
|
.handle();
|
||||||
|
|
||||||
assert_eq!(
|
assert_navigation_popped!(app, ActiveRadarrBlock::Collections.into());
|
||||||
app.get_current_route(),
|
|
||||||
ActiveRadarrBlock::Collections.into()
|
|
||||||
);
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
app.data.radarr_data.prompt_confirm_action,
|
app.data.radarr_data.prompt_confirm_action,
|
||||||
Some(RadarrEvent::EditCollection(expected_edit_collection_params))
|
Some(RadarrEvent::EditCollection(expected_edit_collection_params))
|
||||||
);
|
);
|
||||||
assert!(app.should_refresh);
|
assert!(app.should_refresh);
|
||||||
assert!(app.data.radarr_data.edit_collection_modal.is_none());
|
assert_modal_absent!(app.data.radarr_data.edit_collection_modal);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -609,7 +604,7 @@ mod tests {
|
|||||||
app.get_current_route(),
|
app.get_current_route(),
|
||||||
ActiveRadarrBlock::EditCollectionPrompt.into()
|
ActiveRadarrBlock::EditCollectionPrompt.into()
|
||||||
);
|
);
|
||||||
assert_eq!(app.data.radarr_data.prompt_confirm_action, None);
|
assert_none!(app.data.radarr_data.prompt_confirm_action);
|
||||||
assert!(!app.should_refresh);
|
assert!(!app.should_refresh);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -634,7 +629,7 @@ mod tests {
|
|||||||
.handle();
|
.handle();
|
||||||
|
|
||||||
assert_eq!(app.get_current_route(), current_route);
|
assert_eq!(app.get_current_route(), current_route);
|
||||||
assert_eq!(
|
assert_some_eq_x!(
|
||||||
app
|
app
|
||||||
.data
|
.data
|
||||||
.radarr_data
|
.radarr_data
|
||||||
@@ -642,7 +637,7 @@ mod tests {
|
|||||||
.as_ref()
|
.as_ref()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.monitored,
|
.monitored,
|
||||||
Some(true)
|
true
|
||||||
);
|
);
|
||||||
|
|
||||||
EditCollectionHandler::new(
|
EditCollectionHandler::new(
|
||||||
@@ -654,7 +649,7 @@ mod tests {
|
|||||||
.handle();
|
.handle();
|
||||||
|
|
||||||
assert_eq!(app.get_current_route(), current_route);
|
assert_eq!(app.get_current_route(), current_route);
|
||||||
assert_eq!(
|
assert_some_eq_x!(
|
||||||
app
|
app
|
||||||
.data
|
.data
|
||||||
.radarr_data
|
.radarr_data
|
||||||
@@ -662,7 +657,7 @@ mod tests {
|
|||||||
.as_ref()
|
.as_ref()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.monitored,
|
.monitored,
|
||||||
Some(false)
|
false
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -692,7 +687,7 @@ mod tests {
|
|||||||
.handle();
|
.handle();
|
||||||
|
|
||||||
assert_eq!(app.get_current_route(), current_route);
|
assert_eq!(app.get_current_route(), current_route);
|
||||||
assert_eq!(
|
assert_some_eq_x!(
|
||||||
app
|
app
|
||||||
.data
|
.data
|
||||||
.radarr_data
|
.radarr_data
|
||||||
@@ -700,7 +695,7 @@ mod tests {
|
|||||||
.as_ref()
|
.as_ref()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.search_on_add,
|
.search_on_add,
|
||||||
Some(true)
|
true
|
||||||
);
|
);
|
||||||
|
|
||||||
EditCollectionHandler::new(
|
EditCollectionHandler::new(
|
||||||
@@ -712,7 +707,7 @@ mod tests {
|
|||||||
.handle();
|
.handle();
|
||||||
|
|
||||||
assert_eq!(app.get_current_route(), current_route);
|
assert_eq!(app.get_current_route(), current_route);
|
||||||
assert_eq!(
|
assert_some_eq_x!(
|
||||||
app
|
app
|
||||||
.data
|
.data
|
||||||
.radarr_data
|
.radarr_data
|
||||||
@@ -720,7 +715,7 @@ mod tests {
|
|||||||
.as_ref()
|
.as_ref()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.search_on_add,
|
.search_on_add,
|
||||||
Some(false)
|
false
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -753,11 +748,11 @@ mod tests {
|
|||||||
)
|
)
|
||||||
.handle();
|
.handle();
|
||||||
|
|
||||||
assert_eq!(
|
assert_navigation_pushed!(
|
||||||
app.get_current_route(),
|
app,
|
||||||
(selected_block, Some(ActiveRadarrBlock::Collections)).into()
|
(selected_block, Some(ActiveRadarrBlock::Collections)).into()
|
||||||
);
|
);
|
||||||
assert_eq!(app.data.radarr_data.prompt_confirm_action, None);
|
assert_none!(app.data.radarr_data.prompt_confirm_action);
|
||||||
|
|
||||||
if selected_block == ActiveRadarrBlock::EditCollectionRootFolderPathInput {
|
if selected_block == ActiveRadarrBlock::EditCollectionRootFolderPathInput {
|
||||||
assert!(app.ignore_special_keys_for_textbox_input);
|
assert!(app.ignore_special_keys_for_textbox_input);
|
||||||
@@ -786,10 +781,7 @@ mod tests {
|
|||||||
)
|
)
|
||||||
.handle();
|
.handle();
|
||||||
|
|
||||||
assert_eq!(
|
assert_navigation_popped!(app, ActiveRadarrBlock::EditCollectionPrompt.into());
|
||||||
app.get_current_route(),
|
|
||||||
ActiveRadarrBlock::EditCollectionPrompt.into()
|
|
||||||
);
|
|
||||||
|
|
||||||
if active_radarr_block == ActiveRadarrBlock::EditCollectionRootFolderPathInput {
|
if active_radarr_block == ActiveRadarrBlock::EditCollectionRootFolderPathInput {
|
||||||
assert!(!app.ignore_special_keys_for_textbox_input);
|
assert!(!app.ignore_special_keys_for_textbox_input);
|
||||||
@@ -798,10 +790,9 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
mod test_handle_esc {
|
mod test_handle_esc {
|
||||||
use pretty_assertions::assert_eq;
|
use crate::assert_navigation_popped;
|
||||||
use rstest::rstest;
|
|
||||||
|
|
||||||
use crate::models::servarr_data::radarr::radarr_data::radarr_test_utils::utils::create_test_radarr_data;
|
use crate::models::servarr_data::radarr::radarr_data::radarr_test_utils::utils::create_test_radarr_data;
|
||||||
|
use rstest::rstest;
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
@@ -825,10 +816,7 @@ mod tests {
|
|||||||
.handle();
|
.handle();
|
||||||
|
|
||||||
assert!(!app.ignore_special_keys_for_textbox_input);
|
assert!(!app.ignore_special_keys_for_textbox_input);
|
||||||
assert_eq!(
|
assert_navigation_popped!(app, ActiveRadarrBlock::EditCollectionPrompt.into());
|
||||||
app.get_current_route(),
|
|
||||||
ActiveRadarrBlock::EditCollectionPrompt.into()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -846,13 +834,10 @@ mod tests {
|
|||||||
)
|
)
|
||||||
.handle();
|
.handle();
|
||||||
|
|
||||||
assert_eq!(
|
assert_navigation_popped!(app, ActiveRadarrBlock::Collections.into());
|
||||||
app.get_current_route(),
|
|
||||||
ActiveRadarrBlock::Collections.into()
|
|
||||||
);
|
|
||||||
let radarr_data = &app.data.radarr_data;
|
let radarr_data = &app.data.radarr_data;
|
||||||
|
|
||||||
assert!(radarr_data.edit_collection_modal.is_none());
|
assert_modal_absent!(radarr_data.edit_collection_modal);
|
||||||
assert!(!radarr_data.prompt_confirm);
|
assert!(!radarr_data.prompt_confirm);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -873,21 +858,19 @@ mod tests {
|
|||||||
|
|
||||||
EditCollectionHandler::new(ESC_KEY, &mut app, active_radarr_block, None).handle();
|
EditCollectionHandler::new(ESC_KEY, &mut app, active_radarr_block, None).handle();
|
||||||
|
|
||||||
assert_eq!(
|
assert_navigation_popped!(app, ActiveRadarrBlock::Collections.into());
|
||||||
app.get_current_route(),
|
|
||||||
ActiveRadarrBlock::Collections.into()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mod test_handle_key_char {
|
mod test_handle_key_char {
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::{
|
use crate::{
|
||||||
|
assert_navigation_popped,
|
||||||
models::{
|
models::{
|
||||||
|
BlockSelectionState,
|
||||||
servarr_data::radarr::{
|
servarr_data::radarr::{
|
||||||
modals::EditCollectionModal, radarr_data::EDIT_COLLECTION_SELECTION_BLOCKS,
|
modals::EditCollectionModal, radarr_data::EDIT_COLLECTION_SELECTION_BLOCKS,
|
||||||
},
|
},
|
||||||
BlockSelectionState,
|
|
||||||
},
|
},
|
||||||
network::radarr_network::RadarrEvent,
|
network::radarr_network::RadarrEvent,
|
||||||
};
|
};
|
||||||
@@ -996,16 +979,13 @@ mod tests {
|
|||||||
)
|
)
|
||||||
.handle();
|
.handle();
|
||||||
|
|
||||||
assert_eq!(
|
assert_navigation_popped!(app, ActiveRadarrBlock::Collections.into());
|
||||||
app.get_current_route(),
|
|
||||||
ActiveRadarrBlock::Collections.into()
|
|
||||||
);
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
app.data.radarr_data.prompt_confirm_action,
|
app.data.radarr_data.prompt_confirm_action,
|
||||||
Some(RadarrEvent::EditCollection(expected_edit_collection_params))
|
Some(RadarrEvent::EditCollection(expected_edit_collection_params))
|
||||||
);
|
);
|
||||||
assert!(app.should_refresh);
|
assert!(app.should_refresh);
|
||||||
assert!(app.data.radarr_data.edit_collection_modal.is_none());
|
assert_modal_absent!(app.data.radarr_data.edit_collection_modal);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1080,7 +1060,7 @@ mod tests {
|
|||||||
.build_edit_collection_params();
|
.build_edit_collection_params();
|
||||||
|
|
||||||
assert_eq!(edit_collection_params, expected_edit_collection_params);
|
assert_eq!(edit_collection_params, expected_edit_collection_params);
|
||||||
assert!(app.data.radarr_data.edit_collection_modal.is_none());
|
assert_modal_absent!(app.data.radarr_data.edit_collection_modal);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|||||||
@@ -3,16 +3,16 @@ use crate::event::Key;
|
|||||||
use crate::handlers::radarr_handlers::collections::collection_details_handler::CollectionDetailsHandler;
|
use crate::handlers::radarr_handlers::collections::collection_details_handler::CollectionDetailsHandler;
|
||||||
use crate::handlers::radarr_handlers::collections::edit_collection_handler::EditCollectionHandler;
|
use crate::handlers::radarr_handlers::collections::edit_collection_handler::EditCollectionHandler;
|
||||||
use crate::handlers::radarr_handlers::handle_change_tab_left_right_keys;
|
use crate::handlers::radarr_handlers::handle_change_tab_left_right_keys;
|
||||||
use crate::handlers::table_handler::TableHandlingConfig;
|
use crate::handlers::table_handler::{TableHandlingConfig, handle_table};
|
||||||
use crate::handlers::{handle_clear_errors, handle_prompt_toggle, KeyEventHandler};
|
use crate::handlers::{KeyEventHandler, handle_clear_errors, handle_prompt_toggle};
|
||||||
|
use crate::matches_key;
|
||||||
|
use crate::models::BlockSelectionState;
|
||||||
use crate::models::radarr_models::Collection;
|
use crate::models::radarr_models::Collection;
|
||||||
use crate::models::servarr_data::radarr::radarr_data::{
|
use crate::models::servarr_data::radarr::radarr_data::{
|
||||||
ActiveRadarrBlock, COLLECTIONS_BLOCKS, EDIT_COLLECTION_SELECTION_BLOCKS,
|
ActiveRadarrBlock, COLLECTIONS_BLOCKS, EDIT_COLLECTION_SELECTION_BLOCKS,
|
||||||
};
|
};
|
||||||
use crate::models::stateful_table::SortOption;
|
use crate::models::stateful_table::SortOption;
|
||||||
use crate::models::BlockSelectionState;
|
|
||||||
use crate::network::radarr_network::RadarrEvent;
|
use crate::network::radarr_network::RadarrEvent;
|
||||||
use crate::{handle_table_events, matches_key};
|
|
||||||
|
|
||||||
mod collection_details_handler;
|
mod collection_details_handler;
|
||||||
mod edit_collection_handler;
|
mod edit_collection_handler;
|
||||||
@@ -28,21 +28,13 @@ pub(super) struct CollectionsHandler<'a, 'b> {
|
|||||||
context: Option<ActiveRadarrBlock>,
|
context: Option<ActiveRadarrBlock>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CollectionsHandler<'_, '_> {
|
impl CollectionsHandler<'_, '_> {}
|
||||||
handle_table_events!(
|
|
||||||
self,
|
|
||||||
collections,
|
|
||||||
self.app.data.radarr_data.collections,
|
|
||||||
Collection
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for CollectionsHandler<'a, 'b> {
|
impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for CollectionsHandler<'a, 'b> {
|
||||||
fn handle(&mut self) {
|
fn handle(&mut self) {
|
||||||
let collections_table_handling_config =
|
let collections_table_handling_config =
|
||||||
TableHandlingConfig::new(ActiveRadarrBlock::Collections.into())
|
TableHandlingConfig::new(ActiveRadarrBlock::Collections.into())
|
||||||
.sorting_block(ActiveRadarrBlock::CollectionsSortPrompt.into())
|
.sorting_block(ActiveRadarrBlock::CollectionsSortPrompt.into())
|
||||||
.sort_by_fn(|a: &Collection, b: &Collection| a.id.cmp(&b.id))
|
|
||||||
.sort_options(collections_sorting_options())
|
.sort_options(collections_sorting_options())
|
||||||
.searching_block(ActiveRadarrBlock::SearchCollection.into())
|
.searching_block(ActiveRadarrBlock::SearchCollection.into())
|
||||||
.search_error_block(ActiveRadarrBlock::SearchCollectionError.into())
|
.search_error_block(ActiveRadarrBlock::SearchCollectionError.into())
|
||||||
@@ -51,7 +43,11 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for CollectionsHandler<'
|
|||||||
.filter_error_block(ActiveRadarrBlock::FilterCollectionsError.into())
|
.filter_error_block(ActiveRadarrBlock::FilterCollectionsError.into())
|
||||||
.filter_field_fn(|collection| &collection.title.text);
|
.filter_field_fn(|collection| &collection.title.text);
|
||||||
|
|
||||||
if !self.handle_collections_table_events(collections_table_handling_config) {
|
if !handle_table(
|
||||||
|
self,
|
||||||
|
|app| &mut app.data.radarr_data.collections,
|
||||||
|
collections_table_handling_config,
|
||||||
|
) {
|
||||||
match self.active_radarr_block {
|
match self.active_radarr_block {
|
||||||
_ if CollectionDetailsHandler::accepts(self.active_radarr_block) => {
|
_ if CollectionDetailsHandler::accepts(self.active_radarr_block) => {
|
||||||
CollectionDetailsHandler::new(self.key, self.app, self.active_radarr_block, self.context)
|
CollectionDetailsHandler::new(self.key, self.app, self.active_radarr_block, self.context)
|
||||||
@@ -178,6 +174,14 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for CollectionsHandler<'
|
|||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn app_mut(&mut self) -> &mut App<'b> {
|
||||||
|
self.app
|
||||||
|
}
|
||||||
|
|
||||||
|
fn current_route(&self) -> crate::models::Route {
|
||||||
|
self.app.get_current_route()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn collections_sorting_options() -> Vec<SortOption<Collection>> {
|
fn collections_sorting_options() -> Vec<SortOption<Collection>> {
|
||||||
|
|||||||
@@ -4,12 +4,13 @@ mod tests {
|
|||||||
use rstest::rstest;
|
use rstest::rstest;
|
||||||
use strum::IntoEnumIterator;
|
use strum::IntoEnumIterator;
|
||||||
|
|
||||||
use crate::app::key_binding::DEFAULT_KEYBINDINGS;
|
|
||||||
use crate::app::App;
|
use crate::app::App;
|
||||||
|
use crate::app::key_binding::DEFAULT_KEYBINDINGS;
|
||||||
|
use crate::assert_navigation_pushed;
|
||||||
use crate::event::Key;
|
use crate::event::Key;
|
||||||
|
use crate::handlers::KeyEventHandler;
|
||||||
use crate::handlers::radarr_handlers::downloads::DownloadsHandler;
|
use crate::handlers::radarr_handlers::downloads::DownloadsHandler;
|
||||||
use crate::handlers::radarr_handlers::radarr_handler_test_utils::utils::download_record;
|
use crate::handlers::radarr_handlers::radarr_handler_test_utils::utils::download_record;
|
||||||
use crate::handlers::KeyEventHandler;
|
|
||||||
use crate::models::radarr_models::DownloadRecord;
|
use crate::models::radarr_models::DownloadRecord;
|
||||||
use crate::models::servarr_data::radarr::radarr_data::{ActiveRadarrBlock, DOWNLOADS_BLOCKS};
|
use crate::models::servarr_data::radarr::radarr_data::{ActiveRadarrBlock, DOWNLOADS_BLOCKS};
|
||||||
|
|
||||||
@@ -31,10 +32,7 @@ mod tests {
|
|||||||
|
|
||||||
DownloadsHandler::new(DELETE_KEY, &mut app, ActiveRadarrBlock::Downloads, None).handle();
|
DownloadsHandler::new(DELETE_KEY, &mut app, ActiveRadarrBlock::Downloads, None).handle();
|
||||||
|
|
||||||
assert_eq!(
|
assert_navigation_pushed!(app, ActiveRadarrBlock::DeleteDownloadPrompt.into());
|
||||||
app.get_current_route(),
|
|
||||||
ActiveRadarrBlock::DeleteDownloadPrompt.into()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -78,10 +76,7 @@ mod tests {
|
|||||||
app.data.radarr_data.main_tabs.get_active_route(),
|
app.data.radarr_data.main_tabs.get_active_route(),
|
||||||
ActiveRadarrBlock::Collections.into()
|
ActiveRadarrBlock::Collections.into()
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_navigation_pushed!(app, ActiveRadarrBlock::Collections.into());
|
||||||
app.get_current_route(),
|
|
||||||
ActiveRadarrBlock::Collections.into()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[rstest]
|
#[rstest]
|
||||||
@@ -102,7 +97,7 @@ mod tests {
|
|||||||
app.data.radarr_data.main_tabs.get_active_route(),
|
app.data.radarr_data.main_tabs.get_active_route(),
|
||||||
ActiveRadarrBlock::Blocklist.into()
|
ActiveRadarrBlock::Blocklist.into()
|
||||||
);
|
);
|
||||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Blocklist.into());
|
assert_navigation_pushed!(app, ActiveRadarrBlock::Blocklist.into());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[rstest]
|
#[rstest]
|
||||||
@@ -133,6 +128,7 @@ mod tests {
|
|||||||
use crate::network::radarr_network::RadarrEvent;
|
use crate::network::radarr_network::RadarrEvent;
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
use crate::assert_navigation_popped;
|
||||||
|
|
||||||
const SUBMIT_KEY: Key = DEFAULT_KEYBINDINGS.submit.key;
|
const SUBMIT_KEY: Key = DEFAULT_KEYBINDINGS.submit.key;
|
||||||
|
|
||||||
@@ -169,7 +165,7 @@ mod tests {
|
|||||||
app.data.radarr_data.prompt_confirm_action,
|
app.data.radarr_data.prompt_confirm_action,
|
||||||
Some(expected_action)
|
Some(expected_action)
|
||||||
);
|
);
|
||||||
assert_eq!(app.get_current_route(), base_route.into());
|
assert_navigation_popped!(app, base_route.into());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[rstest]
|
#[rstest]
|
||||||
@@ -191,16 +187,16 @@ mod tests {
|
|||||||
DownloadsHandler::new(SUBMIT_KEY, &mut app, prompt_block, None).handle();
|
DownloadsHandler::new(SUBMIT_KEY, &mut app, prompt_block, None).handle();
|
||||||
|
|
||||||
assert!(!app.data.radarr_data.prompt_confirm);
|
assert!(!app.data.radarr_data.prompt_confirm);
|
||||||
assert_eq!(app.data.radarr_data.prompt_confirm_action, None);
|
assert_none!(app.data.radarr_data.prompt_confirm_action);
|
||||||
assert_eq!(app.get_current_route(), base_route.into());
|
assert_navigation_popped!(app, base_route.into());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mod test_handle_esc {
|
mod test_handle_esc {
|
||||||
use pretty_assertions::assert_eq;
|
|
||||||
use rstest::rstest;
|
use rstest::rstest;
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
use crate::assert_navigation_popped;
|
||||||
|
|
||||||
const ESC_KEY: Key = DEFAULT_KEYBINDINGS.esc.key;
|
const ESC_KEY: Key = DEFAULT_KEYBINDINGS.esc.key;
|
||||||
|
|
||||||
@@ -218,7 +214,7 @@ mod tests {
|
|||||||
|
|
||||||
DownloadsHandler::new(ESC_KEY, &mut app, prompt_block, None).handle();
|
DownloadsHandler::new(ESC_KEY, &mut app, prompt_block, None).handle();
|
||||||
|
|
||||||
assert_eq!(app.get_current_route(), base_block.into());
|
assert_navigation_popped!(app, base_block.into());
|
||||||
assert!(!app.data.radarr_data.prompt_confirm);
|
assert!(!app.data.radarr_data.prompt_confirm);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -232,17 +228,17 @@ mod tests {
|
|||||||
|
|
||||||
DownloadsHandler::new(ESC_KEY, &mut app, ActiveRadarrBlock::Downloads, None).handle();
|
DownloadsHandler::new(ESC_KEY, &mut app, ActiveRadarrBlock::Downloads, None).handle();
|
||||||
|
|
||||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Downloads.into());
|
assert_navigation_popped!(app, ActiveRadarrBlock::Downloads.into());
|
||||||
assert!(app.error.text.is_empty());
|
assert_is_empty!(app.error.text);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mod test_handle_key_char {
|
mod test_handle_key_char {
|
||||||
|
use crate::assert_navigation_popped;
|
||||||
|
use crate::network::radarr_network::RadarrEvent;
|
||||||
use pretty_assertions::assert_eq;
|
use pretty_assertions::assert_eq;
|
||||||
use rstest::rstest;
|
use rstest::rstest;
|
||||||
|
|
||||||
use crate::network::radarr_network::RadarrEvent;
|
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -262,10 +258,7 @@ mod tests {
|
|||||||
)
|
)
|
||||||
.handle();
|
.handle();
|
||||||
|
|
||||||
assert_eq!(
|
assert_navigation_pushed!(app, ActiveRadarrBlock::UpdateDownloadsPrompt.into());
|
||||||
app.get_current_route(),
|
|
||||||
ActiveRadarrBlock::UpdateDownloadsPrompt.into()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -308,7 +301,7 @@ mod tests {
|
|||||||
)
|
)
|
||||||
.handle();
|
.handle();
|
||||||
|
|
||||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Downloads.into());
|
assert_navigation_pushed!(app, ActiveRadarrBlock::Downloads.into());
|
||||||
assert!(app.should_refresh);
|
assert!(app.should_refresh);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -373,7 +366,7 @@ mod tests {
|
|||||||
app.data.radarr_data.prompt_confirm_action,
|
app.data.radarr_data.prompt_confirm_action,
|
||||||
Some(expected_action)
|
Some(expected_action)
|
||||||
);
|
);
|
||||||
assert_eq!(app.get_current_route(), base_route.into());
|
assert_navigation_popped!(app, base_route.into());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,11 @@
|
|||||||
use crate::app::App;
|
use crate::app::App;
|
||||||
use crate::event::Key;
|
use crate::event::Key;
|
||||||
use crate::handlers::radarr_handlers::handle_change_tab_left_right_keys;
|
use crate::handlers::radarr_handlers::handle_change_tab_left_right_keys;
|
||||||
use crate::handlers::table_handler::TableHandlingConfig;
|
use crate::handlers::table_handler::{TableHandlingConfig, handle_table};
|
||||||
use crate::handlers::{handle_clear_errors, handle_prompt_toggle, KeyEventHandler};
|
use crate::handlers::{KeyEventHandler, handle_clear_errors, handle_prompt_toggle};
|
||||||
use crate::models::radarr_models::DownloadRecord;
|
use crate::matches_key;
|
||||||
use crate::models::servarr_data::radarr::radarr_data::{ActiveRadarrBlock, DOWNLOADS_BLOCKS};
|
use crate::models::servarr_data::radarr::radarr_data::{ActiveRadarrBlock, DOWNLOADS_BLOCKS};
|
||||||
use crate::network::radarr_network::RadarrEvent;
|
use crate::network::radarr_network::RadarrEvent;
|
||||||
use crate::{handle_table_events, matches_key};
|
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
#[path = "downloads_handler_tests.rs"]
|
#[path = "downloads_handler_tests.rs"]
|
||||||
@@ -20,13 +19,6 @@ pub(super) struct DownloadsHandler<'a, 'b> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl DownloadsHandler<'_, '_> {
|
impl DownloadsHandler<'_, '_> {
|
||||||
handle_table_events!(
|
|
||||||
self,
|
|
||||||
downloads,
|
|
||||||
self.app.data.radarr_data.downloads,
|
|
||||||
DownloadRecord
|
|
||||||
);
|
|
||||||
|
|
||||||
fn extract_download_id(&self) -> i64 {
|
fn extract_download_id(&self) -> i64 {
|
||||||
self.app.data.radarr_data.downloads.current_selection().id
|
self.app.data.radarr_data.downloads.current_selection().id
|
||||||
}
|
}
|
||||||
@@ -37,7 +29,11 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for DownloadsHandler<'a,
|
|||||||
let downloads_table_handling_config =
|
let downloads_table_handling_config =
|
||||||
TableHandlingConfig::new(ActiveRadarrBlock::Downloads.into());
|
TableHandlingConfig::new(ActiveRadarrBlock::Downloads.into());
|
||||||
|
|
||||||
if !self.handle_downloads_table_events(downloads_table_handling_config) {
|
if !handle_table(
|
||||||
|
self,
|
||||||
|
|app| &mut app.data.radarr_data.downloads,
|
||||||
|
downloads_table_handling_config,
|
||||||
|
) {
|
||||||
self.handle_key_event();
|
self.handle_key_event();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -163,4 +159,12 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for DownloadsHandler<'a,
|
|||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn app_mut(&mut self) -> &mut App<'b> {
|
||||||
|
self.app
|
||||||
|
}
|
||||||
|
|
||||||
|
fn current_route(&self) -> crate::models::Route {
|
||||||
|
self.app.get_current_route()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
use crate::app::App;
|
use crate::app::App;
|
||||||
use crate::event::Key;
|
use crate::event::Key;
|
||||||
use crate::handlers::{handle_prompt_toggle, KeyEventHandler};
|
use crate::handlers::{KeyEventHandler, handle_prompt_toggle};
|
||||||
use crate::models::servarr_data::modals::EditIndexerModal;
|
use crate::models::servarr_data::modals::EditIndexerModal;
|
||||||
use crate::models::servarr_data::radarr::radarr_data::{ActiveRadarrBlock, EDIT_INDEXER_BLOCKS};
|
use crate::models::servarr_data::radarr::radarr_data::{ActiveRadarrBlock, EDIT_INDEXER_BLOCKS};
|
||||||
use crate::models::servarr_models::EditIndexerParams;
|
use crate::models::servarr_models::EditIndexerParams;
|
||||||
@@ -522,4 +522,12 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for EditIndexerHandler<'
|
|||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn app_mut(&mut self) -> &mut App<'b> {
|
||||||
|
self.app
|
||||||
|
}
|
||||||
|
|
||||||
|
fn current_route(&self) -> crate::models::Route {
|
||||||
|
self.app.get_current_route()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,14 @@
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use crate::app::key_binding::DEFAULT_KEYBINDINGS;
|
|
||||||
use crate::app::App;
|
use crate::app::App;
|
||||||
|
use crate::app::key_binding::DEFAULT_KEYBINDINGS;
|
||||||
|
use crate::assert_modal_absent;
|
||||||
|
use crate::assert_modal_present;
|
||||||
|
use crate::assert_navigation_pushed;
|
||||||
use crate::event::Key;
|
use crate::event::Key;
|
||||||
|
use crate::handlers::KeyEventHandler;
|
||||||
use crate::handlers::radarr_handlers::indexers::edit_indexer_handler::EditIndexerHandler;
|
use crate::handlers::radarr_handlers::indexers::edit_indexer_handler::EditIndexerHandler;
|
||||||
use crate::handlers::radarr_handlers::radarr_handler_test_utils::utils::indexer;
|
use crate::handlers::radarr_handlers::radarr_handler_test_utils::utils::indexer;
|
||||||
use crate::handlers::KeyEventHandler;
|
|
||||||
use crate::models::servarr_data::modals::EditIndexerModal;
|
use crate::models::servarr_data::modals::EditIndexerModal;
|
||||||
use crate::models::servarr_data::radarr::radarr_data::{ActiveRadarrBlock, EDIT_INDEXER_BLOCKS};
|
use crate::models::servarr_data::radarr::radarr_data::{ActiveRadarrBlock, EDIT_INDEXER_BLOCKS};
|
||||||
use crate::models::servarr_models::EditIndexerParams;
|
use crate::models::servarr_models::EditIndexerParams;
|
||||||
@@ -18,9 +21,9 @@ mod tests {
|
|||||||
use pretty_assertions::assert_eq;
|
use pretty_assertions::assert_eq;
|
||||||
use rstest::rstest;
|
use rstest::rstest;
|
||||||
|
|
||||||
|
use crate::models::BlockSelectionState;
|
||||||
use crate::models::servarr_data::modals::EditIndexerModal;
|
use crate::models::servarr_data::modals::EditIndexerModal;
|
||||||
use crate::models::servarr_data::radarr::radarr_data::EDIT_INDEXER_TORRENT_SELECTION_BLOCKS;
|
use crate::models::servarr_data::radarr::radarr_data::EDIT_INDEXER_TORRENT_SELECTION_BLOCKS;
|
||||||
use crate::models::BlockSelectionState;
|
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
@@ -419,11 +422,11 @@ mod tests {
|
|||||||
use std::sync::atomic::Ordering;
|
use std::sync::atomic::Ordering;
|
||||||
|
|
||||||
use crate::app::App;
|
use crate::app::App;
|
||||||
|
use crate::models::BlockSelectionState;
|
||||||
use crate::models::servarr_data::modals::EditIndexerModal;
|
use crate::models::servarr_data::modals::EditIndexerModal;
|
||||||
use crate::models::servarr_data::radarr::radarr_data::{
|
use crate::models::servarr_data::radarr::radarr_data::{
|
||||||
EDIT_INDEXER_NZB_SELECTION_BLOCKS, EDIT_INDEXER_TORRENT_SELECTION_BLOCKS,
|
EDIT_INDEXER_NZB_SELECTION_BLOCKS, EDIT_INDEXER_TORRENT_SELECTION_BLOCKS,
|
||||||
};
|
};
|
||||||
use crate::models::BlockSelectionState;
|
|
||||||
use pretty_assertions::assert_eq;
|
use pretty_assertions::assert_eq;
|
||||||
use rstest::rstest;
|
use rstest::rstest;
|
||||||
|
|
||||||
@@ -850,9 +853,10 @@ mod tests {
|
|||||||
use rstest::rstest;
|
use rstest::rstest;
|
||||||
|
|
||||||
use crate::app::App;
|
use crate::app::App;
|
||||||
|
use crate::assert_navigation_popped;
|
||||||
use crate::models::servarr_data::modals::EditIndexerModal;
|
use crate::models::servarr_data::modals::EditIndexerModal;
|
||||||
use crate::models::{
|
use crate::models::{
|
||||||
servarr_data::radarr::radarr_data::EDIT_INDEXER_TORRENT_SELECTION_BLOCKS, BlockSelectionState,
|
BlockSelectionState, servarr_data::radarr::radarr_data::EDIT_INDEXER_TORRENT_SELECTION_BLOCKS,
|
||||||
};
|
};
|
||||||
use crate::network::radarr_network::RadarrEvent;
|
use crate::network::radarr_network::RadarrEvent;
|
||||||
|
|
||||||
@@ -882,10 +886,10 @@ mod tests {
|
|||||||
)
|
)
|
||||||
.handle();
|
.handle();
|
||||||
|
|
||||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Indexers.into());
|
assert_navigation_popped!(app, ActiveRadarrBlock::Indexers.into());
|
||||||
assert_eq!(app.data.radarr_data.prompt_confirm_action, None);
|
assert_none!(app.data.radarr_data.prompt_confirm_action);
|
||||||
assert!(!app.should_refresh);
|
assert!(!app.should_refresh);
|
||||||
assert_eq!(app.data.radarr_data.edit_indexer_modal, None);
|
assert_none!(app.data.radarr_data.edit_indexer_modal);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -936,8 +940,8 @@ mod tests {
|
|||||||
)
|
)
|
||||||
.handle();
|
.handle();
|
||||||
|
|
||||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Indexers.into());
|
assert_navigation_popped!(app, ActiveRadarrBlock::Indexers.into());
|
||||||
assert!(app.data.radarr_data.edit_indexer_modal.is_none());
|
assert_modal_absent!(app.data.radarr_data.edit_indexer_modal);
|
||||||
assert!(app.should_refresh);
|
assert!(app.should_refresh);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
app.data.radarr_data.prompt_confirm_action,
|
app.data.radarr_data.prompt_confirm_action,
|
||||||
@@ -966,9 +970,9 @@ mod tests {
|
|||||||
app.get_current_route(),
|
app.get_current_route(),
|
||||||
ActiveRadarrBlock::EditIndexerPrompt.into()
|
ActiveRadarrBlock::EditIndexerPrompt.into()
|
||||||
);
|
);
|
||||||
assert!(app.data.radarr_data.edit_indexer_modal.is_some());
|
assert_modal_present!(app.data.radarr_data.edit_indexer_modal);
|
||||||
assert!(!app.should_refresh);
|
assert!(!app.should_refresh);
|
||||||
assert_eq!(app.data.radarr_data.prompt_confirm_action, None);
|
assert_none!(app.data.radarr_data.prompt_confirm_action);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[rstest]
|
#[rstest]
|
||||||
@@ -1002,7 +1006,7 @@ mod tests {
|
|||||||
)
|
)
|
||||||
.handle();
|
.handle();
|
||||||
|
|
||||||
assert_eq!(app.get_current_route(), block.into());
|
assert_navigation_pushed!(app, block.into());
|
||||||
assert!(app.ignore_special_keys_for_textbox_input);
|
assert!(app.ignore_special_keys_for_textbox_input);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1024,10 +1028,7 @@ mod tests {
|
|||||||
)
|
)
|
||||||
.handle();
|
.handle();
|
||||||
|
|
||||||
assert_eq!(
|
assert_navigation_pushed!(app, ActiveRadarrBlock::EditIndexerPriorityInput.into());
|
||||||
app.get_current_route(),
|
|
||||||
ActiveRadarrBlock::EditIndexerPriorityInput.into()
|
|
||||||
);
|
|
||||||
assert!(!app.ignore_special_keys_for_textbox_input);
|
assert!(!app.ignore_special_keys_for_textbox_input);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1053,14 +1054,16 @@ mod tests {
|
|||||||
app.get_current_route(),
|
app.get_current_route(),
|
||||||
ActiveRadarrBlock::EditIndexerPrompt.into()
|
ActiveRadarrBlock::EditIndexerPrompt.into()
|
||||||
);
|
);
|
||||||
assert!(app
|
assert!(
|
||||||
.data
|
app
|
||||||
.radarr_data
|
.data
|
||||||
.edit_indexer_modal
|
.radarr_data
|
||||||
.as_ref()
|
.edit_indexer_modal
|
||||||
.unwrap()
|
.as_ref()
|
||||||
.enable_rss
|
.unwrap()
|
||||||
.unwrap());
|
.enable_rss
|
||||||
|
.unwrap()
|
||||||
|
);
|
||||||
|
|
||||||
EditIndexerHandler::new(
|
EditIndexerHandler::new(
|
||||||
SUBMIT_KEY,
|
SUBMIT_KEY,
|
||||||
@@ -1074,14 +1077,16 @@ mod tests {
|
|||||||
app.get_current_route(),
|
app.get_current_route(),
|
||||||
ActiveRadarrBlock::EditIndexerPrompt.into()
|
ActiveRadarrBlock::EditIndexerPrompt.into()
|
||||||
);
|
);
|
||||||
assert!(!app
|
assert!(
|
||||||
.data
|
!app
|
||||||
.radarr_data
|
.data
|
||||||
.edit_indexer_modal
|
.radarr_data
|
||||||
.as_ref()
|
.edit_indexer_modal
|
||||||
.unwrap()
|
.as_ref()
|
||||||
.enable_rss
|
.unwrap()
|
||||||
.unwrap());
|
.enable_rss
|
||||||
|
.unwrap()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -1106,14 +1111,16 @@ mod tests {
|
|||||||
app.get_current_route(),
|
app.get_current_route(),
|
||||||
ActiveRadarrBlock::EditIndexerPrompt.into()
|
ActiveRadarrBlock::EditIndexerPrompt.into()
|
||||||
);
|
);
|
||||||
assert!(app
|
assert!(
|
||||||
.data
|
app
|
||||||
.radarr_data
|
.data
|
||||||
.edit_indexer_modal
|
.radarr_data
|
||||||
.as_ref()
|
.edit_indexer_modal
|
||||||
.unwrap()
|
.as_ref()
|
||||||
.enable_automatic_search
|
.unwrap()
|
||||||
.unwrap());
|
.enable_automatic_search
|
||||||
|
.unwrap()
|
||||||
|
);
|
||||||
|
|
||||||
EditIndexerHandler::new(
|
EditIndexerHandler::new(
|
||||||
SUBMIT_KEY,
|
SUBMIT_KEY,
|
||||||
@@ -1127,14 +1134,16 @@ mod tests {
|
|||||||
app.get_current_route(),
|
app.get_current_route(),
|
||||||
ActiveRadarrBlock::EditIndexerPrompt.into()
|
ActiveRadarrBlock::EditIndexerPrompt.into()
|
||||||
);
|
);
|
||||||
assert!(!app
|
assert!(
|
||||||
.data
|
!app
|
||||||
.radarr_data
|
.data
|
||||||
.edit_indexer_modal
|
.radarr_data
|
||||||
.as_ref()
|
.edit_indexer_modal
|
||||||
.unwrap()
|
.as_ref()
|
||||||
.enable_automatic_search
|
.unwrap()
|
||||||
.unwrap());
|
.enable_automatic_search
|
||||||
|
.unwrap()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -1159,14 +1168,16 @@ mod tests {
|
|||||||
app.get_current_route(),
|
app.get_current_route(),
|
||||||
ActiveRadarrBlock::EditIndexerPrompt.into()
|
ActiveRadarrBlock::EditIndexerPrompt.into()
|
||||||
);
|
);
|
||||||
assert!(app
|
assert!(
|
||||||
.data
|
app
|
||||||
.radarr_data
|
.data
|
||||||
.edit_indexer_modal
|
.radarr_data
|
||||||
.as_ref()
|
.edit_indexer_modal
|
||||||
.unwrap()
|
.as_ref()
|
||||||
.enable_interactive_search
|
.unwrap()
|
||||||
.unwrap());
|
.enable_interactive_search
|
||||||
|
.unwrap()
|
||||||
|
);
|
||||||
|
|
||||||
EditIndexerHandler::new(
|
EditIndexerHandler::new(
|
||||||
SUBMIT_KEY,
|
SUBMIT_KEY,
|
||||||
@@ -1180,14 +1191,16 @@ mod tests {
|
|||||||
app.get_current_route(),
|
app.get_current_route(),
|
||||||
ActiveRadarrBlock::EditIndexerPrompt.into()
|
ActiveRadarrBlock::EditIndexerPrompt.into()
|
||||||
);
|
);
|
||||||
assert!(!app
|
assert!(
|
||||||
.data
|
!app
|
||||||
.radarr_data
|
.data
|
||||||
.edit_indexer_modal
|
.radarr_data
|
||||||
.as_ref()
|
.edit_indexer_modal
|
||||||
.unwrap()
|
.as_ref()
|
||||||
.enable_interactive_search
|
.unwrap()
|
||||||
.unwrap());
|
.enable_interactive_search
|
||||||
|
.unwrap()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -1211,19 +1224,18 @@ mod tests {
|
|||||||
.handle();
|
.handle();
|
||||||
|
|
||||||
assert!(!app.ignore_special_keys_for_textbox_input);
|
assert!(!app.ignore_special_keys_for_textbox_input);
|
||||||
assert!(!app
|
assert!(
|
||||||
.data
|
!app
|
||||||
.radarr_data
|
.data
|
||||||
.edit_indexer_modal
|
.radarr_data
|
||||||
.as_ref()
|
.edit_indexer_modal
|
||||||
.unwrap()
|
.as_ref()
|
||||||
.name
|
.unwrap()
|
||||||
.text
|
.name
|
||||||
.is_empty());
|
.text
|
||||||
assert_eq!(
|
.is_empty()
|
||||||
app.get_current_route(),
|
|
||||||
ActiveRadarrBlock::EditIndexerPrompt.into()
|
|
||||||
);
|
);
|
||||||
|
assert_navigation_popped!(app, ActiveRadarrBlock::EditIndexerPrompt.into());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -1247,19 +1259,18 @@ mod tests {
|
|||||||
.handle();
|
.handle();
|
||||||
|
|
||||||
assert!(!app.ignore_special_keys_for_textbox_input);
|
assert!(!app.ignore_special_keys_for_textbox_input);
|
||||||
assert!(!app
|
assert!(
|
||||||
.data
|
!app
|
||||||
.radarr_data
|
.data
|
||||||
.edit_indexer_modal
|
.radarr_data
|
||||||
.as_ref()
|
.edit_indexer_modal
|
||||||
.unwrap()
|
.as_ref()
|
||||||
.url
|
.unwrap()
|
||||||
.text
|
.url
|
||||||
.is_empty());
|
.text
|
||||||
assert_eq!(
|
.is_empty()
|
||||||
app.get_current_route(),
|
|
||||||
ActiveRadarrBlock::EditIndexerPrompt.into()
|
|
||||||
);
|
);
|
||||||
|
assert_navigation_popped!(app, ActiveRadarrBlock::EditIndexerPrompt.into());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -1283,19 +1294,18 @@ mod tests {
|
|||||||
.handle();
|
.handle();
|
||||||
|
|
||||||
assert!(!app.ignore_special_keys_for_textbox_input);
|
assert!(!app.ignore_special_keys_for_textbox_input);
|
||||||
assert!(!app
|
assert!(
|
||||||
.data
|
!app
|
||||||
.radarr_data
|
.data
|
||||||
.edit_indexer_modal
|
.radarr_data
|
||||||
.as_ref()
|
.edit_indexer_modal
|
||||||
.unwrap()
|
.as_ref()
|
||||||
.api_key
|
.unwrap()
|
||||||
.text
|
.api_key
|
||||||
.is_empty());
|
.text
|
||||||
assert_eq!(
|
.is_empty()
|
||||||
app.get_current_route(),
|
|
||||||
ActiveRadarrBlock::EditIndexerPrompt.into()
|
|
||||||
);
|
);
|
||||||
|
assert_navigation_popped!(app, ActiveRadarrBlock::EditIndexerPrompt.into());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -1319,19 +1329,18 @@ mod tests {
|
|||||||
.handle();
|
.handle();
|
||||||
|
|
||||||
assert!(!app.ignore_special_keys_for_textbox_input);
|
assert!(!app.ignore_special_keys_for_textbox_input);
|
||||||
assert!(!app
|
assert!(
|
||||||
.data
|
!app
|
||||||
.radarr_data
|
.data
|
||||||
.edit_indexer_modal
|
.radarr_data
|
||||||
.as_ref()
|
.edit_indexer_modal
|
||||||
.unwrap()
|
.as_ref()
|
||||||
.seed_ratio
|
.unwrap()
|
||||||
.text
|
.seed_ratio
|
||||||
.is_empty());
|
.text
|
||||||
assert_eq!(
|
.is_empty()
|
||||||
app.get_current_route(),
|
|
||||||
ActiveRadarrBlock::EditIndexerPrompt.into()
|
|
||||||
);
|
);
|
||||||
|
assert_navigation_popped!(app, ActiveRadarrBlock::EditIndexerPrompt.into());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -1355,25 +1364,25 @@ mod tests {
|
|||||||
.handle();
|
.handle();
|
||||||
|
|
||||||
assert!(!app.ignore_special_keys_for_textbox_input);
|
assert!(!app.ignore_special_keys_for_textbox_input);
|
||||||
assert!(!app
|
assert!(
|
||||||
.data
|
!app
|
||||||
.radarr_data
|
.data
|
||||||
.edit_indexer_modal
|
.radarr_data
|
||||||
.as_ref()
|
.edit_indexer_modal
|
||||||
.unwrap()
|
.as_ref()
|
||||||
.tags
|
.unwrap()
|
||||||
.text
|
.tags
|
||||||
.is_empty());
|
.text
|
||||||
assert_eq!(
|
.is_empty()
|
||||||
app.get_current_route(),
|
|
||||||
ActiveRadarrBlock::EditIndexerPrompt.into()
|
|
||||||
);
|
);
|
||||||
|
assert_navigation_popped!(app, ActiveRadarrBlock::EditIndexerPrompt.into());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mod test_handle_esc {
|
mod test_handle_esc {
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::app::App;
|
use crate::app::App;
|
||||||
|
use crate::assert_navigation_popped;
|
||||||
use crate::event::Key;
|
use crate::event::Key;
|
||||||
use crate::models::servarr_data::modals::EditIndexerModal;
|
use crate::models::servarr_data::modals::EditIndexerModal;
|
||||||
use pretty_assertions::assert_eq;
|
use pretty_assertions::assert_eq;
|
||||||
@@ -1397,9 +1406,9 @@ mod tests {
|
|||||||
)
|
)
|
||||||
.handle();
|
.handle();
|
||||||
|
|
||||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Indexers.into());
|
assert_navigation_popped!(app, ActiveRadarrBlock::Indexers.into());
|
||||||
assert!(!app.data.radarr_data.prompt_confirm);
|
assert!(!app.data.radarr_data.prompt_confirm);
|
||||||
assert_eq!(app.data.radarr_data.edit_indexer_modal, None);
|
assert_none!(app.data.radarr_data.edit_indexer_modal);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[rstest]
|
#[rstest]
|
||||||
@@ -1422,7 +1431,7 @@ mod tests {
|
|||||||
|
|
||||||
EditIndexerHandler::new(ESC_KEY, &mut app, active_radarr_block, None).handle();
|
EditIndexerHandler::new(ESC_KEY, &mut app, active_radarr_block, None).handle();
|
||||||
|
|
||||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Indexers.into());
|
assert_navigation_popped!(app, ActiveRadarrBlock::Indexers.into());
|
||||||
assert!(!app.ignore_special_keys_for_textbox_input);
|
assert!(!app.ignore_special_keys_for_textbox_input);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
app.data.radarr_data.edit_indexer_modal,
|
app.data.radarr_data.edit_indexer_modal,
|
||||||
@@ -1432,15 +1441,15 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
mod test_handle_key_char {
|
mod test_handle_key_char {
|
||||||
|
use super::*;
|
||||||
use crate::app::App;
|
use crate::app::App;
|
||||||
|
use crate::assert_navigation_popped;
|
||||||
|
use crate::models::BlockSelectionState;
|
||||||
use crate::models::servarr_data::modals::EditIndexerModal;
|
use crate::models::servarr_data::modals::EditIndexerModal;
|
||||||
use crate::models::servarr_data::radarr::radarr_data::EDIT_INDEXER_TORRENT_SELECTION_BLOCKS;
|
use crate::models::servarr_data::radarr::radarr_data::EDIT_INDEXER_TORRENT_SELECTION_BLOCKS;
|
||||||
use crate::models::BlockSelectionState;
|
|
||||||
use crate::network::radarr_network::RadarrEvent;
|
use crate::network::radarr_network::RadarrEvent;
|
||||||
use pretty_assertions::{assert_eq, assert_str_eq};
|
use pretty_assertions::{assert_eq, assert_str_eq};
|
||||||
|
|
||||||
use super::*;
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_edit_indexer_name_input_backspace() {
|
fn test_edit_indexer_name_input_backspace() {
|
||||||
let mut app = App::test_default();
|
let mut app = App::test_default();
|
||||||
@@ -1773,8 +1782,8 @@ mod tests {
|
|||||||
)
|
)
|
||||||
.handle();
|
.handle();
|
||||||
|
|
||||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Indexers.into());
|
assert_navigation_popped!(app, ActiveRadarrBlock::Indexers.into());
|
||||||
assert!(app.data.radarr_data.edit_indexer_modal.is_none());
|
assert_modal_absent!(app.data.radarr_data.edit_indexer_modal);
|
||||||
assert!(app.should_refresh);
|
assert!(app.should_refresh);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
app.data.radarr_data.prompt_confirm_action,
|
app.data.radarr_data.prompt_confirm_action,
|
||||||
@@ -1852,7 +1861,7 @@ mod tests {
|
|||||||
.build_edit_indexer_params();
|
.build_edit_indexer_params();
|
||||||
|
|
||||||
assert_eq!(edit_indexer_params, expected_edit_indexer_params);
|
assert_eq!(edit_indexer_params, expected_edit_indexer_params);
|
||||||
assert!(app.data.radarr_data.edit_indexer_modal.is_none());
|
assert_modal_absent!(app.data.radarr_data.edit_indexer_modal);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
use crate::app::App;
|
use crate::app::App;
|
||||||
use crate::event::Key;
|
use crate::event::Key;
|
||||||
use crate::handlers::{handle_prompt_toggle, KeyEventHandler};
|
use crate::handlers::{KeyEventHandler, handle_prompt_toggle};
|
||||||
use crate::models::radarr_models::IndexerSettings;
|
use crate::models::radarr_models::IndexerSettings;
|
||||||
use crate::models::servarr_data::radarr::radarr_data::{
|
use crate::models::servarr_data::radarr::radarr_data::{
|
||||||
ActiveRadarrBlock, INDEXER_SETTINGS_BLOCKS,
|
ActiveRadarrBlock, INDEXER_SETTINGS_BLOCKS,
|
||||||
@@ -288,4 +288,12 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for IndexerSettingsHandl
|
|||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn app_mut(&mut self) -> &mut App<'b> {
|
||||||
|
self.app
|
||||||
|
}
|
||||||
|
|
||||||
|
fn current_route(&self) -> crate::models::Route {
|
||||||
|
self.app.get_current_route()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,12 +4,14 @@ mod tests {
|
|||||||
use rstest::rstest;
|
use rstest::rstest;
|
||||||
use strum::IntoEnumIterator;
|
use strum::IntoEnumIterator;
|
||||||
|
|
||||||
use crate::app::key_binding::DEFAULT_KEYBINDINGS;
|
|
||||||
use crate::app::App;
|
use crate::app::App;
|
||||||
|
use crate::app::key_binding::DEFAULT_KEYBINDINGS;
|
||||||
|
use crate::assert_modal_absent;
|
||||||
|
use crate::assert_navigation_pushed;
|
||||||
use crate::event::Key;
|
use crate::event::Key;
|
||||||
|
use crate::handlers::KeyEventHandler;
|
||||||
use crate::handlers::radarr_handlers::indexers::edit_indexer_settings_handler::IndexerSettingsHandler;
|
use crate::handlers::radarr_handlers::indexers::edit_indexer_settings_handler::IndexerSettingsHandler;
|
||||||
use crate::handlers::radarr_handlers::radarr_handler_test_utils::utils::indexer_settings;
|
use crate::handlers::radarr_handlers::radarr_handler_test_utils::utils::indexer_settings;
|
||||||
use crate::handlers::KeyEventHandler;
|
|
||||||
use crate::models::radarr_models::IndexerSettings;
|
use crate::models::radarr_models::IndexerSettings;
|
||||||
use crate::models::servarr_data::radarr::radarr_data::{
|
use crate::models::servarr_data::radarr::radarr_data::{
|
||||||
ActiveRadarrBlock, INDEXER_SETTINGS_BLOCKS,
|
ActiveRadarrBlock, INDEXER_SETTINGS_BLOCKS,
|
||||||
@@ -19,9 +21,9 @@ mod tests {
|
|||||||
use pretty_assertions::assert_eq;
|
use pretty_assertions::assert_eq;
|
||||||
use rstest::rstest;
|
use rstest::rstest;
|
||||||
|
|
||||||
|
use crate::models::BlockSelectionState;
|
||||||
use crate::models::radarr_models::IndexerSettings;
|
use crate::models::radarr_models::IndexerSettings;
|
||||||
use crate::models::servarr_data::radarr::radarr_data::INDEXER_SETTINGS_SELECTION_BLOCKS;
|
use crate::models::servarr_data::radarr::radarr_data::INDEXER_SETTINGS_SELECTION_BLOCKS;
|
||||||
use crate::models::BlockSelectionState;
|
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
@@ -267,9 +269,9 @@ mod tests {
|
|||||||
mod test_handle_left_right_action {
|
mod test_handle_left_right_action {
|
||||||
use std::sync::atomic::Ordering;
|
use std::sync::atomic::Ordering;
|
||||||
|
|
||||||
|
use crate::models::BlockSelectionState;
|
||||||
use crate::models::radarr_models::IndexerSettings;
|
use crate::models::radarr_models::IndexerSettings;
|
||||||
use crate::models::servarr_data::radarr::radarr_data::INDEXER_SETTINGS_SELECTION_BLOCKS;
|
use crate::models::servarr_data::radarr::radarr_data::INDEXER_SETTINGS_SELECTION_BLOCKS;
|
||||||
use crate::models::BlockSelectionState;
|
|
||||||
use pretty_assertions::assert_eq;
|
use pretty_assertions::assert_eq;
|
||||||
use rstest::rstest;
|
use rstest::rstest;
|
||||||
|
|
||||||
@@ -424,9 +426,10 @@ mod tests {
|
|||||||
use rstest::rstest;
|
use rstest::rstest;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
|
assert_navigation_popped,
|
||||||
models::{
|
models::{
|
||||||
radarr_models::IndexerSettings,
|
BlockSelectionState, radarr_models::IndexerSettings,
|
||||||
servarr_data::radarr::radarr_data::INDEXER_SETTINGS_SELECTION_BLOCKS, BlockSelectionState,
|
servarr_data::radarr::radarr_data::INDEXER_SETTINGS_SELECTION_BLOCKS,
|
||||||
},
|
},
|
||||||
network::radarr_network::RadarrEvent,
|
network::radarr_network::RadarrEvent,
|
||||||
};
|
};
|
||||||
@@ -457,10 +460,10 @@ mod tests {
|
|||||||
)
|
)
|
||||||
.handle();
|
.handle();
|
||||||
|
|
||||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Indexers.into());
|
assert_navigation_popped!(app, ActiveRadarrBlock::Indexers.into());
|
||||||
assert_eq!(app.data.radarr_data.prompt_confirm_action, None);
|
assert_none!(app.data.radarr_data.prompt_confirm_action);
|
||||||
assert!(!app.should_refresh);
|
assert!(!app.should_refresh);
|
||||||
assert_eq!(app.data.radarr_data.indexer_settings, None);
|
assert_none!(app.data.radarr_data.indexer_settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -486,12 +489,12 @@ mod tests {
|
|||||||
)
|
)
|
||||||
.handle();
|
.handle();
|
||||||
|
|
||||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Indexers.into());
|
assert_navigation_popped!(app, ActiveRadarrBlock::Indexers.into());
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
app.data.radarr_data.prompt_confirm_action,
|
app.data.radarr_data.prompt_confirm_action,
|
||||||
Some(RadarrEvent::EditAllIndexerSettings(indexer_settings()))
|
Some(RadarrEvent::EditAllIndexerSettings(indexer_settings()))
|
||||||
);
|
);
|
||||||
assert!(app.data.radarr_data.indexer_settings.is_none());
|
assert_modal_absent!(app.data.radarr_data.indexer_settings);
|
||||||
assert!(app.should_refresh);
|
assert!(app.should_refresh);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -549,7 +552,7 @@ mod tests {
|
|||||||
)
|
)
|
||||||
.handle();
|
.handle();
|
||||||
|
|
||||||
assert_eq!(app.get_current_route(), selected_block.into());
|
assert_navigation_pushed!(app, selected_block.into());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[rstest]
|
#[rstest]
|
||||||
@@ -599,8 +602,8 @@ mod tests {
|
|||||||
)
|
)
|
||||||
.handle();
|
.handle();
|
||||||
|
|
||||||
assert_eq!(
|
assert_navigation_pushed!(
|
||||||
app.get_current_route(),
|
app,
|
||||||
ActiveRadarrBlock::IndexerSettingsWhitelistedSubtitleTagsInput.into()
|
ActiveRadarrBlock::IndexerSettingsWhitelistedSubtitleTagsInput.into()
|
||||||
);
|
);
|
||||||
assert!(app.ignore_special_keys_for_textbox_input);
|
assert!(app.ignore_special_keys_for_textbox_input);
|
||||||
@@ -736,19 +739,18 @@ mod tests {
|
|||||||
.handle();
|
.handle();
|
||||||
|
|
||||||
assert!(!app.ignore_special_keys_for_textbox_input);
|
assert!(!app.ignore_special_keys_for_textbox_input);
|
||||||
assert!(!app
|
assert!(
|
||||||
.data
|
!app
|
||||||
.radarr_data
|
.data
|
||||||
.indexer_settings
|
.radarr_data
|
||||||
.as_ref()
|
.indexer_settings
|
||||||
.unwrap()
|
.as_ref()
|
||||||
.whitelisted_hardcoded_subs
|
.unwrap()
|
||||||
.text
|
.whitelisted_hardcoded_subs
|
||||||
.is_empty());
|
.text
|
||||||
assert_eq!(
|
.is_empty()
|
||||||
app.get_current_route(),
|
|
||||||
ActiveRadarrBlock::AllIndexerSettingsPrompt.into()
|
|
||||||
);
|
);
|
||||||
|
assert_navigation_popped!(app, ActiveRadarrBlock::AllIndexerSettingsPrompt.into());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[rstest]
|
#[rstest]
|
||||||
@@ -769,20 +771,17 @@ mod tests {
|
|||||||
|
|
||||||
IndexerSettingsHandler::new(SUBMIT_KEY, &mut app, active_radarr_block, None).handle();
|
IndexerSettingsHandler::new(SUBMIT_KEY, &mut app, active_radarr_block, None).handle();
|
||||||
|
|
||||||
assert_eq!(
|
assert_navigation_popped!(app, ActiveRadarrBlock::AllIndexerSettingsPrompt.into());
|
||||||
app.get_current_route(),
|
|
||||||
ActiveRadarrBlock::AllIndexerSettingsPrompt.into()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mod test_handle_esc {
|
mod test_handle_esc {
|
||||||
use pretty_assertions::assert_eq;
|
|
||||||
use rstest::rstest;
|
use rstest::rstest;
|
||||||
|
|
||||||
use crate::models::radarr_models::IndexerSettings;
|
use crate::models::radarr_models::IndexerSettings;
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
use crate::assert_navigation_popped;
|
||||||
|
|
||||||
const ESC_KEY: Key = DEFAULT_KEYBINDINGS.esc.key;
|
const ESC_KEY: Key = DEFAULT_KEYBINDINGS.esc.key;
|
||||||
|
|
||||||
@@ -802,9 +801,9 @@ mod tests {
|
|||||||
)
|
)
|
||||||
.handle();
|
.handle();
|
||||||
|
|
||||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Indexers.into());
|
assert_navigation_popped!(app, ActiveRadarrBlock::Indexers.into());
|
||||||
assert!(!app.data.radarr_data.prompt_confirm);
|
assert!(!app.data.radarr_data.prompt_confirm);
|
||||||
assert_eq!(app.data.radarr_data.indexer_settings, None);
|
assert_none!(app.data.radarr_data.indexer_settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -825,11 +824,11 @@ mod tests {
|
|||||||
)
|
)
|
||||||
.handle();
|
.handle();
|
||||||
|
|
||||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Indexers.into());
|
assert_navigation_popped!(app, ActiveRadarrBlock::Indexers.into());
|
||||||
assert!(!app.ignore_special_keys_for_textbox_input);
|
assert!(!app.ignore_special_keys_for_textbox_input);
|
||||||
assert_eq!(
|
assert_some_eq_x!(
|
||||||
app.data.radarr_data.indexer_settings,
|
&app.data.radarr_data.indexer_settings,
|
||||||
Some(IndexerSettings::default())
|
&IndexerSettings::default()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -852,21 +851,22 @@ mod tests {
|
|||||||
|
|
||||||
IndexerSettingsHandler::new(ESC_KEY, &mut app, active_radarr_block, None).handle();
|
IndexerSettingsHandler::new(ESC_KEY, &mut app, active_radarr_block, None).handle();
|
||||||
|
|
||||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Indexers.into());
|
assert_navigation_popped!(app, ActiveRadarrBlock::Indexers.into());
|
||||||
assert_eq!(
|
assert_some_eq_x!(
|
||||||
app.data.radarr_data.indexer_settings,
|
&app.data.radarr_data.indexer_settings,
|
||||||
Some(IndexerSettings::default())
|
&IndexerSettings::default()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mod test_handle_key_char {
|
mod test_handle_key_char {
|
||||||
use pretty_assertions::{assert_eq, assert_str_eq};
|
use pretty_assertions::assert_str_eq;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
|
assert_navigation_popped,
|
||||||
models::{
|
models::{
|
||||||
radarr_models::IndexerSettings,
|
BlockSelectionState, radarr_models::IndexerSettings,
|
||||||
servarr_data::radarr::radarr_data::INDEXER_SETTINGS_SELECTION_BLOCKS, BlockSelectionState,
|
servarr_data::radarr::radarr_data::INDEXER_SETTINGS_SELECTION_BLOCKS,
|
||||||
},
|
},
|
||||||
network::radarr_network::RadarrEvent,
|
network::radarr_network::RadarrEvent,
|
||||||
};
|
};
|
||||||
@@ -950,12 +950,12 @@ mod tests {
|
|||||||
)
|
)
|
||||||
.handle();
|
.handle();
|
||||||
|
|
||||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Indexers.into());
|
assert_navigation_popped!(app, ActiveRadarrBlock::Indexers.into());
|
||||||
assert_eq!(
|
assert_some_eq_x!(
|
||||||
app.data.radarr_data.prompt_confirm_action,
|
&app.data.radarr_data.prompt_confirm_action,
|
||||||
Some(RadarrEvent::EditAllIndexerSettings(indexer_settings()))
|
&RadarrEvent::EditAllIndexerSettings(indexer_settings())
|
||||||
);
|
);
|
||||||
assert!(app.data.radarr_data.indexer_settings.is_none());
|
assert_modal_absent!(app.data.radarr_data.indexer_settings);
|
||||||
assert!(app.should_refresh);
|
assert!(app.should_refresh);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1004,7 +1004,7 @@ mod tests {
|
|||||||
.build_edit_indexer_settings_body();
|
.build_edit_indexer_settings_body();
|
||||||
|
|
||||||
assert_eq!(body, indexer_settings());
|
assert_eq!(body, indexer_settings());
|
||||||
assert!(app.data.radarr_data.indexer_settings.is_none());
|
assert_modal_absent!(app.data.radarr_data.indexer_settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|||||||
@@ -4,14 +4,15 @@ mod tests {
|
|||||||
use rstest::rstest;
|
use rstest::rstest;
|
||||||
use strum::IntoEnumIterator;
|
use strum::IntoEnumIterator;
|
||||||
|
|
||||||
use crate::app::key_binding::DEFAULT_KEYBINDINGS;
|
|
||||||
use crate::app::App;
|
use crate::app::App;
|
||||||
|
use crate::app::key_binding::DEFAULT_KEYBINDINGS;
|
||||||
|
use crate::assert_navigation_pushed;
|
||||||
use crate::event::Key;
|
use crate::event::Key;
|
||||||
|
use crate::handlers::KeyEventHandler;
|
||||||
use crate::handlers::radarr_handlers::indexers::IndexersHandler;
|
use crate::handlers::radarr_handlers::indexers::IndexersHandler;
|
||||||
use crate::handlers::radarr_handlers::radarr_handler_test_utils::utils::indexer;
|
use crate::handlers::radarr_handlers::radarr_handler_test_utils::utils::indexer;
|
||||||
use crate::handlers::KeyEventHandler;
|
|
||||||
use crate::models::servarr_data::radarr::radarr_data::{
|
use crate::models::servarr_data::radarr::radarr_data::{
|
||||||
ActiveRadarrBlock, EDIT_INDEXER_BLOCKS, INDEXERS_BLOCKS, INDEXER_SETTINGS_BLOCKS,
|
ActiveRadarrBlock, EDIT_INDEXER_BLOCKS, INDEXER_SETTINGS_BLOCKS, INDEXERS_BLOCKS,
|
||||||
};
|
};
|
||||||
use crate::models::servarr_models::Indexer;
|
use crate::models::servarr_models::Indexer;
|
||||||
use crate::test_handler_delegation;
|
use crate::test_handler_delegation;
|
||||||
@@ -34,10 +35,7 @@ mod tests {
|
|||||||
|
|
||||||
IndexersHandler::new(DELETE_KEY, &mut app, ActiveRadarrBlock::Indexers, None).handle();
|
IndexersHandler::new(DELETE_KEY, &mut app, ActiveRadarrBlock::Indexers, None).handle();
|
||||||
|
|
||||||
assert_eq!(
|
assert_navigation_pushed!(app, ActiveRadarrBlock::DeleteIndexerPrompt.into());
|
||||||
app.get_current_route(),
|
|
||||||
ActiveRadarrBlock::DeleteIndexerPrompt.into()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -81,10 +79,7 @@ mod tests {
|
|||||||
app.data.radarr_data.main_tabs.get_active_route(),
|
app.data.radarr_data.main_tabs.get_active_route(),
|
||||||
ActiveRadarrBlock::RootFolders.into()
|
ActiveRadarrBlock::RootFolders.into()
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_navigation_pushed!(app, ActiveRadarrBlock::RootFolders.into());
|
||||||
app.get_current_route(),
|
|
||||||
ActiveRadarrBlock::RootFolders.into()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[rstest]
|
#[rstest]
|
||||||
@@ -105,7 +100,7 @@ mod tests {
|
|||||||
app.data.radarr_data.main_tabs.get_active_route(),
|
app.data.radarr_data.main_tabs.get_active_route(),
|
||||||
ActiveRadarrBlock::System.into()
|
ActiveRadarrBlock::System.into()
|
||||||
);
|
);
|
||||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::System.into());
|
assert_navigation_pushed!(app, ActiveRadarrBlock::System.into());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[rstest]
|
#[rstest]
|
||||||
@@ -125,10 +120,12 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
mod test_handle_submit {
|
mod test_handle_submit {
|
||||||
|
use super::*;
|
||||||
|
use crate::assert_navigation_popped;
|
||||||
use crate::handlers::radarr_handlers::radarr_handler_test_utils::utils::indexer;
|
use crate::handlers::radarr_handlers::radarr_handler_test_utils::utils::indexer;
|
||||||
use crate::models::servarr_data::modals::EditIndexerModal;
|
use crate::models::servarr_data::modals::EditIndexerModal;
|
||||||
use crate::models::servarr_data::radarr::radarr_data::{
|
use crate::models::servarr_data::radarr::radarr_data::{
|
||||||
RadarrData, EDIT_INDEXER_NZB_SELECTION_BLOCKS, EDIT_INDEXER_TORRENT_SELECTION_BLOCKS,
|
EDIT_INDEXER_NZB_SELECTION_BLOCKS, EDIT_INDEXER_TORRENT_SELECTION_BLOCKS, RadarrData,
|
||||||
};
|
};
|
||||||
use crate::models::servarr_models::{Indexer, IndexerField};
|
use crate::models::servarr_models::{Indexer, IndexerField};
|
||||||
use crate::network::radarr_network::RadarrEvent;
|
use crate::network::radarr_network::RadarrEvent;
|
||||||
@@ -136,8 +133,6 @@ mod tests {
|
|||||||
use pretty_assertions::assert_eq;
|
use pretty_assertions::assert_eq;
|
||||||
use serde_json::{Number, Value};
|
use serde_json::{Number, Value};
|
||||||
|
|
||||||
use super::*;
|
|
||||||
|
|
||||||
const SUBMIT_KEY: Key = DEFAULT_KEYBINDINGS.submit.key;
|
const SUBMIT_KEY: Key = DEFAULT_KEYBINDINGS.submit.key;
|
||||||
|
|
||||||
#[rstest]
|
#[rstest]
|
||||||
@@ -196,17 +191,14 @@ mod tests {
|
|||||||
|
|
||||||
IndexersHandler::new(SUBMIT_KEY, &mut app, ActiveRadarrBlock::Indexers, None).handle();
|
IndexersHandler::new(SUBMIT_KEY, &mut app, ActiveRadarrBlock::Indexers, None).handle();
|
||||||
|
|
||||||
assert_eq!(
|
assert_navigation_pushed!(app, ActiveRadarrBlock::EditIndexerPrompt.into());
|
||||||
app.get_current_route(),
|
assert_some_eq_x!(
|
||||||
ActiveRadarrBlock::EditIndexerPrompt.into()
|
&app.data.radarr_data.edit_indexer_modal,
|
||||||
|
&EditIndexerModal::from(&app.data.radarr_data)
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_some_eq_x!(
|
||||||
app.data.radarr_data.edit_indexer_modal,
|
&app.data.radarr_data.edit_indexer_modal,
|
||||||
Some((&app.data.radarr_data).into())
|
&expected_edit_indexer_modal
|
||||||
);
|
|
||||||
assert_eq!(
|
|
||||||
app.data.radarr_data.edit_indexer_modal,
|
|
||||||
Some(expected_edit_indexer_modal)
|
|
||||||
);
|
);
|
||||||
if torrent_protocol {
|
if torrent_protocol {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
@@ -235,7 +227,7 @@ mod tests {
|
|||||||
IndexersHandler::new(SUBMIT_KEY, &mut app, ActiveRadarrBlock::Indexers, None).handle();
|
IndexersHandler::new(SUBMIT_KEY, &mut app, ActiveRadarrBlock::Indexers, None).handle();
|
||||||
|
|
||||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Indexers.into());
|
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Indexers.into());
|
||||||
assert_eq!(app.data.radarr_data.edit_indexer_modal, None);
|
assert_none!(app.data.radarr_data.edit_indexer_modal);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -255,11 +247,11 @@ mod tests {
|
|||||||
.handle();
|
.handle();
|
||||||
|
|
||||||
assert!(app.data.radarr_data.prompt_confirm);
|
assert!(app.data.radarr_data.prompt_confirm);
|
||||||
assert_eq!(
|
assert_some_eq_x!(
|
||||||
app.data.radarr_data.prompt_confirm_action,
|
&app.data.radarr_data.prompt_confirm_action,
|
||||||
Some(RadarrEvent::DeleteIndexer(1))
|
&RadarrEvent::DeleteIndexer(1)
|
||||||
);
|
);
|
||||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Indexers.into());
|
assert_navigation_popped!(app, ActiveRadarrBlock::Indexers.into());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -282,15 +274,14 @@ mod tests {
|
|||||||
.handle();
|
.handle();
|
||||||
|
|
||||||
assert!(!app.data.radarr_data.prompt_confirm);
|
assert!(!app.data.radarr_data.prompt_confirm);
|
||||||
assert_eq!(app.data.radarr_data.prompt_confirm_action, None);
|
assert_none!(app.data.radarr_data.prompt_confirm_action);
|
||||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Indexers.into());
|
assert_navigation_popped!(app, ActiveRadarrBlock::Indexers.into());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mod test_handle_esc {
|
mod test_handle_esc {
|
||||||
use pretty_assertions::assert_eq;
|
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
use crate::assert_navigation_popped;
|
||||||
|
|
||||||
const ESC_KEY: Key = DEFAULT_KEYBINDINGS.esc.key;
|
const ESC_KEY: Key = DEFAULT_KEYBINDINGS.esc.key;
|
||||||
|
|
||||||
@@ -310,7 +301,7 @@ mod tests {
|
|||||||
)
|
)
|
||||||
.handle();
|
.handle();
|
||||||
|
|
||||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Indexers.into());
|
assert_navigation_popped!(app, ActiveRadarrBlock::Indexers.into());
|
||||||
assert!(!app.data.radarr_data.prompt_confirm);
|
assert!(!app.data.radarr_data.prompt_confirm);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -324,8 +315,8 @@ mod tests {
|
|||||||
|
|
||||||
IndexersHandler::new(ESC_KEY, &mut app, ActiveRadarrBlock::TestIndexer, None).handle();
|
IndexersHandler::new(ESC_KEY, &mut app, ActiveRadarrBlock::TestIndexer, None).handle();
|
||||||
|
|
||||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Indexers.into());
|
assert_navigation_popped!(app, ActiveRadarrBlock::Indexers.into());
|
||||||
assert_eq!(app.data.radarr_data.indexer_test_errors, None);
|
assert_none!(app.data.radarr_data.indexer_test_errors);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[rstest]
|
#[rstest]
|
||||||
@@ -338,8 +329,8 @@ mod tests {
|
|||||||
|
|
||||||
IndexersHandler::new(ESC_KEY, &mut app, ActiveRadarrBlock::Indexers, None).handle();
|
IndexersHandler::new(ESC_KEY, &mut app, ActiveRadarrBlock::Indexers, None).handle();
|
||||||
|
|
||||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Indexers.into());
|
assert_navigation_popped!(app, ActiveRadarrBlock::Indexers.into());
|
||||||
assert!(app.error.text.is_empty());
|
assert_is_empty!(app.error.text);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -349,6 +340,7 @@ mod tests {
|
|||||||
use super::*;
|
use super::*;
|
||||||
use crate::handlers::radarr_handlers::radarr_handler_test_utils::utils::indexer;
|
use crate::handlers::radarr_handlers::radarr_handler_test_utils::utils::indexer;
|
||||||
use crate::{
|
use crate::{
|
||||||
|
assert_navigation_popped,
|
||||||
models::servarr_data::radarr::radarr_data::INDEXER_SETTINGS_SELECTION_BLOCKS,
|
models::servarr_data::radarr::radarr_data::INDEXER_SETTINGS_SELECTION_BLOCKS,
|
||||||
network::radarr_network::RadarrEvent,
|
network::radarr_network::RadarrEvent,
|
||||||
};
|
};
|
||||||
@@ -371,7 +363,7 @@ mod tests {
|
|||||||
)
|
)
|
||||||
.handle();
|
.handle();
|
||||||
|
|
||||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Indexers.into());
|
assert_navigation_pushed!(app, ActiveRadarrBlock::Indexers.into());
|
||||||
assert!(app.should_refresh);
|
assert!(app.should_refresh);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -415,10 +407,7 @@ mod tests {
|
|||||||
)
|
)
|
||||||
.handle();
|
.handle();
|
||||||
|
|
||||||
assert_eq!(
|
assert_navigation_pushed!(app, ActiveRadarrBlock::AllIndexerSettingsPrompt.into());
|
||||||
app.get_current_route(),
|
|
||||||
ActiveRadarrBlock::AllIndexerSettingsPrompt.into()
|
|
||||||
);
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
app.data.radarr_data.selected_block.blocks,
|
app.data.radarr_data.selected_block.blocks,
|
||||||
INDEXER_SETTINGS_SELECTION_BLOCKS
|
INDEXER_SETTINGS_SELECTION_BLOCKS
|
||||||
@@ -464,10 +453,7 @@ mod tests {
|
|||||||
)
|
)
|
||||||
.handle();
|
.handle();
|
||||||
|
|
||||||
assert_eq!(
|
assert_navigation_pushed!(app, ActiveRadarrBlock::TestIndexer.into());
|
||||||
app.get_current_route(),
|
|
||||||
ActiveRadarrBlock::TestIndexer.into()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -509,10 +495,7 @@ mod tests {
|
|||||||
)
|
)
|
||||||
.handle();
|
.handle();
|
||||||
|
|
||||||
assert_eq!(
|
assert_navigation_pushed!(app, ActiveRadarrBlock::TestAllIndexers.into());
|
||||||
app.get_current_route(),
|
|
||||||
ActiveRadarrBlock::TestAllIndexers.into()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -553,11 +536,11 @@ mod tests {
|
|||||||
.handle();
|
.handle();
|
||||||
|
|
||||||
assert!(app.data.radarr_data.prompt_confirm);
|
assert!(app.data.radarr_data.prompt_confirm);
|
||||||
assert_eq!(
|
assert_some_eq_x!(
|
||||||
app.data.radarr_data.prompt_confirm_action,
|
&app.data.radarr_data.prompt_confirm_action,
|
||||||
Some(RadarrEvent::DeleteIndexer(1))
|
&RadarrEvent::DeleteIndexer(1)
|
||||||
);
|
);
|
||||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Indexers.into());
|
assert_navigation_popped!(app, ActiveRadarrBlock::Indexers.into());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,16 +4,15 @@ use crate::handlers::radarr_handlers::handle_change_tab_left_right_keys;
|
|||||||
use crate::handlers::radarr_handlers::indexers::edit_indexer_handler::EditIndexerHandler;
|
use crate::handlers::radarr_handlers::indexers::edit_indexer_handler::EditIndexerHandler;
|
||||||
use crate::handlers::radarr_handlers::indexers::edit_indexer_settings_handler::IndexerSettingsHandler;
|
use crate::handlers::radarr_handlers::indexers::edit_indexer_settings_handler::IndexerSettingsHandler;
|
||||||
use crate::handlers::radarr_handlers::indexers::test_all_indexers_handler::TestAllIndexersHandler;
|
use crate::handlers::radarr_handlers::indexers::test_all_indexers_handler::TestAllIndexersHandler;
|
||||||
use crate::handlers::table_handler::TableHandlingConfig;
|
use crate::handlers::table_handler::{TableHandlingConfig, handle_table};
|
||||||
use crate::handlers::{handle_clear_errors, handle_prompt_toggle, KeyEventHandler};
|
use crate::handlers::{KeyEventHandler, handle_clear_errors, handle_prompt_toggle};
|
||||||
|
use crate::matches_key;
|
||||||
|
use crate::models::BlockSelectionState;
|
||||||
use crate::models::servarr_data::radarr::radarr_data::{
|
use crate::models::servarr_data::radarr::radarr_data::{
|
||||||
ActiveRadarrBlock, EDIT_INDEXER_NZB_SELECTION_BLOCKS, EDIT_INDEXER_TORRENT_SELECTION_BLOCKS,
|
ActiveRadarrBlock, EDIT_INDEXER_NZB_SELECTION_BLOCKS, EDIT_INDEXER_TORRENT_SELECTION_BLOCKS,
|
||||||
INDEXERS_BLOCKS, INDEXER_SETTINGS_SELECTION_BLOCKS,
|
INDEXER_SETTINGS_SELECTION_BLOCKS, INDEXERS_BLOCKS,
|
||||||
};
|
};
|
||||||
use crate::models::servarr_models::Indexer;
|
|
||||||
use crate::models::BlockSelectionState;
|
|
||||||
use crate::network::radarr_network::RadarrEvent;
|
use crate::network::radarr_network::RadarrEvent;
|
||||||
use crate::{handle_table_events, matches_key};
|
|
||||||
|
|
||||||
mod edit_indexer_handler;
|
mod edit_indexer_handler;
|
||||||
mod edit_indexer_settings_handler;
|
mod edit_indexer_settings_handler;
|
||||||
@@ -31,8 +30,6 @@ pub(super) struct IndexersHandler<'a, 'b> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl IndexersHandler<'_, '_> {
|
impl IndexersHandler<'_, '_> {
|
||||||
handle_table_events!(self, indexers, self.app.data.radarr_data.indexers, Indexer);
|
|
||||||
|
|
||||||
fn extract_indexer_id(&self) -> i64 {
|
fn extract_indexer_id(&self) -> i64 {
|
||||||
self.app.data.radarr_data.indexers.current_selection().id
|
self.app.data.radarr_data.indexers.current_selection().id
|
||||||
}
|
}
|
||||||
@@ -43,7 +40,11 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for IndexersHandler<'a,
|
|||||||
let indexer_table_handling_config =
|
let indexer_table_handling_config =
|
||||||
TableHandlingConfig::new(ActiveRadarrBlock::Indexers.into());
|
TableHandlingConfig::new(ActiveRadarrBlock::Indexers.into());
|
||||||
|
|
||||||
if !self.handle_indexers_table_events(indexer_table_handling_config) {
|
if !handle_table(
|
||||||
|
self,
|
||||||
|
|app| &mut app.data.radarr_data.indexers,
|
||||||
|
indexer_table_handling_config,
|
||||||
|
) {
|
||||||
match self.active_radarr_block {
|
match self.active_radarr_block {
|
||||||
_ if EditIndexerHandler::accepts(self.active_radarr_block) => {
|
_ if EditIndexerHandler::accepts(self.active_radarr_block) => {
|
||||||
EditIndexerHandler::new(self.key, self.app, self.active_radarr_block, self.context)
|
EditIndexerHandler::new(self.key, self.app, self.active_radarr_block, self.context)
|
||||||
@@ -206,4 +207,12 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for IndexersHandler<'a,
|
|||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn app_mut(&mut self) -> &mut App<'b> {
|
||||||
|
self.app
|
||||||
|
}
|
||||||
|
|
||||||
|
fn current_route(&self) -> crate::models::Route {
|
||||||
|
self.app.get_current_route()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
use crate::app::App;
|
use crate::app::App;
|
||||||
use crate::event::Key;
|
use crate::event::Key;
|
||||||
use crate::handle_table_events;
|
|
||||||
use crate::handlers::table_handler::TableHandlingConfig;
|
|
||||||
use crate::handlers::KeyEventHandler;
|
use crate::handlers::KeyEventHandler;
|
||||||
use crate::models::servarr_data::modals::IndexerTestResultModalItem;
|
use crate::handlers::table_handler::{TableHandlingConfig, handle_table};
|
||||||
use crate::models::servarr_data::radarr::radarr_data::ActiveRadarrBlock;
|
use crate::models::servarr_data::radarr::radarr_data::ActiveRadarrBlock;
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
@@ -17,27 +15,23 @@ pub(super) struct TestAllIndexersHandler<'a, 'b> {
|
|||||||
_context: Option<ActiveRadarrBlock>,
|
_context: Option<ActiveRadarrBlock>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TestAllIndexersHandler<'_, '_> {
|
impl TestAllIndexersHandler<'_, '_> {}
|
||||||
handle_table_events!(
|
|
||||||
self,
|
|
||||||
indexer_test_all_results,
|
|
||||||
self
|
|
||||||
.app
|
|
||||||
.data
|
|
||||||
.radarr_data
|
|
||||||
.indexer_test_all_results
|
|
||||||
.as_mut()
|
|
||||||
.unwrap(),
|
|
||||||
IndexerTestResultModalItem
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for TestAllIndexersHandler<'a, 'b> {
|
impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for TestAllIndexersHandler<'a, 'b> {
|
||||||
fn handle(&mut self) {
|
fn handle(&mut self) {
|
||||||
let test_all_indexers_test_results_table_handler_config =
|
let test_all_indexers_test_results_table_handler_config =
|
||||||
TableHandlingConfig::new(ActiveRadarrBlock::TestAllIndexers.into());
|
TableHandlingConfig::new(ActiveRadarrBlock::TestAllIndexers.into());
|
||||||
|
|
||||||
if !self.handle_indexer_test_all_results_table_events(
|
if !handle_table(
|
||||||
|
self,
|
||||||
|
|app| {
|
||||||
|
app
|
||||||
|
.data
|
||||||
|
.radarr_data
|
||||||
|
.indexer_test_all_results
|
||||||
|
.as_mut()
|
||||||
|
.unwrap()
|
||||||
|
},
|
||||||
test_all_indexers_test_results_table_handler_config,
|
test_all_indexers_test_results_table_handler_config,
|
||||||
) {
|
) {
|
||||||
self.handle_key_event();
|
self.handle_key_event();
|
||||||
@@ -102,4 +96,12 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for TestAllIndexersHandl
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn handle_char_key_event(&mut self) {}
|
fn handle_char_key_event(&mut self) {}
|
||||||
|
|
||||||
|
fn app_mut(&mut self) -> &mut App<'b> {
|
||||||
|
self.app
|
||||||
|
}
|
||||||
|
|
||||||
|
fn current_route(&self) -> crate::models::Route {
|
||||||
|
self.app.get_current_route()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use crate::app::key_binding::DEFAULT_KEYBINDINGS;
|
|
||||||
use crate::app::App;
|
use crate::app::App;
|
||||||
use crate::handlers::radarr_handlers::indexers::test_all_indexers_handler::TestAllIndexersHandler;
|
use crate::app::key_binding::DEFAULT_KEYBINDINGS;
|
||||||
use crate::handlers::KeyEventHandler;
|
use crate::handlers::KeyEventHandler;
|
||||||
|
use crate::handlers::radarr_handlers::indexers::test_all_indexers_handler::TestAllIndexersHandler;
|
||||||
use crate::models::servarr_data::modals::IndexerTestResultModalItem;
|
use crate::models::servarr_data::modals::IndexerTestResultModalItem;
|
||||||
use crate::models::servarr_data::radarr::radarr_data::ActiveRadarrBlock;
|
use crate::models::servarr_data::radarr::radarr_data::ActiveRadarrBlock;
|
||||||
use crate::models::stateful_table::StatefulTable;
|
use crate::models::stateful_table::StatefulTable;
|
||||||
@@ -13,7 +13,7 @@ mod tests {
|
|||||||
mod test_handle_esc {
|
mod test_handle_esc {
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::models::stateful_table::StatefulTable;
|
use crate::models::stateful_table::StatefulTable;
|
||||||
use pretty_assertions::assert_eq;
|
use crate::{assert_modal_absent, assert_navigation_popped};
|
||||||
use rstest::rstest;
|
use rstest::rstest;
|
||||||
|
|
||||||
#[rstest]
|
#[rstest]
|
||||||
@@ -32,9 +32,9 @@ mod tests {
|
|||||||
)
|
)
|
||||||
.handle();
|
.handle();
|
||||||
|
|
||||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Indexers.into());
|
assert_navigation_popped!(app, ActiveRadarrBlock::Indexers.into());
|
||||||
assert!(!app.data.radarr_data.prompt_confirm);
|
assert!(!app.data.radarr_data.prompt_confirm);
|
||||||
assert!(app.data.radarr_data.indexer_test_all_results.is_none());
|
assert_modal_absent!(app.data.radarr_data.indexer_test_all_results);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,18 +1,15 @@
|
|||||||
use crate::handlers::table_handler::TableHandlingConfig;
|
use crate::handlers::table_handler::{TableHandlingConfig, handle_table};
|
||||||
use crate::handlers::{handle_prompt_toggle, KeyEventHandler};
|
use crate::handlers::{KeyEventHandler, handle_prompt_toggle};
|
||||||
use crate::models::radarr_models::{
|
use crate::models::radarr_models::{
|
||||||
AddMovieBody, AddMovieOptions, AddMovieSearchResult, CollectionMovie,
|
AddMovieBody, AddMovieOptions, AddMovieSearchResult, CollectionMovie,
|
||||||
};
|
};
|
||||||
use crate::models::servarr_data::radarr::modals::AddMovieModal;
|
use crate::models::servarr_data::radarr::modals::AddMovieModal;
|
||||||
use crate::models::servarr_data::radarr::radarr_data::{
|
use crate::models::servarr_data::radarr::radarr_data::{
|
||||||
ActiveRadarrBlock, ADD_MOVIE_BLOCKS, ADD_MOVIE_SELECTION_BLOCKS,
|
ADD_MOVIE_BLOCKS, ADD_MOVIE_SELECTION_BLOCKS, ActiveRadarrBlock,
|
||||||
};
|
};
|
||||||
use crate::models::stateful_table::StatefulTable;
|
|
||||||
use crate::models::{BlockSelectionState, Scrollable};
|
use crate::models::{BlockSelectionState, Scrollable};
|
||||||
use crate::network::radarr_network::RadarrEvent;
|
use crate::network::radarr_network::RadarrEvent;
|
||||||
use crate::{
|
use crate::{App, Key, handle_text_box_keys, handle_text_box_left_right_keys, matches_key};
|
||||||
handle_table_events, handle_text_box_keys, handle_text_box_left_right_keys, matches_key, App, Key,
|
|
||||||
};
|
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
#[path = "add_movie_handler_tests.rs"]
|
#[path = "add_movie_handler_tests.rs"]
|
||||||
@@ -26,19 +23,6 @@ pub(super) struct AddMovieHandler<'a, 'b> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl AddMovieHandler<'_, '_> {
|
impl AddMovieHandler<'_, '_> {
|
||||||
handle_table_events!(
|
|
||||||
self,
|
|
||||||
add_movie_search_results,
|
|
||||||
self
|
|
||||||
.app
|
|
||||||
.data
|
|
||||||
.radarr_data
|
|
||||||
.add_searched_movies
|
|
||||||
.as_mut()
|
|
||||||
.unwrap_or(&mut StatefulTable::default()),
|
|
||||||
AddMovieSearchResult
|
|
||||||
);
|
|
||||||
|
|
||||||
fn build_add_movie_body(&mut self) -> AddMovieBody {
|
fn build_add_movie_body(&mut self) -> AddMovieBody {
|
||||||
let add_movie_modal = self
|
let add_movie_modal = self
|
||||||
.app
|
.app
|
||||||
@@ -124,7 +108,18 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for AddMovieHandler<'a,
|
|||||||
let add_movie_table_handling_config =
|
let add_movie_table_handling_config =
|
||||||
TableHandlingConfig::new(ActiveRadarrBlock::AddMovieSearchResults.into());
|
TableHandlingConfig::new(ActiveRadarrBlock::AddMovieSearchResults.into());
|
||||||
|
|
||||||
if !self.handle_add_movie_search_results_table_events(add_movie_table_handling_config) {
|
if !handle_table(
|
||||||
|
self,
|
||||||
|
|app| {
|
||||||
|
app
|
||||||
|
.data
|
||||||
|
.radarr_data
|
||||||
|
.add_searched_movies
|
||||||
|
.as_mut()
|
||||||
|
.expect("add_searched_movies should be initialized")
|
||||||
|
},
|
||||||
|
add_movie_table_handling_config,
|
||||||
|
) {
|
||||||
self.handle_key_event();
|
self.handle_key_event();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -558,4 +553,12 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for AddMovieHandler<'a,
|
|||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn app_mut(&mut self) -> &mut App<'b> {
|
||||||
|
self.app
|
||||||
|
}
|
||||||
|
|
||||||
|
fn current_route(&self) -> crate::models::Route {
|
||||||
|
self.app.get_current_route()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,23 +1,26 @@
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
|
use crate::assert_modal_absent;
|
||||||
|
use crate::assert_modal_present;
|
||||||
|
use crate::assert_navigation_pushed;
|
||||||
use crate::handlers::radarr_handlers::radarr_handler_test_utils::utils::add_movie_search_result;
|
use crate::handlers::radarr_handlers::radarr_handler_test_utils::utils::add_movie_search_result;
|
||||||
use crate::models::stateful_table::StatefulTable;
|
use crate::models::stateful_table::StatefulTable;
|
||||||
use pretty_assertions::assert_str_eq;
|
use pretty_assertions::assert_str_eq;
|
||||||
use rstest::rstest;
|
use rstest::rstest;
|
||||||
use strum::IntoEnumIterator;
|
use strum::IntoEnumIterator;
|
||||||
|
|
||||||
use crate::app::key_binding::DEFAULT_KEYBINDINGS;
|
|
||||||
use crate::app::App;
|
use crate::app::App;
|
||||||
|
use crate::app::key_binding::DEFAULT_KEYBINDINGS;
|
||||||
use crate::event::Key;
|
use crate::event::Key;
|
||||||
|
use crate::handlers::KeyEventHandler;
|
||||||
use crate::handlers::radarr_handlers::library::add_movie_handler::AddMovieHandler;
|
use crate::handlers::radarr_handlers::library::add_movie_handler::AddMovieHandler;
|
||||||
use crate::handlers::radarr_handlers::radarr_handler_test_utils::utils::add_movie_body;
|
use crate::handlers::radarr_handlers::radarr_handler_test_utils::utils::add_movie_body;
|
||||||
use crate::handlers::radarr_handlers::radarr_handler_test_utils::utils::collection_movie;
|
use crate::handlers::radarr_handlers::radarr_handler_test_utils::utils::collection_movie;
|
||||||
use crate::handlers::KeyEventHandler;
|
use crate::models::HorizontallyScrollableText;
|
||||||
use crate::models::radarr_models::{AddMovieSearchResult, MinimumAvailability, MovieMonitor};
|
use crate::models::radarr_models::{AddMovieSearchResult, MinimumAvailability, MovieMonitor};
|
||||||
use crate::models::servarr_data::radarr::modals::AddMovieModal;
|
use crate::models::servarr_data::radarr::modals::AddMovieModal;
|
||||||
use crate::models::servarr_data::radarr::radarr_data::{ActiveRadarrBlock, ADD_MOVIE_BLOCKS};
|
use crate::models::servarr_data::radarr::radarr_data::{ADD_MOVIE_BLOCKS, ActiveRadarrBlock};
|
||||||
use crate::models::servarr_models::RootFolder;
|
use crate::models::servarr_models::RootFolder;
|
||||||
use crate::models::HorizontallyScrollableText;
|
|
||||||
use bimap::BiMap;
|
use bimap::BiMap;
|
||||||
|
|
||||||
mod test_handle_scroll_up_and_down {
|
mod test_handle_scroll_up_and_down {
|
||||||
@@ -25,9 +28,9 @@ mod tests {
|
|||||||
use rstest::rstest;
|
use rstest::rstest;
|
||||||
use strum::IntoEnumIterator;
|
use strum::IntoEnumIterator;
|
||||||
|
|
||||||
|
use crate::models::BlockSelectionState;
|
||||||
use crate::models::servarr_data::radarr::modals::AddMovieModal;
|
use crate::models::servarr_data::radarr::modals::AddMovieModal;
|
||||||
use crate::models::servarr_data::radarr::radarr_data::ADD_MOVIE_SELECTION_BLOCKS;
|
use crate::models::servarr_data::radarr::radarr_data::ADD_MOVIE_SELECTION_BLOCKS;
|
||||||
use crate::models::BlockSelectionState;
|
|
||||||
use crate::simple_stateful_iterable_vec;
|
use crate::simple_stateful_iterable_vec;
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
@@ -761,19 +764,19 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
mod test_handle_submit {
|
mod test_handle_submit {
|
||||||
use bimap::BiMap;
|
use crate::assert_navigation_popped;
|
||||||
use pretty_assertions::{assert_eq, assert_str_eq};
|
|
||||||
use rstest::rstest;
|
|
||||||
|
|
||||||
use crate::handlers::radarr_handlers::radarr_handler_test_utils::utils::{
|
use crate::handlers::radarr_handlers::radarr_handler_test_utils::utils::{
|
||||||
add_movie_body, add_movie_search_result, collection_movie,
|
add_movie_body, add_movie_search_result, collection_movie,
|
||||||
};
|
};
|
||||||
|
use crate::models::BlockSelectionState;
|
||||||
use crate::models::radarr_models::Movie;
|
use crate::models::radarr_models::Movie;
|
||||||
use crate::models::servarr_data::radarr::modals::AddMovieModal;
|
use crate::models::servarr_data::radarr::modals::AddMovieModal;
|
||||||
use crate::models::servarr_data::radarr::radarr_data::ADD_MOVIE_SELECTION_BLOCKS;
|
use crate::models::servarr_data::radarr::radarr_data::ADD_MOVIE_SELECTION_BLOCKS;
|
||||||
use crate::models::stateful_table::StatefulTable;
|
use crate::models::stateful_table::StatefulTable;
|
||||||
use crate::models::BlockSelectionState;
|
|
||||||
use crate::network::radarr_network::RadarrEvent;
|
use crate::network::radarr_network::RadarrEvent;
|
||||||
|
use bimap::BiMap;
|
||||||
|
use pretty_assertions::{assert_eq, assert_str_eq};
|
||||||
|
use rstest::rstest;
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
@@ -847,34 +850,40 @@ mod tests {
|
|||||||
app.data.radarr_data.selected_block.get_active_block(),
|
app.data.radarr_data.selected_block.get_active_block(),
|
||||||
ActiveRadarrBlock::AddMovieSelectRootFolder
|
ActiveRadarrBlock::AddMovieSelectRootFolder
|
||||||
);
|
);
|
||||||
assert!(app.data.radarr_data.add_movie_modal.is_some());
|
assert_modal_present!(app.data.radarr_data.add_movie_modal);
|
||||||
assert!(!app
|
assert!(
|
||||||
.data
|
!app
|
||||||
.radarr_data
|
.data
|
||||||
.add_movie_modal
|
.radarr_data
|
||||||
.as_ref()
|
.add_movie_modal
|
||||||
.unwrap()
|
.as_ref()
|
||||||
.monitor_list
|
.unwrap()
|
||||||
.items
|
.monitor_list
|
||||||
.is_empty());
|
.items
|
||||||
assert!(!app
|
.is_empty()
|
||||||
.data
|
);
|
||||||
.radarr_data
|
assert!(
|
||||||
.add_movie_modal
|
!app
|
||||||
.as_ref()
|
.data
|
||||||
.unwrap()
|
.radarr_data
|
||||||
.minimum_availability_list
|
.add_movie_modal
|
||||||
.items
|
.as_ref()
|
||||||
.is_empty());
|
.unwrap()
|
||||||
assert!(!app
|
.minimum_availability_list
|
||||||
.data
|
.items
|
||||||
.radarr_data
|
.is_empty()
|
||||||
.add_movie_modal
|
);
|
||||||
.as_ref()
|
assert!(
|
||||||
.unwrap()
|
!app
|
||||||
.quality_profile_list
|
.data
|
||||||
.items
|
.radarr_data
|
||||||
.is_empty());
|
.add_movie_modal
|
||||||
|
.as_ref()
|
||||||
|
.unwrap()
|
||||||
|
.quality_profile_list
|
||||||
|
.items
|
||||||
|
.is_empty()
|
||||||
|
);
|
||||||
assert_str_eq!(
|
assert_str_eq!(
|
||||||
app
|
app
|
||||||
.data
|
.data
|
||||||
@@ -908,7 +917,7 @@ mod tests {
|
|||||||
app.get_current_route(),
|
app.get_current_route(),
|
||||||
ActiveRadarrBlock::AddMovieSearchResults.into()
|
ActiveRadarrBlock::AddMovieSearchResults.into()
|
||||||
);
|
);
|
||||||
assert!(app.data.radarr_data.add_movie_modal.is_none());
|
assert_modal_absent!(app.data.radarr_data.add_movie_modal);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -975,8 +984,8 @@ mod tests {
|
|||||||
)
|
)
|
||||||
.handle();
|
.handle();
|
||||||
|
|
||||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Movies.into());
|
assert_navigation_popped!(app, ActiveRadarrBlock::Movies.into());
|
||||||
assert_eq!(app.data.radarr_data.prompt_confirm_action, None);
|
assert_none!(app.data.radarr_data.prompt_confirm_action);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[rstest]
|
#[rstest]
|
||||||
@@ -1049,12 +1058,12 @@ mod tests {
|
|||||||
)
|
)
|
||||||
.handle();
|
.handle();
|
||||||
|
|
||||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Movies.into());
|
assert_navigation_popped!(app, ActiveRadarrBlock::Movies.into());
|
||||||
assert_eq!(
|
assert_some_eq_x!(
|
||||||
app.data.radarr_data.prompt_confirm_action,
|
&app.data.radarr_data.prompt_confirm_action,
|
||||||
Some(RadarrEvent::AddMovie(add_movie_body()))
|
&RadarrEvent::AddMovie(add_movie_body())
|
||||||
);
|
);
|
||||||
assert!(app.data.radarr_data.add_movie_modal.is_none());
|
assert_modal_absent!(app.data.radarr_data.add_movie_modal);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[rstest]
|
#[rstest]
|
||||||
@@ -1086,11 +1095,11 @@ mod tests {
|
|||||||
)
|
)
|
||||||
.handle();
|
.handle();
|
||||||
|
|
||||||
assert_eq!(
|
assert_navigation_pushed!(
|
||||||
app.get_current_route(),
|
app,
|
||||||
(selected_block, Some(ActiveRadarrBlock::CollectionDetails)).into()
|
(selected_block, Some(ActiveRadarrBlock::CollectionDetails)).into()
|
||||||
);
|
);
|
||||||
assert_eq!(app.data.radarr_data.prompt_confirm_action, None);
|
assert_none!(app.data.radarr_data.prompt_confirm_action);
|
||||||
|
|
||||||
if selected_block == ActiveRadarrBlock::AddMovieTagsInput {
|
if selected_block == ActiveRadarrBlock::AddMovieTagsInput {
|
||||||
assert!(app.ignore_special_keys_for_textbox_input);
|
assert!(app.ignore_special_keys_for_textbox_input);
|
||||||
@@ -1120,10 +1129,7 @@ mod tests {
|
|||||||
)
|
)
|
||||||
.handle();
|
.handle();
|
||||||
|
|
||||||
assert_eq!(
|
assert_navigation_popped!(app, ActiveRadarrBlock::AddMoviePrompt.into());
|
||||||
app.get_current_route(),
|
|
||||||
ActiveRadarrBlock::AddMoviePrompt.into()
|
|
||||||
);
|
|
||||||
|
|
||||||
if active_radarr_block == ActiveRadarrBlock::AddMovieTagsInput {
|
if active_radarr_block == ActiveRadarrBlock::AddMovieTagsInput {
|
||||||
assert!(!app.ignore_special_keys_for_textbox_input);
|
assert!(!app.ignore_special_keys_for_textbox_input);
|
||||||
@@ -1132,13 +1138,12 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
mod test_handle_esc {
|
mod test_handle_esc {
|
||||||
use pretty_assertions::assert_eq;
|
|
||||||
use rstest::rstest;
|
use rstest::rstest;
|
||||||
|
|
||||||
use crate::models::servarr_data::radarr::modals::AddMovieModal;
|
use crate::models::servarr_data::radarr::modals::AddMovieModal;
|
||||||
use crate::models::servarr_data::radarr::radarr_data::radarr_test_utils::utils::create_test_radarr_data;
|
use crate::models::servarr_data::radarr::radarr_data::radarr_test_utils::utils::create_test_radarr_data;
|
||||||
use crate::models::stateful_table::StatefulTable;
|
use crate::models::stateful_table::StatefulTable;
|
||||||
use crate::simple_stateful_iterable_vec;
|
use crate::{assert_navigation_popped, simple_stateful_iterable_vec};
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
@@ -1161,8 +1166,8 @@ mod tests {
|
|||||||
.handle();
|
.handle();
|
||||||
|
|
||||||
assert!(!app.ignore_special_keys_for_textbox_input);
|
assert!(!app.ignore_special_keys_for_textbox_input);
|
||||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Movies.into());
|
assert_navigation_popped!(app, ActiveRadarrBlock::Movies.into());
|
||||||
assert_eq!(app.data.radarr_data.add_movie_search, None);
|
assert_none!(app.data.radarr_data.add_movie_search);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -1182,10 +1187,7 @@ mod tests {
|
|||||||
.handle();
|
.handle();
|
||||||
|
|
||||||
assert!(!app.ignore_special_keys_for_textbox_input);
|
assert!(!app.ignore_special_keys_for_textbox_input);
|
||||||
assert_eq!(
|
assert_navigation_popped!(app, ActiveRadarrBlock::AddMoviePrompt.into());
|
||||||
app.get_current_route(),
|
|
||||||
ActiveRadarrBlock::AddMoviePrompt.into()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[rstest]
|
#[rstest]
|
||||||
@@ -1208,11 +1210,8 @@ mod tests {
|
|||||||
|
|
||||||
AddMovieHandler::new(ESC_KEY, &mut app, active_radarr_block, None).handle();
|
AddMovieHandler::new(ESC_KEY, &mut app, active_radarr_block, None).handle();
|
||||||
|
|
||||||
assert_eq!(
|
assert_navigation_popped!(app, ActiveRadarrBlock::AddMovieSearchInput.into());
|
||||||
app.get_current_route(),
|
assert_modal_absent!(app.data.radarr_data.add_searched_movies);
|
||||||
ActiveRadarrBlock::AddMovieSearchInput.into()
|
|
||||||
);
|
|
||||||
assert!(app.data.radarr_data.add_searched_movies.is_none());
|
|
||||||
assert!(app.ignore_special_keys_for_textbox_input);
|
assert!(app.ignore_special_keys_for_textbox_input);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1231,10 +1230,7 @@ mod tests {
|
|||||||
)
|
)
|
||||||
.handle();
|
.handle();
|
||||||
|
|
||||||
assert_eq!(
|
assert_navigation_popped!(app, ActiveRadarrBlock::AddMovieSearchResults.into());
|
||||||
app.get_current_route(),
|
|
||||||
ActiveRadarrBlock::AddMovieSearchResults.into()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -1248,11 +1244,8 @@ mod tests {
|
|||||||
AddMovieHandler::new(ESC_KEY, &mut app, ActiveRadarrBlock::AddMoviePrompt, None).handle();
|
AddMovieHandler::new(ESC_KEY, &mut app, ActiveRadarrBlock::AddMoviePrompt, None).handle();
|
||||||
|
|
||||||
assert!(!app.data.radarr_data.prompt_confirm);
|
assert!(!app.data.radarr_data.prompt_confirm);
|
||||||
assert_eq!(
|
assert_navigation_popped!(app, ActiveRadarrBlock::AddMovieSearchResults.into());
|
||||||
app.get_current_route(),
|
assert_modal_absent!(app.data.radarr_data.add_movie_modal);
|
||||||
ActiveRadarrBlock::AddMovieSearchResults.into()
|
|
||||||
);
|
|
||||||
assert!(app.data.radarr_data.add_movie_modal.is_none());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -1272,10 +1265,7 @@ mod tests {
|
|||||||
.handle();
|
.handle();
|
||||||
|
|
||||||
assert!(!app.ignore_special_keys_for_textbox_input);
|
assert!(!app.ignore_special_keys_for_textbox_input);
|
||||||
assert_eq!(
|
assert_navigation_popped!(app, ActiveRadarrBlock::AddMoviePrompt.into());
|
||||||
app.get_current_route(),
|
|
||||||
ActiveRadarrBlock::AddMoviePrompt.into()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[rstest]
|
#[rstest]
|
||||||
@@ -1312,8 +1302,8 @@ mod tests {
|
|||||||
)
|
)
|
||||||
.handle();
|
.handle();
|
||||||
|
|
||||||
assert_eq!(
|
assert_navigation_popped!(
|
||||||
app.get_current_route(),
|
app,
|
||||||
(
|
(
|
||||||
ActiveRadarrBlock::AddMoviePrompt,
|
ActiveRadarrBlock::AddMoviePrompt,
|
||||||
Some(ActiveRadarrBlock::CollectionDetails),
|
Some(ActiveRadarrBlock::CollectionDetails),
|
||||||
@@ -1325,18 +1315,18 @@ mod tests {
|
|||||||
|
|
||||||
mod test_handle_key_char {
|
mod test_handle_key_char {
|
||||||
use bimap::BiMap;
|
use bimap::BiMap;
|
||||||
use pretty_assertions::assert_eq;
|
|
||||||
use rstest::rstest;
|
use rstest::rstest;
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::{
|
use crate::{
|
||||||
|
assert_navigation_popped,
|
||||||
handlers::radarr_handlers::radarr_handler_test_utils::utils::{
|
handlers::radarr_handlers::radarr_handler_test_utils::utils::{
|
||||||
add_movie_body, add_movie_search_result, collection_movie,
|
add_movie_body, add_movie_search_result, collection_movie,
|
||||||
},
|
},
|
||||||
models::{
|
models::{
|
||||||
|
BlockSelectionState,
|
||||||
servarr_data::radarr::{modals::AddMovieModal, radarr_data::ADD_MOVIE_SELECTION_BLOCKS},
|
servarr_data::radarr::{modals::AddMovieModal, radarr_data::ADD_MOVIE_SELECTION_BLOCKS},
|
||||||
stateful_table::StatefulTable,
|
stateful_table::StatefulTable,
|
||||||
BlockSelectionState,
|
|
||||||
},
|
},
|
||||||
network::radarr_network::RadarrEvent,
|
network::radarr_network::RadarrEvent,
|
||||||
};
|
};
|
||||||
@@ -1503,12 +1493,12 @@ mod tests {
|
|||||||
)
|
)
|
||||||
.handle();
|
.handle();
|
||||||
|
|
||||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Movies.into());
|
assert_navigation_popped!(app, ActiveRadarrBlock::Movies.into());
|
||||||
assert_eq!(
|
assert_some_eq_x!(
|
||||||
app.data.radarr_data.prompt_confirm_action,
|
&app.data.radarr_data.prompt_confirm_action,
|
||||||
Some(RadarrEvent::AddMovie(add_movie_body()))
|
&RadarrEvent::AddMovie(add_movie_body())
|
||||||
);
|
);
|
||||||
assert!(app.data.radarr_data.add_movie_modal.is_none());
|
assert_modal_absent!(app.data.radarr_data.add_movie_modal);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
use crate::app::App;
|
use crate::app::App;
|
||||||
use crate::event::Key;
|
use crate::event::Key;
|
||||||
use crate::handlers::{handle_prompt_toggle, KeyEventHandler};
|
use crate::handlers::{KeyEventHandler, handle_prompt_toggle};
|
||||||
use crate::matches_key;
|
use crate::matches_key;
|
||||||
use crate::models::radarr_models::DeleteMovieParams;
|
use crate::models::radarr_models::DeleteMovieParams;
|
||||||
use crate::models::servarr_data::radarr::radarr_data::{ActiveRadarrBlock, DELETE_MOVIE_BLOCKS};
|
use crate::models::servarr_data::radarr::radarr_data::{ActiveRadarrBlock, DELETE_MOVIE_BLOCKS};
|
||||||
@@ -136,4 +136,12 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for DeleteMovieHandler<'
|
|||||||
self.app.pop_navigation_stack();
|
self.app.pop_navigation_stack();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn app_mut(&mut self) -> &mut App<'b> {
|
||||||
|
self.app
|
||||||
|
}
|
||||||
|
|
||||||
|
fn current_route(&self) -> crate::models::Route {
|
||||||
|
self.app.get_current_route()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,12 +4,12 @@ mod tests {
|
|||||||
use rstest::rstest;
|
use rstest::rstest;
|
||||||
use strum::IntoEnumIterator;
|
use strum::IntoEnumIterator;
|
||||||
|
|
||||||
use crate::app::key_binding::DEFAULT_KEYBINDINGS;
|
|
||||||
use crate::app::App;
|
use crate::app::App;
|
||||||
|
use crate::app::key_binding::DEFAULT_KEYBINDINGS;
|
||||||
use crate::event::Key;
|
use crate::event::Key;
|
||||||
|
use crate::handlers::KeyEventHandler;
|
||||||
use crate::handlers::radarr_handlers::library::delete_movie_handler::DeleteMovieHandler;
|
use crate::handlers::radarr_handlers::library::delete_movie_handler::DeleteMovieHandler;
|
||||||
use crate::handlers::radarr_handlers::radarr_handler_test_utils::utils::movie;
|
use crate::handlers::radarr_handlers::radarr_handler_test_utils::utils::movie;
|
||||||
use crate::handlers::KeyEventHandler;
|
|
||||||
use crate::models::radarr_models::DeleteMovieParams;
|
use crate::models::radarr_models::DeleteMovieParams;
|
||||||
use crate::models::servarr_data::radarr::radarr_data::{ActiveRadarrBlock, DELETE_MOVIE_BLOCKS};
|
use crate::models::servarr_data::radarr::radarr_data::{ActiveRadarrBlock, DELETE_MOVIE_BLOCKS};
|
||||||
|
|
||||||
@@ -17,8 +17,8 @@ mod tests {
|
|||||||
use pretty_assertions::assert_eq;
|
use pretty_assertions::assert_eq;
|
||||||
use rstest::rstest;
|
use rstest::rstest;
|
||||||
|
|
||||||
use crate::models::servarr_data::radarr::radarr_data::DELETE_MOVIE_SELECTION_BLOCKS;
|
|
||||||
use crate::models::BlockSelectionState;
|
use crate::models::BlockSelectionState;
|
||||||
|
use crate::models::servarr_data::radarr::radarr_data::DELETE_MOVIE_SELECTION_BLOCKS;
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
@@ -83,11 +83,12 @@ mod tests {
|
|||||||
mod test_handle_submit {
|
mod test_handle_submit {
|
||||||
use pretty_assertions::assert_eq;
|
use pretty_assertions::assert_eq;
|
||||||
|
|
||||||
use crate::models::servarr_data::radarr::radarr_data::DELETE_MOVIE_SELECTION_BLOCKS;
|
|
||||||
use crate::models::BlockSelectionState;
|
use crate::models::BlockSelectionState;
|
||||||
|
use crate::models::servarr_data::radarr::radarr_data::DELETE_MOVIE_SELECTION_BLOCKS;
|
||||||
use crate::network::radarr_network::RadarrEvent;
|
use crate::network::radarr_network::RadarrEvent;
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
use crate::assert_navigation_popped;
|
||||||
|
|
||||||
const SUBMIT_KEY: Key = DEFAULT_KEYBINDINGS.submit.key;
|
const SUBMIT_KEY: Key = DEFAULT_KEYBINDINGS.submit.key;
|
||||||
|
|
||||||
@@ -113,8 +114,8 @@ mod tests {
|
|||||||
)
|
)
|
||||||
.handle();
|
.handle();
|
||||||
|
|
||||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Movies.into());
|
assert_navigation_popped!(app, ActiveRadarrBlock::Movies.into());
|
||||||
assert_eq!(app.data.radarr_data.prompt_confirm_action, None);
|
assert_none!(app.data.radarr_data.prompt_confirm_action);
|
||||||
assert!(!app.data.radarr_data.prompt_confirm);
|
assert!(!app.data.radarr_data.prompt_confirm);
|
||||||
assert!(!app.data.radarr_data.delete_movie_files);
|
assert!(!app.data.radarr_data.delete_movie_files);
|
||||||
assert!(!app.data.radarr_data.add_list_exclusion);
|
assert!(!app.data.radarr_data.add_list_exclusion);
|
||||||
@@ -149,7 +150,7 @@ mod tests {
|
|||||||
)
|
)
|
||||||
.handle();
|
.handle();
|
||||||
|
|
||||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Movies.into());
|
assert_navigation_popped!(app, ActiveRadarrBlock::Movies.into());
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
app.data.radarr_data.prompt_confirm_action,
|
app.data.radarr_data.prompt_confirm_action,
|
||||||
Some(RadarrEvent::DeleteMovie(expected_delete_movie_params))
|
Some(RadarrEvent::DeleteMovie(expected_delete_movie_params))
|
||||||
@@ -182,7 +183,7 @@ mod tests {
|
|||||||
app.get_current_route(),
|
app.get_current_route(),
|
||||||
ActiveRadarrBlock::DeleteMoviePrompt.into()
|
ActiveRadarrBlock::DeleteMoviePrompt.into()
|
||||||
);
|
);
|
||||||
assert_eq!(app.data.radarr_data.prompt_confirm_action, None);
|
assert_none!(app.data.radarr_data.prompt_confirm_action);
|
||||||
assert!(!app.should_refresh);
|
assert!(!app.should_refresh);
|
||||||
assert!(app.data.radarr_data.prompt_confirm);
|
assert!(app.data.radarr_data.prompt_confirm);
|
||||||
assert!(app.data.radarr_data.delete_movie_files);
|
assert!(app.data.radarr_data.delete_movie_files);
|
||||||
@@ -222,7 +223,7 @@ mod tests {
|
|||||||
|
|
||||||
mod test_handle_esc {
|
mod test_handle_esc {
|
||||||
use super::*;
|
use super::*;
|
||||||
use pretty_assertions::assert_eq;
|
use crate::assert_navigation_popped;
|
||||||
use rstest::rstest;
|
use rstest::rstest;
|
||||||
|
|
||||||
const ESC_KEY: Key = DEFAULT_KEYBINDINGS.esc.key;
|
const ESC_KEY: Key = DEFAULT_KEYBINDINGS.esc.key;
|
||||||
@@ -245,7 +246,7 @@ mod tests {
|
|||||||
)
|
)
|
||||||
.handle();
|
.handle();
|
||||||
|
|
||||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Movies.into());
|
assert_navigation_popped!(app, ActiveRadarrBlock::Movies.into());
|
||||||
assert!(!app.data.radarr_data.prompt_confirm);
|
assert!(!app.data.radarr_data.prompt_confirm);
|
||||||
assert!(!app.data.radarr_data.delete_movie_files);
|
assert!(!app.data.radarr_data.delete_movie_files);
|
||||||
assert!(!app.data.radarr_data.add_list_exclusion);
|
assert!(!app.data.radarr_data.add_list_exclusion);
|
||||||
@@ -254,8 +255,9 @@ mod tests {
|
|||||||
|
|
||||||
mod test_handle_key_char {
|
mod test_handle_key_char {
|
||||||
use crate::{
|
use crate::{
|
||||||
|
assert_navigation_popped,
|
||||||
models::{
|
models::{
|
||||||
servarr_data::radarr::radarr_data::DELETE_MOVIE_SELECTION_BLOCKS, BlockSelectionState,
|
BlockSelectionState, servarr_data::radarr::radarr_data::DELETE_MOVIE_SELECTION_BLOCKS,
|
||||||
},
|
},
|
||||||
network::radarr_network::RadarrEvent,
|
network::radarr_network::RadarrEvent,
|
||||||
};
|
};
|
||||||
@@ -291,7 +293,7 @@ mod tests {
|
|||||||
)
|
)
|
||||||
.handle();
|
.handle();
|
||||||
|
|
||||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Movies.into());
|
assert_navigation_popped!(app, ActiveRadarrBlock::Movies.into());
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
app.data.radarr_data.prompt_confirm_action,
|
app.data.radarr_data.prompt_confirm_action,
|
||||||
Some(RadarrEvent::DeleteMovie(expected_delete_movie_params))
|
Some(RadarrEvent::DeleteMovie(expected_delete_movie_params))
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
use crate::app::App;
|
use crate::app::App;
|
||||||
use crate::event::Key;
|
use crate::event::Key;
|
||||||
use crate::handlers::{handle_prompt_toggle, KeyEventHandler};
|
use crate::handlers::{KeyEventHandler, handle_prompt_toggle};
|
||||||
|
use crate::models::Scrollable;
|
||||||
use crate::models::radarr_models::EditMovieParams;
|
use crate::models::radarr_models::EditMovieParams;
|
||||||
use crate::models::servarr_data::radarr::modals::EditMovieModal;
|
use crate::models::servarr_data::radarr::modals::EditMovieModal;
|
||||||
use crate::models::servarr_data::radarr::radarr_data::{ActiveRadarrBlock, EDIT_MOVIE_BLOCKS};
|
use crate::models::servarr_data::radarr::radarr_data::{ActiveRadarrBlock, EDIT_MOVIE_BLOCKS};
|
||||||
use crate::models::Scrollable;
|
|
||||||
use crate::network::radarr_network::RadarrEvent;
|
use crate::network::radarr_network::RadarrEvent;
|
||||||
use crate::{handle_text_box_keys, handle_text_box_left_right_keys, matches_key};
|
use crate::{handle_text_box_keys, handle_text_box_left_right_keys, matches_key};
|
||||||
|
|
||||||
@@ -392,4 +392,12 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for EditMovieHandler<'a,
|
|||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn app_mut(&mut self) -> &mut App<'b> {
|
||||||
|
self.app
|
||||||
|
}
|
||||||
|
|
||||||
|
fn current_route(&self) -> crate::models::Route {
|
||||||
|
self.app.get_current_route()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,12 +5,14 @@ mod tests {
|
|||||||
use rstest::rstest;
|
use rstest::rstest;
|
||||||
use strum::IntoEnumIterator;
|
use strum::IntoEnumIterator;
|
||||||
|
|
||||||
use crate::app::key_binding::DEFAULT_KEYBINDINGS;
|
|
||||||
use crate::app::App;
|
use crate::app::App;
|
||||||
|
use crate::app::key_binding::DEFAULT_KEYBINDINGS;
|
||||||
|
use crate::assert_modal_absent;
|
||||||
|
use crate::assert_navigation_pushed;
|
||||||
use crate::event::Key;
|
use crate::event::Key;
|
||||||
|
use crate::handlers::KeyEventHandler;
|
||||||
use crate::handlers::radarr_handlers::library::edit_movie_handler::EditMovieHandler;
|
use crate::handlers::radarr_handlers::library::edit_movie_handler::EditMovieHandler;
|
||||||
use crate::handlers::radarr_handlers::radarr_handler_test_utils::utils::movie;
|
use crate::handlers::radarr_handlers::radarr_handler_test_utils::utils::movie;
|
||||||
use crate::handlers::KeyEventHandler;
|
|
||||||
use crate::models::radarr_models::{EditMovieParams, MinimumAvailability, Movie};
|
use crate::models::radarr_models::{EditMovieParams, MinimumAvailability, Movie};
|
||||||
use crate::models::servarr_data::radarr::modals::EditMovieModal;
|
use crate::models::servarr_data::radarr::modals::EditMovieModal;
|
||||||
use crate::models::servarr_data::radarr::radarr_data::{ActiveRadarrBlock, EDIT_MOVIE_BLOCKS};
|
use crate::models::servarr_data::radarr::radarr_data::{ActiveRadarrBlock, EDIT_MOVIE_BLOCKS};
|
||||||
@@ -20,9 +22,9 @@ mod tests {
|
|||||||
use rstest::rstest;
|
use rstest::rstest;
|
||||||
use strum::IntoEnumIterator;
|
use strum::IntoEnumIterator;
|
||||||
|
|
||||||
|
use crate::models::BlockSelectionState;
|
||||||
use crate::models::servarr_data::radarr::modals::EditMovieModal;
|
use crate::models::servarr_data::radarr::modals::EditMovieModal;
|
||||||
use crate::models::servarr_data::radarr::radarr_data::EDIT_MOVIE_SELECTION_BLOCKS;
|
use crate::models::servarr_data::radarr::radarr_data::EDIT_MOVIE_SELECTION_BLOCKS;
|
||||||
use crate::models::BlockSelectionState;
|
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
@@ -534,13 +536,13 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
mod test_handle_submit {
|
mod test_handle_submit {
|
||||||
use pretty_assertions::assert_eq;
|
use crate::assert_navigation_popped;
|
||||||
use rstest::rstest;
|
|
||||||
|
|
||||||
use crate::models::servarr_data::radarr::modals::EditMovieModal;
|
use crate::models::servarr_data::radarr::modals::EditMovieModal;
|
||||||
use crate::models::servarr_data::radarr::radarr_data::EDIT_MOVIE_SELECTION_BLOCKS;
|
use crate::models::servarr_data::radarr::radarr_data::EDIT_MOVIE_SELECTION_BLOCKS;
|
||||||
use crate::models::{BlockSelectionState, Route};
|
use crate::models::{BlockSelectionState, Route};
|
||||||
use crate::network::radarr_network::RadarrEvent;
|
use crate::network::radarr_network::RadarrEvent;
|
||||||
|
use pretty_assertions::assert_eq;
|
||||||
|
use rstest::rstest;
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
@@ -566,19 +568,18 @@ mod tests {
|
|||||||
.handle();
|
.handle();
|
||||||
|
|
||||||
assert!(!app.ignore_special_keys_for_textbox_input);
|
assert!(!app.ignore_special_keys_for_textbox_input);
|
||||||
assert!(!app
|
assert!(
|
||||||
.data
|
!app
|
||||||
.radarr_data
|
.data
|
||||||
.edit_movie_modal
|
.radarr_data
|
||||||
.as_ref()
|
.edit_movie_modal
|
||||||
.unwrap()
|
.as_ref()
|
||||||
.path
|
.unwrap()
|
||||||
.text
|
.path
|
||||||
.is_empty());
|
.text
|
||||||
assert_eq!(
|
.is_empty()
|
||||||
app.get_current_route(),
|
|
||||||
ActiveRadarrBlock::EditMoviePrompt.into()
|
|
||||||
);
|
);
|
||||||
|
assert_navigation_popped!(app, ActiveRadarrBlock::EditMoviePrompt.into());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -601,19 +602,18 @@ mod tests {
|
|||||||
.handle();
|
.handle();
|
||||||
|
|
||||||
assert!(!app.ignore_special_keys_for_textbox_input);
|
assert!(!app.ignore_special_keys_for_textbox_input);
|
||||||
assert!(!app
|
assert!(
|
||||||
.data
|
!app
|
||||||
.radarr_data
|
.data
|
||||||
.edit_movie_modal
|
.radarr_data
|
||||||
.as_mut()
|
.edit_movie_modal
|
||||||
.unwrap()
|
.as_mut()
|
||||||
.tags
|
.unwrap()
|
||||||
.text
|
.tags
|
||||||
.is_empty());
|
.text
|
||||||
assert_eq!(
|
.is_empty()
|
||||||
app.get_current_route(),
|
|
||||||
ActiveRadarrBlock::EditMoviePrompt.into()
|
|
||||||
);
|
);
|
||||||
|
assert_navigation_popped!(app, ActiveRadarrBlock::EditMoviePrompt.into());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -637,8 +637,8 @@ mod tests {
|
|||||||
)
|
)
|
||||||
.handle();
|
.handle();
|
||||||
|
|
||||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Movies.into());
|
assert_navigation_popped!(app, ActiveRadarrBlock::Movies.into());
|
||||||
assert_eq!(app.data.radarr_data.prompt_confirm_action, None);
|
assert_none!(app.data.radarr_data.prompt_confirm_action);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -690,12 +690,12 @@ mod tests {
|
|||||||
)
|
)
|
||||||
.handle();
|
.handle();
|
||||||
|
|
||||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Movies.into());
|
assert_navigation_popped!(app, ActiveRadarrBlock::Movies.into());
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
app.data.radarr_data.prompt_confirm_action,
|
app.data.radarr_data.prompt_confirm_action,
|
||||||
Some(RadarrEvent::EditMovie(expected_edit_movie_params))
|
Some(RadarrEvent::EditMovie(expected_edit_movie_params))
|
||||||
);
|
);
|
||||||
assert!(app.data.radarr_data.edit_movie_modal.is_none());
|
assert_modal_absent!(app.data.radarr_data.edit_movie_modal);
|
||||||
assert!(app.should_refresh);
|
assert!(app.should_refresh);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -720,7 +720,7 @@ mod tests {
|
|||||||
app.get_current_route(),
|
app.get_current_route(),
|
||||||
ActiveRadarrBlock::EditMoviePrompt.into()
|
ActiveRadarrBlock::EditMoviePrompt.into()
|
||||||
);
|
);
|
||||||
assert_eq!(app.data.radarr_data.prompt_confirm_action, None);
|
assert_none!(app.data.radarr_data.prompt_confirm_action);
|
||||||
assert!(!app.should_refresh);
|
assert!(!app.should_refresh);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -744,7 +744,7 @@ mod tests {
|
|||||||
.handle();
|
.handle();
|
||||||
|
|
||||||
assert_eq!(app.get_current_route(), current_route);
|
assert_eq!(app.get_current_route(), current_route);
|
||||||
assert_eq!(
|
assert_some_eq_x!(
|
||||||
app
|
app
|
||||||
.data
|
.data
|
||||||
.radarr_data
|
.radarr_data
|
||||||
@@ -752,7 +752,7 @@ mod tests {
|
|||||||
.as_ref()
|
.as_ref()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.monitored,
|
.monitored,
|
||||||
Some(true)
|
true
|
||||||
);
|
);
|
||||||
|
|
||||||
EditMovieHandler::new(
|
EditMovieHandler::new(
|
||||||
@@ -764,7 +764,7 @@ mod tests {
|
|||||||
.handle();
|
.handle();
|
||||||
|
|
||||||
assert_eq!(app.get_current_route(), current_route);
|
assert_eq!(app.get_current_route(), current_route);
|
||||||
assert_eq!(
|
assert_some_eq_x!(
|
||||||
app
|
app
|
||||||
.data
|
.data
|
||||||
.radarr_data
|
.radarr_data
|
||||||
@@ -772,7 +772,7 @@ mod tests {
|
|||||||
.as_ref()
|
.as_ref()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.monitored,
|
.monitored,
|
||||||
Some(false)
|
false
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -805,11 +805,11 @@ mod tests {
|
|||||||
)
|
)
|
||||||
.handle();
|
.handle();
|
||||||
|
|
||||||
assert_eq!(
|
assert_navigation_pushed!(
|
||||||
app.get_current_route(),
|
app,
|
||||||
(selected_block, Some(ActiveRadarrBlock::Movies)).into()
|
(selected_block, Some(ActiveRadarrBlock::Movies)).into()
|
||||||
);
|
);
|
||||||
assert_eq!(app.data.radarr_data.prompt_confirm_action, None);
|
assert_none!(app.data.radarr_data.prompt_confirm_action);
|
||||||
|
|
||||||
if selected_block == ActiveRadarrBlock::EditMoviePathInput
|
if selected_block == ActiveRadarrBlock::EditMoviePathInput
|
||||||
|| selected_block == ActiveRadarrBlock::EditMovieTagsInput
|
|| selected_block == ActiveRadarrBlock::EditMovieTagsInput
|
||||||
@@ -851,7 +851,7 @@ mod tests {
|
|||||||
)
|
)
|
||||||
.into()
|
.into()
|
||||||
);
|
);
|
||||||
assert_eq!(app.data.radarr_data.prompt_confirm_action, None);
|
assert_none!(app.data.radarr_data.prompt_confirm_action);
|
||||||
assert!(!app.ignore_special_keys_for_textbox_input);
|
assert!(!app.ignore_special_keys_for_textbox_input);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -878,10 +878,7 @@ mod tests {
|
|||||||
)
|
)
|
||||||
.handle();
|
.handle();
|
||||||
|
|
||||||
assert_eq!(
|
assert_navigation_popped!(app, ActiveRadarrBlock::EditMoviePrompt.into());
|
||||||
app.get_current_route(),
|
|
||||||
ActiveRadarrBlock::EditMoviePrompt.into()
|
|
||||||
);
|
|
||||||
|
|
||||||
if active_radarr_block == ActiveRadarrBlock::EditMoviePathInput
|
if active_radarr_block == ActiveRadarrBlock::EditMoviePathInput
|
||||||
|| active_radarr_block == ActiveRadarrBlock::EditMovieTagsInput
|
|| active_radarr_block == ActiveRadarrBlock::EditMovieTagsInput
|
||||||
@@ -892,11 +889,10 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
mod test_handle_esc {
|
mod test_handle_esc {
|
||||||
use pretty_assertions::assert_eq;
|
use crate::assert_navigation_popped;
|
||||||
use rstest::rstest;
|
|
||||||
|
|
||||||
use crate::models::servarr_data::radarr::modals::EditMovieModal;
|
use crate::models::servarr_data::radarr::modals::EditMovieModal;
|
||||||
use crate::models::servarr_data::radarr::radarr_data::radarr_test_utils::utils::create_test_radarr_data;
|
use crate::models::servarr_data::radarr::radarr_data::radarr_test_utils::utils::create_test_radarr_data;
|
||||||
|
use rstest::rstest;
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
@@ -919,10 +915,7 @@ mod tests {
|
|||||||
EditMovieHandler::new(ESC_KEY, &mut app, active_radarr_block, None).handle();
|
EditMovieHandler::new(ESC_KEY, &mut app, active_radarr_block, None).handle();
|
||||||
|
|
||||||
assert!(!app.ignore_special_keys_for_textbox_input);
|
assert!(!app.ignore_special_keys_for_textbox_input);
|
||||||
assert_eq!(
|
assert_navigation_popped!(app, ActiveRadarrBlock::EditMoviePrompt.into());
|
||||||
app.get_current_route(),
|
|
||||||
ActiveRadarrBlock::EditMoviePrompt.into()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -934,9 +927,9 @@ mod tests {
|
|||||||
|
|
||||||
EditMovieHandler::new(ESC_KEY, &mut app, ActiveRadarrBlock::EditMoviePrompt, None).handle();
|
EditMovieHandler::new(ESC_KEY, &mut app, ActiveRadarrBlock::EditMoviePrompt, None).handle();
|
||||||
|
|
||||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Movies.into());
|
assert_navigation_popped!(app, ActiveRadarrBlock::Movies.into());
|
||||||
|
|
||||||
assert!(app.data.radarr_data.edit_movie_modal.is_none());
|
assert_modal_absent!(app.data.radarr_data.edit_movie_modal);
|
||||||
assert!(!app.data.radarr_data.prompt_confirm);
|
assert!(!app.data.radarr_data.prompt_confirm);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -956,16 +949,17 @@ mod tests {
|
|||||||
|
|
||||||
EditMovieHandler::new(ESC_KEY, &mut app, active_radarr_block, None).handle();
|
EditMovieHandler::new(ESC_KEY, &mut app, active_radarr_block, None).handle();
|
||||||
|
|
||||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Movies.into());
|
assert_navigation_popped!(app, ActiveRadarrBlock::Movies.into());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mod test_handle_key_char {
|
mod test_handle_key_char {
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::{
|
use crate::{
|
||||||
|
assert_navigation_popped,
|
||||||
models::{
|
models::{
|
||||||
servarr_data::radarr::{modals::EditMovieModal, radarr_data::EDIT_MOVIE_SELECTION_BLOCKS},
|
|
||||||
BlockSelectionState,
|
BlockSelectionState,
|
||||||
|
servarr_data::radarr::{modals::EditMovieModal, radarr_data::EDIT_MOVIE_SELECTION_BLOCKS},
|
||||||
},
|
},
|
||||||
network::radarr_network::RadarrEvent,
|
network::radarr_network::RadarrEvent,
|
||||||
};
|
};
|
||||||
@@ -1128,12 +1122,12 @@ mod tests {
|
|||||||
)
|
)
|
||||||
.handle();
|
.handle();
|
||||||
|
|
||||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Movies.into());
|
assert_navigation_popped!(app, ActiveRadarrBlock::Movies.into());
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
app.data.radarr_data.prompt_confirm_action,
|
app.data.radarr_data.prompt_confirm_action,
|
||||||
Some(RadarrEvent::EditMovie(expected_edit_movie_params))
|
Some(RadarrEvent::EditMovie(expected_edit_movie_params))
|
||||||
);
|
);
|
||||||
assert!(app.data.radarr_data.edit_movie_modal.is_none());
|
assert_modal_absent!(app.data.radarr_data.edit_movie_modal);
|
||||||
assert!(app.should_refresh);
|
assert!(app.should_refresh);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1209,7 +1203,7 @@ mod tests {
|
|||||||
.build_edit_movie_params();
|
.build_edit_movie_params();
|
||||||
|
|
||||||
assert_eq!(edit_movie_params, expected_edit_movie_params);
|
assert_eq!(edit_movie_params, expected_edit_movie_params);
|
||||||
assert!(app.data.radarr_data.edit_movie_modal.is_none());
|
assert_modal_absent!(app.data.radarr_data.edit_movie_modal);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|||||||
@@ -5,15 +5,18 @@ mod tests {
|
|||||||
use std::cmp::Ordering;
|
use std::cmp::Ordering;
|
||||||
use strum::IntoEnumIterator;
|
use strum::IntoEnumIterator;
|
||||||
|
|
||||||
use crate::app::key_binding::DEFAULT_KEYBINDINGS;
|
|
||||||
use crate::app::App;
|
use crate::app::App;
|
||||||
|
use crate::app::key_binding::DEFAULT_KEYBINDINGS;
|
||||||
|
use crate::assert_modal_absent;
|
||||||
|
use crate::assert_modal_present;
|
||||||
|
use crate::assert_navigation_pushed;
|
||||||
use crate::event::Key;
|
use crate::event::Key;
|
||||||
use crate::handlers::radarr_handlers::library::{movies_sorting_options, LibraryHandler};
|
|
||||||
use crate::handlers::radarr_handlers::radarr_handler_test_utils::utils::movie;
|
|
||||||
use crate::handlers::KeyEventHandler;
|
use crate::handlers::KeyEventHandler;
|
||||||
|
use crate::handlers::radarr_handlers::library::{LibraryHandler, movies_sorting_options};
|
||||||
|
use crate::handlers::radarr_handlers::radarr_handler_test_utils::utils::movie;
|
||||||
use crate::models::radarr_models::Movie;
|
use crate::models::radarr_models::Movie;
|
||||||
use crate::models::servarr_data::radarr::radarr_data::{
|
use crate::models::servarr_data::radarr::radarr_data::{
|
||||||
ActiveRadarrBlock, ADD_MOVIE_BLOCKS, DELETE_MOVIE_BLOCKS, EDIT_MOVIE_BLOCKS, LIBRARY_BLOCKS,
|
ADD_MOVIE_BLOCKS, ActiveRadarrBlock, DELETE_MOVIE_BLOCKS, EDIT_MOVIE_BLOCKS, LIBRARY_BLOCKS,
|
||||||
MOVIE_DETAILS_BLOCKS,
|
MOVIE_DETAILS_BLOCKS,
|
||||||
};
|
};
|
||||||
use crate::models::servarr_models::Language;
|
use crate::models::servarr_models::Language;
|
||||||
@@ -72,6 +75,7 @@ mod tests {
|
|||||||
use rstest::rstest;
|
use rstest::rstest;
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
use crate::assert_navigation_pushed;
|
||||||
|
|
||||||
#[rstest]
|
#[rstest]
|
||||||
fn test_movie_tab_left(#[values(true, false)] is_ready: bool) {
|
fn test_movie_tab_left(#[values(true, false)] is_ready: bool) {
|
||||||
@@ -91,7 +95,7 @@ mod tests {
|
|||||||
app.data.radarr_data.main_tabs.get_active_route(),
|
app.data.radarr_data.main_tabs.get_active_route(),
|
||||||
ActiveRadarrBlock::System.into()
|
ActiveRadarrBlock::System.into()
|
||||||
);
|
);
|
||||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::System.into());
|
assert_navigation_pushed!(app, ActiveRadarrBlock::System.into());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[rstest]
|
#[rstest]
|
||||||
@@ -112,10 +116,7 @@ mod tests {
|
|||||||
app.data.radarr_data.main_tabs.get_active_route(),
|
app.data.radarr_data.main_tabs.get_active_route(),
|
||||||
ActiveRadarrBlock::Collections.into()
|
ActiveRadarrBlock::Collections.into()
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_navigation_pushed!(app, ActiveRadarrBlock::Collections.into());
|
||||||
app.get_current_route(),
|
|
||||||
ActiveRadarrBlock::Collections.into()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[rstest]
|
#[rstest]
|
||||||
@@ -147,9 +148,9 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
mod test_handle_submit {
|
mod test_handle_submit {
|
||||||
use pretty_assertions::assert_eq;
|
use crate::assert_navigation_popped;
|
||||||
|
|
||||||
use crate::network::radarr_network::RadarrEvent;
|
use crate::network::radarr_network::RadarrEvent;
|
||||||
|
use pretty_assertions::assert_eq;
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
@@ -166,10 +167,7 @@ mod tests {
|
|||||||
|
|
||||||
LibraryHandler::new(SUBMIT_KEY, &mut app, ActiveRadarrBlock::Movies, None).handle();
|
LibraryHandler::new(SUBMIT_KEY, &mut app, ActiveRadarrBlock::Movies, None).handle();
|
||||||
|
|
||||||
assert_eq!(
|
assert_navigation_pushed!(app, ActiveRadarrBlock::MovieDetails.into());
|
||||||
app.get_current_route(),
|
|
||||||
ActiveRadarrBlock::MovieDetails.into()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -209,11 +207,11 @@ mod tests {
|
|||||||
.handle();
|
.handle();
|
||||||
|
|
||||||
assert!(app.data.radarr_data.prompt_confirm);
|
assert!(app.data.radarr_data.prompt_confirm);
|
||||||
assert_eq!(
|
assert_some_eq_x!(
|
||||||
app.data.radarr_data.prompt_confirm_action,
|
&app.data.radarr_data.prompt_confirm_action,
|
||||||
Some(RadarrEvent::UpdateAllMovies)
|
&RadarrEvent::UpdateAllMovies
|
||||||
);
|
);
|
||||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Movies.into());
|
assert_navigation_popped!(app, ActiveRadarrBlock::Movies.into());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -236,19 +234,19 @@ mod tests {
|
|||||||
.handle();
|
.handle();
|
||||||
|
|
||||||
assert!(!app.data.radarr_data.prompt_confirm);
|
assert!(!app.data.radarr_data.prompt_confirm);
|
||||||
assert_eq!(app.data.radarr_data.prompt_confirm_action, None);
|
assert_none!(app.data.radarr_data.prompt_confirm_action);
|
||||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Movies.into());
|
assert_navigation_popped!(app, ActiveRadarrBlock::Movies.into());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mod test_handle_esc {
|
mod test_handle_esc {
|
||||||
use pretty_assertions::assert_eq;
|
|
||||||
use ratatui::widgets::TableState;
|
use ratatui::widgets::TableState;
|
||||||
|
|
||||||
use crate::models::servarr_data::radarr::radarr_data::radarr_test_utils::utils::create_test_radarr_data;
|
use crate::models::servarr_data::radarr::radarr_data::radarr_test_utils::utils::create_test_radarr_data;
|
||||||
use crate::models::stateful_table::StatefulTable;
|
use crate::models::stateful_table::StatefulTable;
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
use crate::assert_navigation_popped;
|
||||||
|
|
||||||
const ESC_KEY: Key = DEFAULT_KEYBINDINGS.esc.key;
|
const ESC_KEY: Key = DEFAULT_KEYBINDINGS.esc.key;
|
||||||
|
|
||||||
@@ -267,7 +265,7 @@ mod tests {
|
|||||||
)
|
)
|
||||||
.handle();
|
.handle();
|
||||||
|
|
||||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Movies.into());
|
assert_navigation_popped!(app, ActiveRadarrBlock::Movies.into());
|
||||||
assert!(!app.data.radarr_data.prompt_confirm);
|
assert!(!app.data.radarr_data.prompt_confirm);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -289,8 +287,8 @@ mod tests {
|
|||||||
|
|
||||||
LibraryHandler::new(ESC_KEY, &mut app, ActiveRadarrBlock::Movies, None).handle();
|
LibraryHandler::new(ESC_KEY, &mut app, ActiveRadarrBlock::Movies, None).handle();
|
||||||
|
|
||||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Movies.into());
|
assert_navigation_popped!(app, ActiveRadarrBlock::Movies.into());
|
||||||
assert!(app.error.text.is_empty());
|
assert_is_empty!(app.error.text);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -303,11 +301,11 @@ mod tests {
|
|||||||
use crate::models::radarr_models::MinimumAvailability;
|
use crate::models::radarr_models::MinimumAvailability;
|
||||||
use crate::models::servarr_data::radarr::radarr_data::radarr_test_utils::utils::create_test_radarr_data;
|
use crate::models::servarr_data::radarr::radarr_data::radarr_test_utils::utils::create_test_radarr_data;
|
||||||
use crate::models::servarr_data::radarr::radarr_data::{
|
use crate::models::servarr_data::radarr::radarr_data::{
|
||||||
RadarrData, EDIT_MOVIE_SELECTION_BLOCKS,
|
EDIT_MOVIE_SELECTION_BLOCKS, RadarrData,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::network::radarr_network::RadarrEvent;
|
use crate::network::radarr_network::RadarrEvent;
|
||||||
use crate::test_edit_movie_key;
|
use crate::{assert_navigation_popped, test_edit_movie_key};
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
@@ -328,12 +326,9 @@ mod tests {
|
|||||||
)
|
)
|
||||||
.handle();
|
.handle();
|
||||||
|
|
||||||
assert_eq!(
|
assert_navigation_pushed!(app, ActiveRadarrBlock::AddMovieSearchInput.into());
|
||||||
app.get_current_route(),
|
|
||||||
ActiveRadarrBlock::AddMovieSearchInput.into()
|
|
||||||
);
|
|
||||||
assert!(app.ignore_special_keys_for_textbox_input);
|
assert!(app.ignore_special_keys_for_textbox_input);
|
||||||
assert!(app.data.radarr_data.add_movie_search.is_some());
|
assert_modal_present!(app.data.radarr_data.add_movie_search);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -357,7 +352,7 @@ mod tests {
|
|||||||
|
|
||||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Movies.into());
|
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Movies.into());
|
||||||
assert!(!app.ignore_special_keys_for_textbox_input);
|
assert!(!app.ignore_special_keys_for_textbox_input);
|
||||||
assert!(app.data.radarr_data.add_movie_search.is_none());
|
assert_modal_absent!(app.data.radarr_data.add_movie_search);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -389,7 +384,7 @@ mod tests {
|
|||||||
.handle();
|
.handle();
|
||||||
|
|
||||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Movies.into());
|
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Movies.into());
|
||||||
assert!(app.data.radarr_data.edit_movie_modal.is_none());
|
assert_modal_absent!(app.data.radarr_data.edit_movie_modal);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -410,9 +405,9 @@ mod tests {
|
|||||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Movies.into());
|
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Movies.into());
|
||||||
assert!(app.data.radarr_data.prompt_confirm);
|
assert!(app.data.radarr_data.prompt_confirm);
|
||||||
assert!(app.is_routing);
|
assert!(app.is_routing);
|
||||||
assert_eq!(
|
assert_some_eq_x!(
|
||||||
app.data.radarr_data.prompt_confirm_action,
|
&app.data.radarr_data.prompt_confirm_action,
|
||||||
Some(RadarrEvent::ToggleMovieMonitoring(0))
|
&RadarrEvent::ToggleMovieMonitoring(0)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -433,7 +428,7 @@ mod tests {
|
|||||||
|
|
||||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Movies.into());
|
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Movies.into());
|
||||||
assert!(!app.data.radarr_data.prompt_confirm);
|
assert!(!app.data.radarr_data.prompt_confirm);
|
||||||
assert!(app.data.radarr_data.prompt_confirm_action.is_none());
|
assert_modal_absent!(app.data.radarr_data.prompt_confirm_action);
|
||||||
assert!(!app.is_routing);
|
assert!(!app.is_routing);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -454,10 +449,7 @@ mod tests {
|
|||||||
)
|
)
|
||||||
.handle();
|
.handle();
|
||||||
|
|
||||||
assert_eq!(
|
assert_navigation_pushed!(app, ActiveRadarrBlock::UpdateAllMoviesPrompt.into());
|
||||||
app.get_current_route(),
|
|
||||||
ActiveRadarrBlock::UpdateAllMoviesPrompt.into()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -500,7 +492,7 @@ mod tests {
|
|||||||
)
|
)
|
||||||
.handle();
|
.handle();
|
||||||
|
|
||||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Movies.into());
|
assert_navigation_pushed!(app, ActiveRadarrBlock::Movies.into());
|
||||||
assert!(app.should_refresh);
|
assert!(app.should_refresh);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -547,11 +539,11 @@ mod tests {
|
|||||||
.handle();
|
.handle();
|
||||||
|
|
||||||
assert!(app.data.radarr_data.prompt_confirm);
|
assert!(app.data.radarr_data.prompt_confirm);
|
||||||
assert_eq!(
|
assert_some_eq_x!(
|
||||||
app.data.radarr_data.prompt_confirm_action,
|
&app.data.radarr_data.prompt_confirm_action,
|
||||||
Some(RadarrEvent::UpdateAllMovies)
|
&RadarrEvent::UpdateAllMovies
|
||||||
);
|
);
|
||||||
assert_eq!(app.get_current_route(), ActiveRadarrBlock::Movies.into());
|
assert_navigation_popped!(app, ActiveRadarrBlock::Movies.into());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,17 +5,17 @@ use crate::handlers::radarr_handlers::library::add_movie_handler::AddMovieHandle
|
|||||||
use crate::handlers::radarr_handlers::library::delete_movie_handler::DeleteMovieHandler;
|
use crate::handlers::radarr_handlers::library::delete_movie_handler::DeleteMovieHandler;
|
||||||
use crate::handlers::radarr_handlers::library::edit_movie_handler::EditMovieHandler;
|
use crate::handlers::radarr_handlers::library::edit_movie_handler::EditMovieHandler;
|
||||||
use crate::handlers::radarr_handlers::library::movie_details_handler::MovieDetailsHandler;
|
use crate::handlers::radarr_handlers::library::movie_details_handler::MovieDetailsHandler;
|
||||||
use crate::handlers::{handle_clear_errors, handle_prompt_toggle, KeyEventHandler};
|
use crate::handlers::{KeyEventHandler, handle_clear_errors, handle_prompt_toggle};
|
||||||
|
|
||||||
use crate::handlers::table_handler::TableHandlingConfig;
|
use crate::handlers::table_handler::{TableHandlingConfig, handle_table};
|
||||||
|
use crate::matches_key;
|
||||||
use crate::models::radarr_models::Movie;
|
use crate::models::radarr_models::Movie;
|
||||||
use crate::models::servarr_data::radarr::radarr_data::{
|
use crate::models::servarr_data::radarr::radarr_data::{
|
||||||
ActiveRadarrBlock, DELETE_MOVIE_SELECTION_BLOCKS, EDIT_MOVIE_SELECTION_BLOCKS, LIBRARY_BLOCKS,
|
ActiveRadarrBlock, DELETE_MOVIE_SELECTION_BLOCKS, EDIT_MOVIE_SELECTION_BLOCKS, LIBRARY_BLOCKS,
|
||||||
};
|
};
|
||||||
use crate::models::stateful_table::SortOption;
|
use crate::models::stateful_table::SortOption;
|
||||||
use crate::models::{BlockSelectionState, HorizontallyScrollableText};
|
use crate::models::{BlockSelectionState, HorizontallyScrollableText, Route};
|
||||||
use crate::network::radarr_network::RadarrEvent;
|
use crate::network::radarr_network::RadarrEvent;
|
||||||
use crate::{handle_table_events, matches_key};
|
|
||||||
|
|
||||||
mod add_movie_handler;
|
mod add_movie_handler;
|
||||||
mod delete_movie_handler;
|
mod delete_movie_handler;
|
||||||
@@ -34,7 +34,6 @@ pub(super) struct LibraryHandler<'a, 'b> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl LibraryHandler<'_, '_> {
|
impl LibraryHandler<'_, '_> {
|
||||||
handle_table_events!(self, movies, self.app.data.radarr_data.movies, Movie);
|
|
||||||
fn extract_movie_id(&self) -> i64 {
|
fn extract_movie_id(&self) -> i64 {
|
||||||
self.app.data.radarr_data.movies.current_selection().id
|
self.app.data.radarr_data.movies.current_selection().id
|
||||||
}
|
}
|
||||||
@@ -44,7 +43,6 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for LibraryHandler<'a, '
|
|||||||
fn handle(&mut self) {
|
fn handle(&mut self) {
|
||||||
let movie_table_handling_config = TableHandlingConfig::new(ActiveRadarrBlock::Movies.into())
|
let movie_table_handling_config = TableHandlingConfig::new(ActiveRadarrBlock::Movies.into())
|
||||||
.sorting_block(ActiveRadarrBlock::MoviesSortPrompt.into())
|
.sorting_block(ActiveRadarrBlock::MoviesSortPrompt.into())
|
||||||
.sort_by_fn(|a: &Movie, b: &Movie| a.id.cmp(&b.id))
|
|
||||||
.sort_options(movies_sorting_options())
|
.sort_options(movies_sorting_options())
|
||||||
.searching_block(ActiveRadarrBlock::SearchMovie.into())
|
.searching_block(ActiveRadarrBlock::SearchMovie.into())
|
||||||
.search_error_block(ActiveRadarrBlock::SearchMovieError.into())
|
.search_error_block(ActiveRadarrBlock::SearchMovieError.into())
|
||||||
@@ -53,7 +51,11 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for LibraryHandler<'a, '
|
|||||||
.filter_error_block(ActiveRadarrBlock::FilterMoviesError.into())
|
.filter_error_block(ActiveRadarrBlock::FilterMoviesError.into())
|
||||||
.filter_field_fn(|movie| &movie.title.text);
|
.filter_field_fn(|movie| &movie.title.text);
|
||||||
|
|
||||||
if !self.handle_movies_table_events(movie_table_handling_config) {
|
if !handle_table(
|
||||||
|
self,
|
||||||
|
|app| &mut app.data.radarr_data.movies,
|
||||||
|
movie_table_handling_config,
|
||||||
|
) {
|
||||||
match self.active_radarr_block {
|
match self.active_radarr_block {
|
||||||
_ if AddMovieHandler::accepts(self.active_radarr_block) => {
|
_ if AddMovieHandler::accepts(self.active_radarr_block) => {
|
||||||
AddMovieHandler::new(self.key, self.app, self.active_radarr_block, self.context).handle();
|
AddMovieHandler::new(self.key, self.app, self.active_radarr_block, self.context).handle();
|
||||||
@@ -216,6 +218,14 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for LibraryHandler<'a, '
|
|||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn app_mut(&mut self) -> &mut App<'b> {
|
||||||
|
self.app
|
||||||
|
}
|
||||||
|
|
||||||
|
fn current_route(&self) -> Route {
|
||||||
|
self.app.get_current_route()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn movies_sorting_options() -> Vec<SortOption<Movie>> {
|
fn movies_sorting_options() -> Vec<SortOption<Movie>> {
|
||||||
|
|||||||
@@ -2,11 +2,10 @@ use serde_json::Number;
|
|||||||
|
|
||||||
use crate::app::App;
|
use crate::app::App;
|
||||||
use crate::event::Key;
|
use crate::event::Key;
|
||||||
use crate::handlers::table_handler::TableHandlingConfig;
|
use crate::handlers::table_handler::{TableHandlingConfig, handle_table};
|
||||||
use crate::handlers::{handle_prompt_toggle, KeyEventHandler};
|
use crate::handlers::{KeyEventHandler, handle_prompt_toggle};
|
||||||
use crate::models::radarr_models::{
|
use crate::matches_key;
|
||||||
Credit, MovieHistoryItem, RadarrRelease, RadarrReleaseDownloadBody,
|
use crate::models::radarr_models::{RadarrRelease, RadarrReleaseDownloadBody};
|
||||||
};
|
|
||||||
use crate::models::servarr_data::radarr::radarr_data::{
|
use crate::models::servarr_data::radarr::radarr_data::{
|
||||||
ActiveRadarrBlock, EDIT_MOVIE_SELECTION_BLOCKS, MOVIE_DETAILS_BLOCKS,
|
ActiveRadarrBlock, EDIT_MOVIE_SELECTION_BLOCKS, MOVIE_DETAILS_BLOCKS,
|
||||||
};
|
};
|
||||||
@@ -14,7 +13,6 @@ use crate::models::servarr_models::Language;
|
|||||||
use crate::models::stateful_table::SortOption;
|
use crate::models::stateful_table::SortOption;
|
||||||
use crate::models::{BlockSelectionState, Scrollable};
|
use crate::models::{BlockSelectionState, Scrollable};
|
||||||
use crate::network::radarr_network::RadarrEvent;
|
use crate::network::radarr_network::RadarrEvent;
|
||||||
use crate::{handle_table_events, matches_key};
|
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
#[path = "movie_details_handler_tests.rs"]
|
#[path = "movie_details_handler_tests.rs"]
|
||||||
@@ -28,59 +26,6 @@ pub(super) struct MovieDetailsHandler<'a, 'b> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl MovieDetailsHandler<'_, '_> {
|
impl MovieDetailsHandler<'_, '_> {
|
||||||
handle_table_events!(
|
|
||||||
self,
|
|
||||||
movie_releases,
|
|
||||||
self
|
|
||||||
.app
|
|
||||||
.data
|
|
||||||
.radarr_data
|
|
||||||
.movie_details_modal
|
|
||||||
.as_mut()
|
|
||||||
.unwrap()
|
|
||||||
.movie_releases,
|
|
||||||
RadarrRelease
|
|
||||||
);
|
|
||||||
handle_table_events!(
|
|
||||||
self,
|
|
||||||
movie_history,
|
|
||||||
self
|
|
||||||
.app
|
|
||||||
.data
|
|
||||||
.radarr_data
|
|
||||||
.movie_details_modal
|
|
||||||
.as_mut()
|
|
||||||
.unwrap()
|
|
||||||
.movie_history,
|
|
||||||
MovieHistoryItem
|
|
||||||
);
|
|
||||||
handle_table_events!(
|
|
||||||
self,
|
|
||||||
movie_cast,
|
|
||||||
self
|
|
||||||
.app
|
|
||||||
.data
|
|
||||||
.radarr_data
|
|
||||||
.movie_details_modal
|
|
||||||
.as_mut()
|
|
||||||
.unwrap()
|
|
||||||
.movie_cast,
|
|
||||||
Credit
|
|
||||||
);
|
|
||||||
handle_table_events!(
|
|
||||||
self,
|
|
||||||
movie_crew,
|
|
||||||
self
|
|
||||||
.app
|
|
||||||
.data
|
|
||||||
.radarr_data
|
|
||||||
.movie_details_modal
|
|
||||||
.as_mut()
|
|
||||||
.unwrap()
|
|
||||||
.movie_crew,
|
|
||||||
Credit
|
|
||||||
);
|
|
||||||
|
|
||||||
fn build_radarr_release_download_body(&self) -> RadarrReleaseDownloadBody {
|
fn build_radarr_release_download_body(&self) -> RadarrReleaseDownloadBody {
|
||||||
let movie_id = self.app.data.radarr_data.movies.current_selection().id;
|
let movie_id = self.app.data.radarr_data.movies.current_selection().id;
|
||||||
let (guid, indexer_id) = {
|
let (guid, indexer_id) = {
|
||||||
@@ -122,11 +67,55 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for MovieDetailsHandler<
|
|||||||
let movie_cast_table_handling_config = TableHandlingConfig::new(ActiveRadarrBlock::Cast.into());
|
let movie_cast_table_handling_config = TableHandlingConfig::new(ActiveRadarrBlock::Cast.into());
|
||||||
let movie_crew_table_handling_config = TableHandlingConfig::new(ActiveRadarrBlock::Crew.into());
|
let movie_crew_table_handling_config = TableHandlingConfig::new(ActiveRadarrBlock::Crew.into());
|
||||||
|
|
||||||
if !self.handle_movie_history_table_events(movie_history_table_handling_config)
|
if !handle_table(
|
||||||
&& !self.handle_movie_releases_table_events(movie_releases_table_handling_config)
|
self,
|
||||||
&& !self.handle_movie_cast_table_events(movie_cast_table_handling_config)
|
|app| {
|
||||||
&& !self.handle_movie_crew_table_events(movie_crew_table_handling_config)
|
&mut app
|
||||||
{
|
.data
|
||||||
|
.radarr_data
|
||||||
|
.movie_details_modal
|
||||||
|
.as_mut()
|
||||||
|
.unwrap()
|
||||||
|
.movie_history
|
||||||
|
},
|
||||||
|
movie_history_table_handling_config,
|
||||||
|
) && !handle_table(
|
||||||
|
self,
|
||||||
|
|app| {
|
||||||
|
&mut app
|
||||||
|
.data
|
||||||
|
.radarr_data
|
||||||
|
.movie_details_modal
|
||||||
|
.as_mut()
|
||||||
|
.unwrap()
|
||||||
|
.movie_releases
|
||||||
|
},
|
||||||
|
movie_releases_table_handling_config,
|
||||||
|
) && !handle_table(
|
||||||
|
self,
|
||||||
|
|app| {
|
||||||
|
&mut app
|
||||||
|
.data
|
||||||
|
.radarr_data
|
||||||
|
.movie_details_modal
|
||||||
|
.as_mut()
|
||||||
|
.unwrap()
|
||||||
|
.movie_cast
|
||||||
|
},
|
||||||
|
movie_cast_table_handling_config,
|
||||||
|
) && !handle_table(
|
||||||
|
self,
|
||||||
|
|app| {
|
||||||
|
&mut app
|
||||||
|
.data
|
||||||
|
.radarr_data
|
||||||
|
.movie_details_modal
|
||||||
|
.as_mut()
|
||||||
|
.unwrap()
|
||||||
|
.movie_crew
|
||||||
|
},
|
||||||
|
movie_crew_table_handling_config,
|
||||||
|
) {
|
||||||
self.handle_key_event();
|
self.handle_key_event();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -158,27 +147,23 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for MovieDetailsHandler<
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn is_ready(&self) -> bool {
|
fn is_ready(&self) -> bool {
|
||||||
if let Some(movie_details_modal) = &self.app.data.radarr_data.movie_details_modal {
|
let Some(movie_details_modal) = &self.app.data.radarr_data.movie_details_modal else {
|
||||||
match self.active_radarr_block {
|
return false;
|
||||||
ActiveRadarrBlock::MovieDetails => {
|
};
|
||||||
!self.app.is_loading && !movie_details_modal.movie_details.is_empty()
|
|
||||||
}
|
match self.active_radarr_block {
|
||||||
ActiveRadarrBlock::MovieHistory => {
|
ActiveRadarrBlock::MovieDetails => {
|
||||||
!self.app.is_loading && !movie_details_modal.movie_history.is_empty()
|
!self.app.is_loading && !movie_details_modal.movie_details.is_empty()
|
||||||
}
|
|
||||||
ActiveRadarrBlock::Cast => {
|
|
||||||
!self.app.is_loading && !movie_details_modal.movie_cast.is_empty()
|
|
||||||
}
|
|
||||||
ActiveRadarrBlock::Crew => {
|
|
||||||
!self.app.is_loading && !movie_details_modal.movie_crew.is_empty()
|
|
||||||
}
|
|
||||||
ActiveRadarrBlock::ManualSearch => {
|
|
||||||
!self.app.is_loading && !movie_details_modal.movie_releases.is_empty()
|
|
||||||
}
|
|
||||||
_ => !self.app.is_loading,
|
|
||||||
}
|
}
|
||||||
} else {
|
ActiveRadarrBlock::MovieHistory => {
|
||||||
false
|
!self.app.is_loading && !movie_details_modal.movie_history.is_empty()
|
||||||
|
}
|
||||||
|
ActiveRadarrBlock::Cast => !self.app.is_loading && !movie_details_modal.movie_cast.is_empty(),
|
||||||
|
ActiveRadarrBlock::Crew => !self.app.is_loading && !movie_details_modal.movie_crew.is_empty(),
|
||||||
|
ActiveRadarrBlock::ManualSearch => {
|
||||||
|
!self.app.is_loading && !movie_details_modal.movie_releases.is_empty()
|
||||||
|
}
|
||||||
|
_ => !self.app.is_loading,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -389,6 +374,14 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveRadarrBlock> for MovieDetailsHandler<
|
|||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn app_mut(&mut self) -> &mut App<'b> {
|
||||||
|
self.app
|
||||||
|
}
|
||||||
|
|
||||||
|
fn current_route(&self) -> crate::models::Route {
|
||||||
|
self.app.get_current_route()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn releases_sorting_options() -> Vec<SortOption<RadarrRelease>> {
|
fn releases_sorting_options() -> Vec<SortOption<RadarrRelease>> {
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user