Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add test for report message #20

Merged
merged 68 commits into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
53dadcc
outcome -> report
hayas1 Oct 22, 2024
120acc8
remove large test
hayas1 Oct 22, 2024
24f88f5
add unit test
hayas1 Oct 22, 2024
27e98a4
random endpoint
hayas1 Oct 22, 2024
8ce4b24
float
hayas1 Oct 22, 2024
239c435
response
hayas1 Oct 22, 2024
a096726
mv
hayas1 Oct 22, 2024
3526ef9
modify path
hayas1 Oct 22, 2024
b37ea39
example-http-server -> relentless-dev-server
hayas1 Oct 22, 2024
89811cc
example server -> develop server
hayas1 Oct 22, 2024
49a2255
modify
hayas1 Oct 22, 2024
c7246fe
example
hayas1 Oct 22, 2024
753052a
remove needless result
hayas1 Oct 23, 2024
b9c464e
randjson (uniform)
hayas1 Oct 23, 2024
6e49d4a
standard rand
hayas1 Oct 23, 2024
eed36d6
doc
hayas1 Oct 23, 2024
03c53a6
distribution
hayas1 Oct 23, 2024
aaef890
Normal
hayas1 Oct 23, 2024
f7682c4
binomial
hayas1 Oct 23, 2024
0d851f5
TODO
hayas1 Oct 23, 2024
b48ae90
test for random
hayas1 Oct 23, 2024
ff66de7
modify health test
hayas1 Oct 23, 2024
f090f01
modify example's feature
hayas1 Oct 23, 2024
5259cd1
test error message
hayas1 Oct 23, 2024
27fa620
distribution
hayas1 Oct 24, 2024
7431e83
normal / binomial
hayas1 Oct 24, 2024
a1d8a95
random handler
hayas1 Oct 24, 2024
5abe13a
uniform
hayas1 Oct 24, 2024
54d73fb
refactor
hayas1 Oct 24, 2024
6cad035
length
hayas1 Oct 24, 2024
8557a9a
string length
hayas1 Oct 24, 2024
1f6d30c
test for random string length
hayas1 Oct 24, 2024
9bc67b6
uniform implementation
hayas1 Oct 24, 2024
d947b2a
ownership
hayas1 Oct 24, 2024
fe7d568
implement RangeBounds
hayas1 Oct 24, 2024
62e3ea6
inclusive
hayas1 Oct 24, 2024
9a7ec16
prepare: error handling
hayas1 Oct 24, 2024
2cf9e60
error handling
hayas1 Oct 24, 2024
fdfa26c
uniform for float
hayas1 Oct 24, 2024
7641f13
Merge branch 'master' into feat/test-report-message
hayas1 Oct 24, 2024
82f402a
TODO: float max
hayas1 Oct 25, 2024
b690244
echo server
hayas1 Oct 25, 2024
79b106b
json
hayas1 Oct 25, 2024
152f8d9
add test for echo
hayas1 Oct 25, 2024
742b91e
jsonizer
hayas1 Oct 26, 2024
534fa0a
modift jsonizer
hayas1 Oct 26, 2024
b920050
rich json endpoint
hayas1 Oct 26, 2024
ac3ce54
escape
hayas1 Oct 26, 2024
5c5669b
basics
hayas1 Oct 26, 2024
3ed8e6e
mime
hayas1 Oct 26, 2024
4c8ca01
yaml / toml config
hayas1 Oct 26, 2024
5a5d39b
feature
hayas1 Oct 26, 2024
f302f3a
repeat feature test
hayas1 Oct 26, 2024
96b5561
parse test
hayas1 Oct 26, 2024
21f70bb
valid config
hayas1 Oct 26, 2024
2c77764
different struct
hayas1 Oct 26, 2024
60f08cc
const
hayas1 Oct 27, 2024
37ab212
mod console report
hayas1 Oct 27, 2024
c3296b3
modify double report
hayas1 Oct 27, 2024
79b695d
remove empty line
hayas1 Oct 27, 2024
0b99eae
`report_with` interface
hayas1 Oct 27, 2024
ca8c9b3
mut ref
hayas1 Oct 27, 2024
3335e97
todo
hayas1 Oct 28, 2024
3c93d55
rename
hayas1 Oct 28, 2024
98afc3f
validate config test
hayas1 Oct 28, 2024
734164a
allow config test
hayas1 Oct 28, 2024
b89c707
feature
hayas1 Oct 28, 2024
32b4ff6
actions feature
hayas1 Oct 28, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
name: Run Example Http Server
name: Run Develop Http Server

