Skip to content

Commit

Permalink
Try workflow to release mollie-sdk crate
Browse files Browse the repository at this point in the history
  • Loading branch information
pgoodjohn committed Dec 11, 2023
1 parent 140da64 commit 35d84ac
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 2 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/release-api-crate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Rust Build and Release

on:
push:
branches:
- main
paths:
- 'ctates/mollie_api/**'
release:
types: [created]

jobs:
build_and_test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- name: Build
run: cargo build --verbose
- name: Run tests
run: cargo test --verbose

release:
needs: build_and_test
runs-on: ubuntu-latest
if: github.event_name == 'release' && github.event.action == 'created'
steps:
- uses: actions/checkout@v2
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- name: Change to SDK directory
run: cd sdk
- name: Publish to Crates.io
uses: actions-rs/cargo@v1
with:
command: publish
args: --token ${{ secrets.CRATES_IO_TOKEN }}
2 changes: 1 addition & 1 deletion Cargo.lock

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

2 changes: 1 addition & 1 deletion crates/mollie_api/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "mollie_api"
version = "0.1.0"
version = "0.0.1"
edition.workspace = true
homepage.workspace = true
repository.workspace = true
Expand Down
18 changes: 18 additions & 0 deletions crates/mollie_api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,3 +160,21 @@ impl<'c> Mollie<'c> {
organizations::OrganizationsApi::new(&self.api_client)
}
}

#[cfg(test)]
mod client_tests {
use super::Mollie;

#[tokio::test]
async fn test_organization_api_is_unauthorized() {
let auth_token = String::from("access_invalidAccessToken");
let client = Mollie::build(&auth_token);

match client.organizations().me().await {
Ok(_r) => panic!("Expected API to return a 401 error code, but got a valid response."),
Err(e) => {
assert!(e.to_string().contains("Mollie API Error 401: Unauthorized Request - Missing authentication, or failed to authenticate."));
}
}
}
}

0 comments on commit 35d84ac

Please # to comment.