-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add snapshot test based on hdoordt/cargo-autoinherit-test repo
- Loading branch information
Showing
16 changed files
with
1,082 additions
and
2 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
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,56 @@ | ||
use std::{env::temp_dir, fs, path::PathBuf}; | ||
|
||
use cargo_autoinherit::{auto_inherit, AutoInheritConf}; | ||
use git2::Repository; | ||
use insta::assert_snapshot; | ||
use rand::{ | ||
distributions::{Alphanumeric, DistString}, | ||
thread_rng, | ||
}; | ||
|
||
const TEST_REPO_URL: &str = match option_env!("TEST_REPO_URL") { | ||
Some(url) => url, | ||
None => "https://github.com/hdoordt/cargo-autoinherit-test", | ||
}; | ||
|
||
fn clone_test_project() -> PathBuf { | ||
let dir: String = Alphanumeric.sample_string(&mut thread_rng(), 32); | ||
let dir = temp_dir().join(dir); | ||
Repository::clone(TEST_REPO_URL, &dir).expect("Error cloning test repository"); | ||
dir | ||
} | ||
|
||
fn run_with_conf(conf: AutoInheritConf) -> PathBuf { | ||
let repo_path = clone_test_project(); | ||
|
||
let conf = AutoInheritConf { | ||
manifest_path: Some(PathBuf::from(format!( | ||
"{}/Cargo.toml", | ||
repo_path.to_str().unwrap() | ||
))), | ||
..conf | ||
}; | ||
auto_inherit(conf).unwrap(); | ||
repo_path | ||
} | ||
|
||
#[test] | ||
fn default_behavior() { | ||
let repo_path = run_with_conf(AutoInheritConf::default()); | ||
insta::glob!(repo_path, "**/Cargo.toml", |p| { | ||
let input = fs::read_to_string(dbg!(p)).unwrap(); | ||
assert_snapshot!(input); | ||
}); | ||
} | ||
|
||
#[test] | ||
fn prefer_simple_dotted() { | ||
let repo_path = run_with_conf(AutoInheritConf { | ||
prefer_simple_dotted: true, | ||
..Default::default() | ||
}); | ||
insta::glob!(repo_path, "**/Cargo.toml", |p| { | ||
let input = fs::read_to_string(dbg!(p)).unwrap(); | ||
assert_snapshot!(input); | ||
}); | ||
} |
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,48 @@ | ||
--- | ||
source: tests/main.rs | ||
expression: input | ||
snapshot_kind: text | ||
--- | ||
[workspace] | ||
members = [ | ||
"cli", | ||
"config", | ||
"db", | ||
"web", | ||
"macros" | ||
] | ||
resolver = "2" | ||
default-members = ["web"] | ||
|
||
[workspace.metadata.cargo-autoinherit] | ||
# Skip cargo-autoinherit for these packages | ||
exclude-members = [ | ||
"cargo-autoinherit-test-web" | ||
] | ||
|
||
[workspace.dependencies] | ||
anyhow = "1.0" | ||
cargo-autoinherit-test-config = { path = "config" } | ||
clap = "4.4" | ||
cruet = "0.14" | ||
dotenvy = "0.15" | ||
fake = "2.9" | ||
figment = "0.10" | ||
googletest = "0.12" | ||
guppy = "0.17" | ||
include_dir = "0.7" | ||
insta = "1.38" | ||
liquid = "~0.26" | ||
quote = "1.0" | ||
rand = "0.8" | ||
regex = "1.10" | ||
serde = "1.0" | ||
sqlx = "0.8" | ||
syn = "2.0" | ||
thiserror = "1.0" | ||
tokio = "1.34" | ||
tracing = "0.1" | ||
url = "2.5" | ||
utoipa = "5.1.3" | ||
uuid = "1.5" | ||
validator = "0.18" |
36 changes: 36 additions & 0 deletions
36
tests/snapshots/main__default_behavior@cli__Cargo.toml.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,36 @@ | ||
--- | ||
source: tests/main.rs | ||
expression: input | ||
snapshot_kind: text | ||
--- | ||
[package] | ||
name = "cargo-autoinherit-test-cli" | ||
version = "0.0.1" | ||
edition = "2021" | ||
publish = false | ||
|
||
[lib] | ||
# examples in docs don't run without additional setup | ||
doctest = false | ||
|
||
[[bin]] | ||
name = "db" | ||
path = "src/bin/db.rs" | ||
[[bin]] | ||
name = "generate" | ||
path = "src/bin/generate.rs" | ||
|
||
[dependencies] | ||
anyhow = { workspace = true } | ||
clap = { workspace = true, features = ["derive"] } | ||
cruet = { workspace = true } | ||
guppy = { workspace = true } | ||
include_dir = { workspace = true } | ||
liquid = { workspace = true } | ||
cargo-autoinherit-test-config = { workspace = true } | ||
sqlx = { workspace = true, features = ["runtime-tokio", "tls-rustls", "postgres", "macros", "uuid", "migrate", "chrono"] } | ||
url = { workspace = true } | ||
tokio = { workspace = true, features = ["full"] } | ||
|
||
[dev-dependencies] | ||
insta = { workspace = true } |
25 changes: 25 additions & 0 deletions
25
tests/snapshots/main__default_behavior@config__Cargo.toml.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,25 @@ | ||
--- | ||
source: tests/main.rs | ||
expression: input | ||
snapshot_kind: text | ||
--- | ||
[package] | ||
name = "cargo-autoinherit-test-config" | ||
version = "0.0.1" | ||
edition = "2021" | ||
publish = false | ||
|
||
[lib] | ||
# examples in docs don't run without config files being in place, etc. | ||
doctest = false | ||
|
||
[dependencies] | ||
anyhow = { workspace = true } | ||
dotenvy = { workspace = true } | ||
figment = { workspace = true, features = ["toml", "env"] } | ||
serde = { workspace = true, features = ["derive"] } | ||
tracing = { workspace = true } | ||
|
||
[dev-dependencies] | ||
figment = { workspace = true, features = ["toml", "env", "test"] } | ||
googletest = { workspace = true } |
31 changes: 31 additions & 0 deletions
31
tests/snapshots/main__default_behavior@db__Cargo.toml.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,31 @@ | ||
--- | ||
source: tests/main.rs | ||
expression: input | ||
snapshot_kind: text | ||
--- | ||
[package] | ||
name = "cargo-autoinherit-test-db" | ||
version = "0.1.0" | ||
edition = "2021" | ||
publish = false | ||
|
||
[lib] | ||
# examples in docs don't run without a running database, etc. | ||
doctest = false | ||
|
||
[features] | ||
test-helpers = ["dep:fake", "dep:rand", "dep:regex"] | ||
openapi = ["dep:utoipa"] | ||
|
||
[dependencies] | ||
anyhow = { workspace = true } | ||
fake = { workspace = true, features = ["derive"], optional = true } | ||
cargo-autoinherit-test-config = { workspace = true } | ||
rand = { workspace = true, optional = true } | ||
regex = { workspace = true, optional = true } | ||
serde = { workspace = true, features = ["derive"] } | ||
sqlx = { workspace = true, features = ["runtime-tokio", "tls-rustls", "postgres", "macros", "uuid", "migrate", "chrono"] } | ||
thiserror = { workspace = true } | ||
utoipa = { workspace = true, features = ["uuid"], optional = true } | ||
uuid = { workspace = true, features = ["serde"] } | ||
validator = { workspace = true, features = ["derive"] } |
19 changes: 19 additions & 0 deletions
19
tests/snapshots/main__default_behavior@macros__Cargo.toml.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,19 @@ | ||
--- | ||
source: tests/main.rs | ||
expression: input | ||
snapshot_kind: text | ||
--- | ||
[package] | ||
name = "cargo-autoinherit-test-macros" | ||
version = "0.0.1" | ||
edition = "2021" | ||
publish = false | ||
|
||
[lib] | ||
proc-macro = true | ||
# examples in docs don't run without a running database, etc. | ||
doctest = false | ||
|
||
[dependencies] | ||
quote = { workspace = true } | ||
syn = { workspace = true, features = ["full"] } |
45 changes: 45 additions & 0 deletions
45
tests/snapshots/main__default_behavior@web__Cargo.toml.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,45 @@ | ||
--- | ||
source: tests/main.rs | ||
expression: input | ||
snapshot_kind: text | ||
--- | ||
[package] | ||
name = "cargo-autoinherit-test-web" | ||
version = "0.0.1" | ||
edition = "2021" | ||
publish = false | ||
|
||
[lib] | ||
# examples in docs don't run without a running database, etc. | ||
doctest = false | ||
|
||
[features] | ||
test-helpers = ["dep:serde_json", "dep:tower", "dep:hyper"] | ||
|
||
[dependencies] | ||
anyhow = "1.0" | ||
axum = { version = "0.7", features = ["macros"] } | ||
cargo-autoinherit-test-config = { path = "../config" } | ||
cargo-autoinherit-test-db = { path = "../db", features = ["openapi"] } | ||
serde = { version = "1.0", features = ["derive"] } | ||
tokio = { version = "1.34", features = ["full"] } | ||
tower-http = { version = "0.6", features = ["full"] } | ||
tracing = "0.1" | ||
tracing-panic = "0.1" | ||
tracing-subscriber = { version = "0.3", features = ["env-filter", "registry", "fmt"] } | ||
uuid = { version = "1.6", features = ["serde"] } | ||
serde_json = { version = "1.0", optional = true } | ||
thiserror = "1.0" | ||
tower = { version = "0.5", features = ["util"], optional = true } | ||
hyper = { version = "1.0", features = ["full"], optional = true } | ||
cargo-autoinherit-test-macros = { path = "../macros" } | ||
validator = { version = "0.18.1", features = ["derive"] } | ||
utoipa = { version = "5.1.2", features = ["axum_extras", "uuid"] } | ||
utoipa-axum = {version = "0.1.2" } | ||
utoipa-swagger-ui = { version = "8.0.3", features = ["axum", "reqwest"] } | ||
|
||
[dev-dependencies] | ||
fake = "2.9" | ||
googletest = "0.12" | ||
cargo-autoinherit-test-db = { path = "../db", features = ["test-helpers"] } | ||
cargo-autoinherit-test-web = { path = ".", features = ["test-helpers"] } |
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,48 @@ | ||
--- | ||
source: tests/main.rs | ||
expression: input | ||
snapshot_kind: text | ||
--- | ||
[workspace] | ||
members = [ | ||
"cli", | ||
"config", | ||
"db", | ||
"web", | ||
"macros" | ||
] | ||
resolver = "2" | ||
default-members = ["web"] | ||
|
||
[workspace.metadata.cargo-autoinherit] | ||
# Skip cargo-autoinherit for these packages | ||
exclude-members = [ | ||
"cargo-autoinherit-test-web" | ||
] | ||
|
||
[workspace.dependencies] | ||
anyhow = "1.0" | ||
cargo-autoinherit-test-config = { path = "config" } | ||
clap = "4.4" | ||
cruet = "0.14" | ||
dotenvy = "0.15" | ||
fake = "2.9" | ||
figment = "0.10" | ||
googletest = "0.12" | ||
guppy = "0.17" | ||
include_dir = "0.7" | ||
insta = "1.38" | ||
liquid = "~0.26" | ||
quote = "1.0" | ||
rand = "0.8" | ||
regex = "1.10" | ||
serde = "1.0" | ||
sqlx = "0.8" | ||
syn = "2.0" | ||
thiserror = "1.0" | ||
tokio = "1.34" | ||
tracing = "0.1" | ||
url = "2.5" | ||
utoipa = "5.1.3" | ||
uuid = "1.5" | ||
validator = "0.18" |
36 changes: 36 additions & 0 deletions
36
tests/snapshots/main__prefer_simple_dotted@cli__Cargo.toml.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,36 @@ | ||
--- | ||
source: tests/main.rs | ||
expression: input | ||
snapshot_kind: text | ||
--- | ||
[package] | ||
name = "cargo-autoinherit-test-cli" | ||
version = "0.0.1" | ||
edition = "2021" | ||
publish = false | ||
|
||
[lib] | ||
# examples in docs don't run without additional setup | ||
doctest = false | ||
|
||
[[bin]] | ||
name = "db" | ||
path = "src/bin/db.rs" | ||
[[bin]] | ||
name = "generate" | ||
path = "src/bin/generate.rs" | ||
|
||
[dependencies] | ||
anyhow.workspace = true | ||
clap = { workspace = true, features = ["derive"] } | ||
cruet.workspace = true | ||
guppy.workspace = true | ||
include_dir.workspace = true | ||
liquid.workspace = true | ||
cargo-autoinherit-test-config.workspace = true | ||
sqlx = { workspace = true, features = ["runtime-tokio", "tls-rustls", "postgres", "macros", "uuid", "migrate", "chrono"] } | ||
url.workspace = true | ||
tokio = { workspace = true, features = ["full"] } | ||
|
||
[dev-dependencies] | ||
insta.workspace = true |
Oops, something went wrong.