inputs:
manifest-path:
description: Manifest path to Cargo.toml of the example http server
description: Manifest path to Cargo.toml of the develop http server
required: false
default: examples/server/http/Cargo.toml
default: dev/server/Cargo.toml
port:
description: Port to listen on
required: false
Expand Down Expand Up @@ -35,7 +35,7 @@ runs:
${{ steps.cargo-home.outputs.path }}
key: cargo-${{ hashFiles('**/Cargo.toml') }}

- name: Run example http server
- name: Run develop http server
shell: bash
env:
PORT: ${{ inputs.port }}
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ jobs:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable

- name: Release test for example server
run: cargo test --release --manifest-path examples/server/http/Cargo.toml
- name: Release test for develop server
run: cargo test --release --manifest-path dev/server/Cargo.toml

- name: Release test
run: cargo test --release
- name: Release test without cli feature
run: cargo test --verbose --features=json --features=yaml
run: cargo test --verbose --no-default-features --features=json --features=yaml
- name: Release test with cli feature
run: cargo test --verbose --features=json --features=yaml --features=cli
run: cargo test --verbose --no-default-features --features=json --features=yaml --features=cli
- name: Run doc
run: cargo doc --no-deps
- name: Coverage
Expand Down
16 changes: 9 additions & 7 deletions .github/workflows/pullrequest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,14 @@ jobs:
${{ steps.cargo-home.outputs.path }}
key: cargo-${{ hashFiles('**/Cargo.toml') }}

- run: cargo test --verbose --manifest-path examples/server/http/Cargo.toml
- run: cargo fmt --check --manifest-path examples/server/http/Cargo.toml
- run: cargo clippy --tests --manifest-path examples/server/http/Cargo.toml -- --deny warnings
- run: cargo test --verbose --manifest-path dev/server/Cargo.toml
- run: cargo fmt --check --manifest-path dev/server/Cargo.toml
- run: cargo clippy --tests --manifest-path dev/server/Cargo.toml -- --deny warnings

- run: cargo test --verbose
- run: cargo test --verbose --no-default-features
- run: cargo test --verbose --no-default-features --features=json
- run: cargo test --verbose --no-default-features --features=yaml
- run: cargo test --verbose --no-default-features --features=json --features=yaml
- run: cargo test --verbose --no-default-features --features=json --features=yaml --features=cli
- run: cargo fmt --check
Expand Down Expand Up @@ -62,12 +64,12 @@ jobs:
${{ steps.cargo-home.outputs.path }}
key: cargo-${{ hashFiles('**/Cargo.toml') }}

- name: Run example http server (actual)
uses: ./.github/actions/example-http-server
- name: Run develop http server (actual)
uses: ./.github/actions/run-develop-server
with:
port: 3001
- name: Run example http server (expect)
uses: ./.github/actions/example-http-server
- name: Run develop http server (expect)
uses: ./.github/actions/run-develop-server
with:
port: 3000

Expand Down
126 changes: 106 additions & 20 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@ console = { version = "0.15.8", optional = true }


[dev-dependencies]
example-http-server = { path = "examples/server/http" }
relentless-dev-server = { path = "dev/server" }
axum = "0.7.5"
glob = "0.3.1"
httptest = "0.16.1"
assert-json-diff = "2.0.2"

