chore: fix upcoming rust 1.77 clippy issues and chrono deprecations (#5850)

This commit is contained in:
David Knaack 2024-03-20 10:57:14 +01:00 committed by GitHub
parent 49575e5a55
commit 0e334e3e6c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 18 additions and 22 deletions

View File

@ -38,9 +38,9 @@ pub struct Context<'a> {
/// The current working directory that starship is being called in.
pub current_dir: PathBuf,
/// A logical directory path which should represent the same directory as current_dir,
/// A logical directory path which should represent the same directory as `current_dir`,
/// though may appear different.
/// E.g. when navigating to a PSDrive in PowerShell, or a path without symlinks resolved.
/// E.g. when navigating to a `PSDrive` in `PowerShell`, or a path without symlinks resolved.
pub logical_dir: PathBuf,
/// A struct containing directory contents in a lookup-optimized format.
@ -61,10 +61,10 @@ pub struct Context<'a> {
/// Width of terminal, or zero if width cannot be detected.
pub width: usize,
/// A HashMap of environment variable mocks
/// A `HashMap` of environment variable mocks
pub env: Env<'a>,
/// A HashMap of command mocks
/// A `HashMap` of command mocks
#[cfg(test)]
pub cmd: HashMap<&'a str, Option<CommandOutput>>,

View File

@ -6,7 +6,7 @@ use std::ffi::OsString;
#[derive(Default)]
pub struct Env<'a> {
/// A HashMap of environment variable mocks
/// A `HashMap` of environment variable mocks
#[cfg(test)]
pub env: HashMap<&'a str, String>,

View File

@ -684,15 +684,12 @@ credential_process = /opt/bin/awscreds-retriever
#[test]
fn expiration_date_set() {
use chrono::{DateTime, NaiveDateTime, SecondsFormat, Utc};
use chrono::{DateTime, SecondsFormat, Utc};
let expiration_env_vars = ["AWS_SESSION_EXPIRATION", "AWS_CREDENTIAL_EXPIRATION"];
expiration_env_vars.iter().for_each(|env_var| {
let now_plus_half_hour: DateTime<Utc> = DateTime::from_naive_utc_and_offset(
NaiveDateTime::from_timestamp_opt(chrono::Local::now().timestamp() + 1800, 0)
.unwrap(),
Utc,
);
let now_plus_half_hour: DateTime<Utc> =
DateTime::from_timestamp(chrono::Local::now().timestamp() + 1800, 0).unwrap();
let actual = ModuleRenderer::new("aws")
.env("AWS_PROFILE", "astronauts")
@ -727,12 +724,10 @@ credential_process = /opt/bin/awscreds-retriever
let credentials_path = dir.path().join("credentials");
let mut file = File::create(&credentials_path)?;
use chrono::{DateTime, NaiveDateTime, Utc};
use chrono::{DateTime, Utc};
let now_plus_half_hour: DateTime<Utc> = DateTime::from_naive_utc_and_offset(
NaiveDateTime::from_timestamp_opt(chrono::Local::now().timestamp() + 1800, 0).unwrap(),
Utc,
);
let now_plus_half_hour: DateTime<Utc> =
DateTime::from_timestamp(chrono::Local::now().timestamp() + 1800, 0).unwrap();
let expiration_date = now_plus_half_hour.to_rfc3339_opts(chrono::SecondsFormat::Secs, true);
@ -800,12 +795,10 @@ aws_secret_access_key=dummy
#[test]
fn expiration_date_set_expired() {
use chrono::{DateTime, NaiveDateTime, SecondsFormat, Utc};
use chrono::{DateTime, SecondsFormat, Utc};
let now: DateTime<Utc> = DateTime::from_naive_utc_and_offset(
NaiveDateTime::from_timestamp_opt(chrono::Local::now().timestamp() - 1800, 0).unwrap(),
Utc,
);
let now: DateTime<Utc> =
DateTime::from_timestamp(chrono::Local::now().timestamp() - 1800, 0).unwrap();
let symbol = "!!!";

View File

@ -70,7 +70,9 @@ impl<'a> ModuleRenderer<'a> {
T: Into<PathBuf>,
{
self.context.current_dir = path.into();
self.context.logical_dir = self.context.current_dir.clone();
self.context
.logical_dir
.clone_from(&self.context.current_dir);
self
}
@ -184,6 +186,7 @@ pub fn fixture_repo(provider: FixtureProvider) -> io::Result<TempDir> {
fs::OpenOptions::new()
.create(true)
.write(true)
.truncate(false)
.open(path.path().join(checkout_db))?
.sync_all()?;
Ok(path)