No description
- Rust 100%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
| src | ||
| tests | ||
| .gitignore | ||
| Cargo.lock | ||
| Cargo.toml | ||
| LICENSE | ||
| mise.toml | ||
| README.md | ||
forgejo-testcontainer
A small testcontainers image for Forgejo.
Add dependency:
forgejo-testcontainer = "0.1"
use forgejo_testcontainer::{Forgejo, HTTP_PORT};
use reqwest::Client;
use testcontainers::runners::AsyncRunner;
#[tokio::test]
async fn use_forgejo() -> Result<(), Box<dyn std::error::Error>> {
let forgejo = Forgejo::default()
.with_admin_user("test-admin", "test-password", "admin@example.test")
.start()
.await?;
let url = format!(
"http://{}:{}",
forgejo.get_host().await?,
forgejo.get_host_port_ipv4(HTTP_PORT).await?
);
let response = Client::new()
.get(format!("{url}/api/v1/user"))
.basic_auth(
forgejo.image().admin_username(),
Some(forgejo.image().admin_password()),
)
.send()
.await?;
assert!(response.status().is_success());
Ok(())
}
Use with_config(section, key, value) to set additional Forgejo configuration.
Compatibility
0.1.xsupports Forgejo16.x