-
Notifications
You must be signed in to change notification settings - Fork 552
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Attempt to fix intermittent config_from_env() test failures by ensuri…
…ng envvars are reset before unwrapping/asserting
- Loading branch information
Showing
1 changed file
with
25 additions
and
19 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1315,16 +1315,18 @@ fn test_s3_no_credentials_conflict() { | |
env::set_var("AWS_ACCESS_KEY_ID", "aws-access-key-id"); | ||
env::set_var("AWS_SECRET_ACCESS_KEY", "aws-secret-access-key"); | ||
|
||
let error = config_from_env().unwrap_err(); | ||
assert_eq!( | ||
"If setting S3 credentials, SCCACHE_S3_NO_CREDENTIALS must not be set.", | ||
error.to_string() | ||
); | ||
let cfg = config_from_env(); | ||
|
||
env::remove_var("SCCACHE_S3_NO_CREDENTIALS"); | ||
env::remove_var("SCCACHE_BUCKET"); | ||
env::remove_var("AWS_ACCESS_KEY_ID"); | ||
env::remove_var("AWS_SECRET_ACCESS_KEY"); | ||
|
||
let error = cfg.unwrap_err(); | ||
assert_eq!( | ||
"If setting S3 credentials, SCCACHE_S3_NO_CREDENTIALS must not be set.", | ||
error.to_string() | ||
); | ||
} | ||
|
||
#[test] | ||
|
@@ -1333,14 +1335,16 @@ fn test_s3_no_credentials_invalid() { | |
env::set_var("SCCACHE_S3_NO_CREDENTIALS", "yes"); | ||
env::set_var("SCCACHE_BUCKET", "my-bucket"); | ||
|
||
let error = config_from_env().unwrap_err(); | ||
let cfg = config_from_env(); | ||
|
||
env::remove_var("SCCACHE_S3_NO_CREDENTIALS"); | ||
env::remove_var("SCCACHE_BUCKET"); | ||
|
||
let error = cfg.unwrap_err(); | ||
assert_eq!( | ||
"SCCACHE_S3_NO_CREDENTIALS must be 'true', 'on', '1', 'false', 'off' or '0'.", | ||
error.to_string() | ||
); | ||
|
||
env::remove_var("SCCACHE_S3_NO_CREDENTIALS"); | ||
env::remove_var("SCCACHE_BUCKET"); | ||
} | ||
|
||
#[test] | ||
|
@@ -1349,7 +1353,12 @@ fn test_s3_no_credentials_valid_true() { | |
env::set_var("SCCACHE_S3_NO_CREDENTIALS", "true"); | ||
env::set_var("SCCACHE_BUCKET", "my-bucket"); | ||
|
||
let env_cfg = config_from_env().unwrap(); | ||
let cfg = config_from_env(); | ||
|
||
env::remove_var("SCCACHE_S3_NO_CREDENTIALS"); | ||
env::remove_var("SCCACHE_BUCKET"); | ||
|
||
let env_cfg = cfg.unwrap(); | ||
match env_cfg.cache.s3 { | ||
Some(S3CacheConfig { | ||
ref bucket, | ||
|
@@ -1361,9 +1370,6 @@ fn test_s3_no_credentials_valid_true() { | |
} | ||
None => unreachable!(), | ||
}; | ||
|
||
env::remove_var("SCCACHE_S3_NO_CREDENTIALS"); | ||
env::remove_var("SCCACHE_BUCKET"); | ||
} | ||
|
||
#[test] | ||
|
@@ -1372,7 +1378,12 @@ fn test_s3_no_credentials_valid_false() { | |
env::set_var("SCCACHE_S3_NO_CREDENTIALS", "false"); | ||
env::set_var("SCCACHE_BUCKET", "my-bucket"); | ||
|
||
let env_cfg = config_from_env().unwrap(); | ||
let cfg = config_from_env(); | ||
|
||
env::remove_var("SCCACHE_S3_NO_CREDENTIALS"); | ||
env::remove_var("SCCACHE_BUCKET"); | ||
|
||
let env_cfg = cfg.unwrap(); | ||
match env_cfg.cache.s3 { | ||
Some(S3CacheConfig { | ||
ref bucket, | ||
|
@@ -1384,14 +1395,10 @@ fn test_s3_no_credentials_valid_false() { | |
} | ||
None => unreachable!(), | ||
}; | ||
|
||
env::remove_var("SCCACHE_S3_NO_CREDENTIALS"); | ||
env::remove_var("SCCACHE_BUCKET"); | ||
} | ||
|
||
#[test] | ||
fn test_gcs_service_account() { | ||
env::set_var("SCCACHE_S3_NO_CREDENTIALS", "false"); | ||
env::set_var("SCCACHE_GCS_BUCKET", "my-bucket"); | ||
env::set_var("SCCACHE_GCS_SERVICE_ACCOUNT", "[email protected]"); | ||
env::set_var("SCCACHE_GCS_RW_MODE", "READ_WRITE"); | ||
|
@@ -1411,7 +1418,6 @@ fn test_gcs_service_account() { | |
None => unreachable!(), | ||
}; | ||
|
||
env::remove_var("SCCACHE_S3_NO_CREDENTIALS"); | ||
env::remove_var("SCCACHE_GCS_BUCKET"); | ||
env::remove_var("SCCACHE_GCS_SERVICE_ACCOUNT"); | ||
env::remove_var("SCCACHE_GCS_RW_MODE"); | ||
|