Files
markbase/tests/command_test.rs
Warren e3d6b60825 feat: MarkBase initial version
Phase 1 (Infrastructure):
- Docs: README.md, AGENTS.md, CHANGELOG.md
- Tests: 26 tests (modes_test, filetree_api_test)
- Examples: examples/sample.md, sample.json
- CI/CD: .gitea/workflows/test.yml, release.yml
- Runner: configuration scripts and guides

Phase 2 (Quality):
- Code quality: rustfmt/clippy config
- Security: environment variables
- Test coverage: 62 tests (+36)
- Documentation: CONTRIBUTING.md, docs/api.yaml
- Showcase: demo_features.md, developer_quickstart.md

Test coverage: 75%
Test pass rate: 100%
2026-05-16 15:37:37 +08:00

49 lines
1.5 KiB
Rust

use axum::response::{IntoResponse, Json};
use markbase::command::{get_commands, post_command};
use serde_json::json;
#[tokio::test]
async fn test_post_command_basic() {
let body = json!({"cmd": "test_cmd", "val": "test_value"});
let response = post_command(Json(body)).await;
let response_json = response.into_response();
//驗證響應狀態碼
assert_eq!(response_json.status(), axum::http::StatusCode::OK);
}
#[tokio::test]
async fn test_post_command_voice() {
let body = json!({"cmd": "test_voice", "val": "zh_TW", "out": "Display Audio"});
let response = post_command(Json(body)).await;
let response_json = response.into_response();
assert_eq!(response_json.status(), axum::http::StatusCode::OK);
}
#[tokio::test]
async fn test_post_command_vol_up() {
let body = json!({"cmd": "vol_up"});
let response = post_command(Json(body)).await;
let response_json = response.into_response();
assert_eq!(response_json.status(), axum::http::StatusCode::OK);
}
#[tokio::test]
async fn test_post_command_vol_down() {
let body = json!({"cmd": "vol_down"});
let response = post_command(Json(body)).await;
let response_json = response.into_response();
assert_eq!(response_json.status(), axum::http::StatusCode::OK);
}
#[tokio::test]
async fn test_get_commands_empty() {
let response = get_commands().await;
let response_json = response.into_response();
assert_eq!(response_json.status(), axum::http::StatusCode::OK);
}