Skip to content

Commit eecf705

Browse files
committed
Add examples for testing
1 parent 6b438ed commit eecf705

4 files changed

Lines changed: 41 additions & 0 deletions

File tree

‎.DS_Store‎

6 KB
Binary file not shown.

‎examples/clash.rs‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#[path = "../src/base/clash.rs"]
2+
#[allow(dead_code)]
3+
mod clash;
4+
5+
#[tokio::main]
6+
async fn main() {
7+
dotenv::dotenv().ok();
8+
9+
let battle = clash::last_battles().await;
10+
dbg!(battle);
11+
}

‎examples/db.rs‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
use sqlx::postgres::PgPoolOptions;
2+
3+
#[tokio::main]
4+
async fn main() -> Result<(), sqlx::Error> {
5+
dotenv::dotenv().ok();
6+
7+
let database_url = std::env::var("DATABASE_URL").expect("DATABASE_URL not set");
8+
let pool = PgPoolOptions::new().connect(&database_url).await?;
9+
10+
let row: (String,) = sqlx::query_as("SELECT version()").fetch_one(&pool).await?;
11+
12+
println!("PostgreSQL version: {}", row.0);
13+
14+
Ok(())
15+
}

‎examples/github.rs‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
use crate::github::update_github_location;
2+
3+
#[path = "../src/base/github.rs"]
4+
#[allow(dead_code)]
5+
mod github;
6+
7+
#[tokio::main]
8+
async fn main() {
9+
dotenv::dotenv().ok();
10+
11+
let location = "San Francisco";
12+
13+
let res = update_github_location(location).await;
14+
dbg!(res);
15+
}

0 commit comments

Comments
 (0)