Skip to content

Commit c6bc422

Browse files
FooBarWidgetsylvestre
authored andcommitted
Remove var lookup tests
1 parent 3fb4889 commit c6bc422

File tree

2 files changed

+0
-87
lines changed

2 files changed

+0
-87
lines changed

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ assert_cmd = "=2.0.4"
9797
cc = "1.0"
9898
chrono = "0.4"
9999
itertools = "0.10"
100-
lazy_static = "1.4"
101100
predicates = "=2.1.1"
102101
thirtyfour_sync = "0.27"
103102
once_cell = "1.9"

src/azure/credentials.rs

Lines changed: 0 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -148,92 +148,6 @@ fn substr(text: &str, to_skip: usize) -> &str {
148148
#[cfg(test)]
149149
mod test {
150150
use super::*;
151-
use lazy_static::lazy_static;
152-
use std::ffi::{OsStr, OsString};
153-
use std::sync::{Mutex, MutexGuard};
154-
155-
lazy_static! {
156-
static ref ENV_TEST_MUTEX: Mutex<()> = Mutex::new(());
157-
}
158-
159-
struct TempCredentialsEnv {
160-
_guard: MutexGuard<'static, ()>,
161-
prev_connection_string: Option<OsString>,
162-
prev_container_name: Option<OsString>,
163-
}
164-
165-
impl TempCredentialsEnv {
166-
pub fn new(
167-
connection_string: Option<String>,
168-
container_name: Option<String>,
169-
) -> TempCredentialsEnv {
170-
let result = TempCredentialsEnv {
171-
_guard: ENV_TEST_MUTEX.lock().unwrap(),
172-
prev_connection_string: var_os("SCCACHE_AZURE_CONNECTION_STRING"),
173-
prev_container_name: var_os("SCCACHE_AZURE_BLOB_CONTAINER"),
174-
};
175-
set_var_os_option("SCCACHE_AZURE_CONNECTION_STRING", connection_string);
176-
set_var_os_option("SCCACHE_AZURE_BLOB_CONTAINER", container_name);
177-
result
178-
}
179-
}
180-
181-
impl Drop for TempCredentialsEnv {
182-
fn drop(&mut self) {
183-
set_var_os_option(
184-
"SCCACHE_AZURE_CONNECTION_STRING",
185-
self.prev_connection_string.as_ref(),
186-
);
187-
set_var_os_option(
188-
"SCCACHE_AZURE_BLOB_CONTAINER",
189-
self.prev_container_name.as_ref(),
190-
);
191-
}
192-
}
193-
194-
fn set_var_os_option(key: impl AsRef<OsStr>, val: Option<impl AsRef<OsStr>>) {
195-
if let Some(ref val) = val {
196-
set_var(key, val);
197-
} else {
198-
remove_var(key);
199-
}
200-
}
201-
202-
#[test]
203-
fn test_credentials_from_environment() {
204-
let _temp_env = TempCredentialsEnv::new(Some("DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;BlobEndpoint=http://127.0.0.1:10000/devstoreaccount1;".to_owned()), Some("container".to_owned()));
205-
206-
let creds = credentials_from_environment().unwrap();
207-
assert_eq!(
208-
"http://127.0.0.1:10000/devstoreaccount1/",
209-
creds.azure_blob_endpoint()
210-
);
211-
assert_eq!("devstoreaccount1", creds.azure_account_name());
212-
assert!(creds.azure_account_key().is_none());
213-
assert_eq!("container", creds.blob_container_name());
214-
}
215-
216-
#[test]
217-
fn test_credentials_from_environment_no_conn_str() {
218-
let _temp_env = TempCredentialsEnv::new(None, Some("container".to_owned()));
219-
220-
let err = credentials_from_environment().unwrap_err();
221-
assert_eq!(
222-
"No SCCACHE_AZURE_CONNECTION_STRING in environment",
223-
err.to_string()
224-
);
225-
}
226-
227-
#[test]
228-
fn test_credentials_from_environment_no_container_name() {
229-
let _temp_env = TempCredentialsEnv::new(Some("DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;BlobEndpoint=http://127.0.0.1:10000/devstoreaccount1;".to_owned()), None);
230-
231-
let err = credentials_from_environment().unwrap_err();
232-
assert_eq!(
233-
"No SCCACHE_AZURE_BLOB_CONTAINER in environment",
234-
err.to_string()
235-
);
236-
}
237151

238152
#[test]
239153
fn test_parse_connection_string() {

0 commit comments

Comments
 (0)