Skip to content

Commit

Permalink
implement some basic online tests
Browse files Browse the repository at this point in the history
Signed-off-by: Andrew Pan <[email protected]>
  • Loading branch information
tnytown committed Feb 16, 2024
1 parent a78df20 commit f0fc9a7
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 30 deletions.
73 changes: 43 additions & 30 deletions Cargo.lock

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

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,6 @@ prettyplease = "0.1.25"
progenitor = "0.5"
syn = "1.0"
serde_json = "1.0"

[dev-dependencies]
tokio = { version = "1", features = ["macros"] }
27 changes: 27 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
macro_rules! include_service {
($name:ident) => {
#[allow(warnings)]
#[cfg(not(doctest))]
pub mod $name {
include!(concat!(
env!("OUT_DIR"),
Expand All @@ -12,6 +13,7 @@ macro_rules! include_service {
};
}

#[cfg(not(doctest))]
pub mod types {
use crate::rekor::types as rekor;
use serde::{Deserialize, Serialize};
Expand All @@ -34,3 +36,28 @@ pub mod types {

include_service!(fulcio);
include_service!(rekor);

/// Basic online tests to ensure that the generated client isn't completely broken.
#[cfg(test)]
mod tests {
use crate::{rekor, fulcio};

const REKOR_URL: &str = "https://rekor.sigstore.dev";
const FULCIO_URL: &str = "https://fulcio.sigstore.dev";

#[tokio::test]
async fn rekor_get_log_info() {
let client = rekor::Client::new(REKOR_URL);

let response = client.get_log_info(None).await;
assert!(response.is_ok(), "{:?}", response.unwrap_err());
}

#[tokio::test]
async fn fulcio_get_configuration() {
let client = fulcio::Client::new(FULCIO_URL);

let response = client.ca_get_configuration().await;
assert!(response.is_ok(), "{:?}", response.unwrap_err());
}
}

0 comments on commit f0fc9a7

Please sign in to comment.