-
-
Notifications
You must be signed in to change notification settings - Fork 296
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix compilation error + adding template test
- Loading branch information
1 parent
6ca79ed
commit 32afb80
Showing
5 changed files
with
132 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
loco-gen/tests/templates/snapshots/generate[shuttle.rs]@deployment.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
--- | ||
source: loco-gen/tests/templates/deployment.rs | ||
expression: "fs::read_to_string(tree_fs.root.join(\"src\").join(\"bin\").join(\"shuttle.rs\")).expect(\"shuttle rs missing\")" | ||
--- | ||
use loco_rs::boot::{create_app, StartMode}; | ||
use loco_rs::environment::Environment; | ||
use tester::app::App; | ||
use migration::Migrator; | ||
use shuttle_runtime::DeploymentMetadata; | ||
|
||
#[shuttle_runtime::main] | ||
async fn main( | ||
#[shuttle_shared_db::Postgres] conn_str: String, | ||
#[shuttle_runtime::Metadata] meta: DeploymentMetadata, | ||
) -> shuttle_axum::ShuttleAxum { | ||
std::env::set_var("DATABASE_URL", conn_str); | ||
let environment = match meta.env { | ||
shuttle_runtime::Environment::Local => Environment::Development, | ||
shuttle_runtime::Environment::Deployment => Environment::Production, | ||
}; | ||
|
||
let config = environment | ||
.load() | ||
.expect("Failed to load configuration from the environment"); | ||
|
||
let boot_result = create_app::<App, Migrator>(StartMode::ServerOnly, &environment, config) | ||
.await | ||
.unwrap(); | ||
|
||
let router = boot_result.router.unwrap(); | ||
Ok(router.into()) | ||
} |
9 changes: 9 additions & 0 deletions
9
loco-gen/tests/templates/snapshots/inject[.config_toml]@deployment.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
source: loco-gen/tests/templates/deployment.rs | ||
expression: "fs::read_to_string(tree_fs.root.join(\".cargo\").join(\"config.toml\")).expect(\".cargo/config.toml not exists\")" | ||
--- | ||
[alias] | ||
loco = "run --bin tester-cli --" | ||
loco-tool = "run --" | ||
|
||
playground = "run --example playground" |
15 changes: 15 additions & 0 deletions
15
loco-gen/tests/templates/snapshots/inject[cargo_toml]@deployment.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
--- | ||
source: loco-gen/tests/templates/deployment.rs | ||
expression: "fs::read_to_string(tree_fs.root.join(\"Cargo.toml\")).expect(\"cargo.toml not exists\")" | ||
--- | ||
[dependencies] | ||
shuttle-axum = "0.51.0" | ||
shuttle-runtime = { version = "0.51.0", default-features = false } | ||
shuttle-shared-db = { version = "0.51.0", features = ["postgres"] } | ||
|
||
|
||
[[bin]] | ||
name = "tester" | ||
path = "src/bin/shuttle.rs" | ||
|
||
[dev-dependencies] |