[workspace]
members = ["examples/server/*"]
members = ["dev/server"]

[badges]
github = { repository = "hayas1/relentless", workflow = "Master" }
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ testcases:
...more examples in <https://github.com/hayas1/relentless/tree/master/examples/config>

#### Run API for testing
If you have not API for testing, you can use `example-http-server`
If you have no API for testing, you can use `relentless-dev-server`
```sh
cargo install --git https://github.com/hayas1/relentless example-http-server
example-http-server
cargo install --git https://github.com/hayas1/relentless relentless-dev-server
relentless-dev-server
```

### Run CLI
Expand All @@ -54,7 +54,7 @@ TODO (feature)
Same config can be used in both binary and library. See [Binary section](#prepare-config).

#### Run API for testing
Same example-http-server can be used in both binary and library. See [Binary section](#run-api-for-testing).
Same relentless-dev-server can be used in both binary and library. See [Binary section](#run-api-for-testing).

### Run Testing
TODO <https://github.com/hayas1/relentless/blob/master/tests/tests.rs>
Expand Down
7 changes: 6 additions & 1 deletion examples/server/http/Cargo.toml → dev/server/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "example-http-server"
name = "relentless-dev-server"
version = "0.1.0"
edition = "2021"

Expand All @@ -8,6 +8,8 @@ axum = { version = "0.7.7", features = ["tokio", "original-uri"] }
chrono = { version = "0.4.38", features = ["serde"] }
http-serde = "2.1.1"
num = { version = "0.4.3", features = ["serde"] }
rand = "0.8.5"
rand_distr = "0.4.3"
serde = { version = "1.0.210", features = ["derive"] }
serde_json = "1.0.132"
# serde_qs = "0.13.0"
Expand All @@ -18,3 +20,6 @@ tower = { version = "0.5.1", features = ["util"] }
tower-http = { version = "0.6.1", features = ["normalize-path"] }
tracing = "0.1.40"
tracing-subscriber = "0.3.18"

[dev-dependencies]
mime = "0.3.17"
File renamed without changes.
52 changes: 52 additions & 0 deletions examples/server/http/src/error.rs → dev/server/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,3 +166,55 @@ pub mod counter {
}
}
}

pub mod random {
use crate::route::random::DistRangeParam;

use super::*;

#[derive(Error, Debug, Clone, PartialEq, Eq)]
pub enum RandomError<T: Display> {
#[error("`{0}` is empty range")]
EmptyRange(DistRangeParam<T>),
}

impl<T: Display + Debug + Send + Sync + 'static> IntoResponse for RandomError<T> {
fn into_response(self) -> Response {
AppErrorDetail::<kind::BadRequest, _>::detail_display(self).into_response()
}
}
}

pub mod echo {
use serde_json::Value;

use super::*;

#[derive(Error, Debug, Clone, PartialEq, Eq)]
pub enum EchoError {
#[error(transparent)]
JsonizeError(#[from] JsonizeError),
}
impl IntoResponse for EchoError {
fn into_response(self) -> Response {
AppErrorDetail::<kind::BadRequest, _>::detail_display(self).into_response()
}
}

#[derive(Error, Debug, Clone, PartialEq, Eq)]
pub enum JsonizeError {
#[error("conflict in {0:?}, already {1} but want {2}")]
Conflict(String, Value, Value),
#[error("cannot parse value as integer: {0}")]
CannotParseInt(#[from] std::num::ParseIntError),
#[error("cannot parse value as float: {0}")]
CannotParseFloat(#[from] std::num::ParseFloatError),
#[error("unknown function: {0}")]
UnknownFunction(String),
}
impl IntoResponse for JsonizeError {
fn into_response(self) -> Response {
AppErrorDetail::<kind::BadRequest, _>::detail_display(self).into_response()
}
}
}
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use example_http_server::{env::Env, serve};
use relentless_dev_server::{env::Env, serve};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
Expand Down
Loading