Compare commits
10 commits
Author | SHA1 | Date | |
---|---|---|---|
|
43fa1c68f3 | ||
5c7201abe7 | |||
|
4d546ee57c | ||
2df1cfe11f | |||
|
18a253e433 | ||
59fa127967 | |||
2e5c80875e | |||
|
ad173c17ee | ||
|
4206289a10 | ||
a91dcb3a4a |
7 changed files with 104 additions and 42 deletions
|
@ -16,21 +16,23 @@ jobs:
|
||||||
release-plz:
|
release-plz:
|
||||||
name: Release-plz
|
name: Release-plz
|
||||||
runs-on: docker
|
runs-on: docker
|
||||||
|
|
||||||
|
container:
|
||||||
|
image:
|
||||||
|
git.kemitix.net/kemitix/rust:v4.0.1
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|
||||||
- name: Run release-plz release-pr
|
- name: Run release-plz release-pr
|
||||||
uses: https://git.kemitix.net/kemitix/rust@v2.5.0
|
run: release-plz release-pr --backend gitea --git-token ${{ secrets.FORGEJO_TOKEN }}
|
||||||
with:
|
|
||||||
args: release-plz release-pr --backend gitea --git-token ${{ secrets.FORGEJO_TOKEN }}
|
|
||||||
env:
|
|
||||||
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
|
|
||||||
- name: Run release-plz release
|
|
||||||
uses: https://git.kemitix.net/kemitix/rust@v2.5.0
|
|
||||||
with:
|
|
||||||
args: release-plz release --backend gitea --git-token ${{ secrets.FORGEJO_TOKEN }}
|
|
||||||
env:
|
env:
|
||||||
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
|
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
|
||||||
|
|
||||||
|
- name: Run release-plz release
|
||||||
|
run: release-plz release --backend gitea --git-token ${{ secrets.FORGEJO_TOKEN }}
|
||||||
|
env:
|
||||||
|
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
|
||||||
|
|
|
@ -16,6 +16,10 @@ jobs:
|
||||||
build:
|
build:
|
||||||
runs-on: docker
|
runs-on: docker
|
||||||
|
|
||||||
|
container:
|
||||||
|
image:
|
||||||
|
git.kemitix.net/kemitix/rust:v4.0.1
|
||||||
|
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
toolchain:
|
toolchain:
|
||||||
|
@ -26,36 +30,27 @@ jobs:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Ignored Files
|
||||||
|
run: check-for-ignored
|
||||||
|
|
||||||
- name: Check TODOs
|
- name: Check TODOs
|
||||||
uses: kemitix/todo-checker@v1.1.0
|
uses: https://git.kemitix.net/kemitix/forgejo-todo-checker@v1.3.0
|
||||||
|
|
||||||
- name: Machete
|
- name: Machete
|
||||||
uses: https://git.kemitix.net/kemitix/rust@v2.5.0
|
run: cargo +${{ matrix.toolchain.name }} machete
|
||||||
with:
|
|
||||||
args: ${{ matrix.toolchain.name }} cargo machete
|
|
||||||
|
|
||||||
- name: Format
|
- name: Format
|
||||||
uses: https://git.kemitix.net/kemitix/rust@v2.5.0
|
run: cargo +${{ matrix.toolchain.name }} fmt --all --check
|
||||||
with:
|
|
||||||
args: ${{ matrix.toolchain.name }} cargo fmt --all -- --check
|
|
||||||
|
|
||||||
- name: Clippy
|
- name: Clippy
|
||||||
uses: https://git.kemitix.net/kemitix/rust@v2.5.0
|
run: cargo +${{ matrix.toolchain.name }} hack --feature-powerset clippy
|
||||||
with:
|
|
||||||
args: ${{ matrix.toolchain.name }} cargo hack --feature-powerset clippy
|
|
||||||
|
|
||||||
- name: Build
|
- name: Build
|
||||||
uses: https://git.kemitix.net/kemitix/rust@v2.5.0
|
run: cargo +${{ matrix.toolchain.name }} hack --feature-powerset build
|
||||||
with:
|
|
||||||
args: ${{ matrix.toolchain.name }} cargo hack --feature-powerset build
|
|
||||||
|
|
||||||
- name: Test
|
- name: Test
|
||||||
uses: https://git.kemitix.net/kemitix/rust@v2.5.0
|
run: cargo +${{ matrix.toolchain.name }} hack --feature-powerset test
|
||||||
with:
|
|
||||||
args: ${{ matrix.toolchain.name }} cargo hack --feature-powerset test
|
|
||||||
|
|
||||||
- name: Mutations
|
- name: Mutations
|
||||||
uses: https://git.kemitix.net/kemitix/rust@v2.5.0
|
run: cargo +${{ matrix.toolchain.name }} mutants -vV --in-place
|
||||||
with:
|
|
||||||
args: ${{ matrix.toolchain.name }} cargo mutants -vV --in-place
|
|
||||||
|
|
||||||
|
|
17
CHANGELOG.md
17
CHANGELOG.md
|
@ -7,6 +7,23 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
## [5.1.0](https://git.kemitix.net/kemitix/kxio/compare/v5.0.0...v5.1.0) - 2025-01-18
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- replace openssl with rustls
|
||||||
|
|
||||||
|
### Other
|
||||||
|
|
||||||
|
- *(deps)* update git.kemitix.net/kemitix/rust docker tag to v4
|
||||||
|
- use check-for-ignored
|
||||||
|
- *(deps)* update git.kemitix.net/kemitix/rust docker tag to v3.1.0
|
||||||
|
- check for ignored files being included in repo
|
||||||
|
- upgrade kemitix/rust v3
|
||||||
|
- *(deps)* update https://git.kemitix.net/kemitix/rust action to v2.6.0
|
||||||
|
- *(deps)* update https://git.kemitix.net/kemitix/rust action to v2.5.1
|
||||||
|
- *(net)* add explicit tests for assert_no_unused_plans
|
||||||
|
|
||||||
## [5.0.0](https://git.kemitix.net/kemitix/kxio/compare/v4.0.1...v5.0.0) - 2024-12-29
|
## [5.0.0](https://git.kemitix.net/kemitix/kxio/compare/v4.0.1...v5.0.0) - 2024-12-29
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
22
Cargo.toml
22
Cargo.toml
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "kxio"
|
name = "kxio"
|
||||||
version = "5.0.0"
|
version = "5.1.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
authors = ["Paul Campbell <pcampbell@kemitix.net>"]
|
authors = ["Paul Campbell <pcampbell@kemitix.net>"]
|
||||||
description = "Provides injectable Filesystem and Network resources to make code more testable"
|
description = "Provides injectable Filesystem and Network resources to make code more testable"
|
||||||
|
@ -11,22 +11,19 @@ exclude = [".cargo_home"]
|
||||||
[lints.rust]
|
[lints.rust]
|
||||||
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(tarpaulin_include)'] }
|
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(tarpaulin_include)'] }
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
base64 = "0.22"
|
base64 = "0.22"
|
||||||
bytes = "1.8"
|
bytes = "1.8"
|
||||||
derive_more = { version = "1.0", features = [
|
derive_more = { version = "1.0", features = ["constructor", "display", "from"] }
|
||||||
"constructor",
|
|
||||||
"display",
|
|
||||||
"from"
|
|
||||||
] }
|
|
||||||
http = "1.1"
|
http = "1.1"
|
||||||
path-clean = "1.0"
|
path-clean = "1.0"
|
||||||
reqwest = { version = "0.12", features = [ "json" ] }
|
reqwest = { version = "0.12", default-features = false, features = [
|
||||||
|
"json",
|
||||||
|
"rustls-tls",
|
||||||
|
] }
|
||||||
url = "2.5"
|
url = "2.5"
|
||||||
tempfile = "3.10"
|
tempfile = "3.10"
|
||||||
tokio = { version = "1.41", features = [ "sync" ] }
|
tokio = { version = "1.41", features = ["sync"] }
|
||||||
tracing = "0.1"
|
tracing = "0.1"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
|
@ -34,10 +31,7 @@ assert2 = "0.3"
|
||||||
mutants = "0.0"
|
mutants = "0.0"
|
||||||
pretty_assertions = "1.4"
|
pretty_assertions = "1.4"
|
||||||
test-log = "0.2"
|
test-log = "0.2"
|
||||||
tokio = { version = "1.41", features = [
|
tokio = { version = "1.41", features = ["macros", "rt-multi-thread"] }
|
||||||
"macros",
|
|
||||||
"rt-multi-thread"
|
|
||||||
] }
|
|
||||||
tokio-test = "0.4"
|
tokio-test = "0.4"
|
||||||
|
|
||||||
[package.metadata.bin]
|
[package.metadata.bin]
|
||||||
|
|
|
@ -151,6 +151,8 @@ mod tests {
|
||||||
|
|
||||||
assert_eq!(contents, "contents");
|
assert_eq!(contents, "contents");
|
||||||
|
|
||||||
|
net.assert_no_unused_plans();
|
||||||
|
|
||||||
// not needed for this test, but should it be needed, we can avoid checking for any
|
// not needed for this test, but should it be needed, we can avoid checking for any
|
||||||
// unconsumed request matches.
|
// unconsumed request matches.
|
||||||
// let mock_net = kxio::net::MockNet::try_from(net).expect("recover mock");
|
// let mock_net = kxio::net::MockNet::try_from(net).expect("recover mock");
|
||||||
|
|
6
justfile
6
justfile
|
@ -10,6 +10,12 @@ build:
|
||||||
cargo test --example get
|
cargo test --example get
|
||||||
cargo mutants --jobs 4
|
cargo mutants --jobs 4
|
||||||
|
|
||||||
|
test-in-docker:
|
||||||
|
docker run --rm -v $PWD:/app/ git.kemitix.net/kemitix/rust:latest cargo test
|
||||||
|
|
||||||
|
shell-in-docker:
|
||||||
|
docker run --rm -it -v $PWD:/app/ git.kemitix.net/kemitix/rust:latest bash
|
||||||
|
|
||||||
doc-test:
|
doc-test:
|
||||||
cargo doc
|
cargo doc
|
||||||
cargo test
|
cargo test
|
||||||
|
|
46
tests/net.rs
46
tests/net.rs
|
@ -53,6 +53,52 @@ async fn test_get_url() {
|
||||||
assert_eq!(response.bytes().await.expect("response body"), "Get OK");
|
assert_eq!(response.bytes().await.expect("response body"), "Get OK");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tokio::test]
|
||||||
|
async fn test_when_all_plans_match_assert_is_ok() {
|
||||||
|
//given
|
||||||
|
let mock_net = kxio::net::mock();
|
||||||
|
|
||||||
|
let url = "https://www.example.com";
|
||||||
|
|
||||||
|
mock_net
|
||||||
|
.on()
|
||||||
|
.get(url)
|
||||||
|
.respond(StatusCode::OK)
|
||||||
|
.body("Get OK")
|
||||||
|
.expect("mock");
|
||||||
|
let net = Net::from(mock_net);
|
||||||
|
|
||||||
|
//when
|
||||||
|
let _response = net.get(url).send().await.expect("response");
|
||||||
|
|
||||||
|
//then
|
||||||
|
net.assert_no_unused_plans();
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tokio::test]
|
||||||
|
#[should_panic]
|
||||||
|
async fn test_when_not_all_plans_match_assert_fails() {
|
||||||
|
//given
|
||||||
|
let mock_net = kxio::net::mock();
|
||||||
|
|
||||||
|
let url = "https://www.example.com";
|
||||||
|
|
||||||
|
mock_net
|
||||||
|
.on()
|
||||||
|
.get(url)
|
||||||
|
.respond(StatusCode::OK)
|
||||||
|
.body("Get OK")
|
||||||
|
.expect("mock");
|
||||||
|
let net = Net::from(mock_net);
|
||||||
|
|
||||||
|
//when
|
||||||
|
// request is not made
|
||||||
|
// let _response = net.get(url).send().await.expect("response");
|
||||||
|
|
||||||
|
//then
|
||||||
|
net.assert_no_unused_plans();
|
||||||
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn test_post_url() {
|
async fn test_post_url() {
|
||||||
//given
|
//given
|
||||||
|
|
Loading…
Add table
Reference in a new issue