Skip to content

Commit

Permalink
Make clippy happy
Browse files Browse the repository at this point in the history
  • Loading branch information
mitsuhiko committed Mar 28, 2020
1 parent 442e38e commit f7e4c69
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 24 deletions.
30 changes: 9 additions & 21 deletions src/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ use difference::{Changeset, Difference};
use lazy_static::lazy_static;

use serde::Deserialize;
use serde_json;

use crate::settings::Settings;
use crate::snapshot::{MetaData, PendingInlineSnapshot, Snapshot, SnapshotContents};
Expand Down Expand Up @@ -96,7 +95,7 @@ fn test_format_rust_expression() {
}

fn update_snapshot_behavior(unseen: bool) -> UpdateBehavior {
match env::var("INSTA_UPDATE").ok().as_ref().map(|x| x.as_str()) {
match env::var("INSTA_UPDATE").ok().as_deref() {
None | Some("") | Some("auto") => {
if is_ci() {
UpdateBehavior::NoUpdate
Expand All @@ -119,7 +118,7 @@ fn update_snapshot_behavior(unseen: bool) -> UpdateBehavior {
}

fn output_snapshot_behavior() -> OutputBehavior {
match env::var("INSTA_OUTPUT").ok().as_ref().map(|x| x.as_str()) {
match env::var("INSTA_OUTPUT").ok().as_deref() {
None | Some("") | Some("diff") => OutputBehavior::Diff,
Some("summary") => OutputBehavior::Summary,
Some("minimal") => OutputBehavior::Minimal,
Expand All @@ -129,23 +128,15 @@ fn output_snapshot_behavior() -> OutputBehavior {
}

fn force_update_snapshots() -> bool {
match env::var("INSTA_FORCE_UPDATE_SNAPSHOTS")
.ok()
.as_ref()
.map(|x| x.as_str())
{
match env::var("INSTA_FORCE_UPDATE_SNAPSHOTS").ok().as_deref() {
None | Some("") | Some("0") => false,
Some("1") => true,
_ => panic!("invalid value for INSTA_FORCE_UPDATE_SNAPSHOTS"),
}
}

fn should_fail_in_tests() -> bool {
match env::var("INSTA_FORCE_PASS")
.ok()
.as_ref()
.map(|x| x.as_str())
{
match env::var("INSTA_FORCE_PASS").ok().as_deref() {
None | Some("") | Some("0") => true,
Some("1") => false,
_ => panic!("invalid value for INSTA_FORCE_PASS"),
Expand Down Expand Up @@ -385,10 +376,7 @@ pub fn print_snapshot_diff(
} else {
println!("{}", style("+new results").green());
}
print_changeset(
&changeset,
new.metadata().expression.as_ref().map(|x| x.as_str()),
);
print_changeset(&changeset, new.metadata().expression.as_deref());
}

fn print_snapshot_diff_with_title(
Expand Down Expand Up @@ -919,7 +907,7 @@ pub fn assert_snapshot(

if force_update_snapshots() {
update_snapshots(
snapshot_file.as_ref().map(|x| x.as_path()),
snapshot_file.as_deref(),
new,
old,
line,
Expand All @@ -939,7 +927,7 @@ pub fn assert_snapshot(
&new,
old.as_ref(),
line,
snapshot_file.as_ref().map(|x| x.as_path()),
snapshot_file.as_deref(),
);
}
OutputBehavior::Diff => {
Expand All @@ -948,14 +936,14 @@ pub fn assert_snapshot(
&new,
old.as_ref(),
line,
snapshot_file.as_ref().map(|x| x.as_path()),
snapshot_file.as_deref(),
);
}
_ => {}
}

update_snapshots(
snapshot_file.as_ref().map(|x| x.as_path()),
snapshot_file.as_deref(),
new,
old,
line,
Expand Down
1 change: 0 additions & 1 deletion src/serialization.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use serde::de::value::Error as ValueError;
use serde::Serialize;
use serde_json;

use crate::content::{Content, ContentSerializer};
use crate::settings::Settings;
Expand Down
3 changes: 1 addition & 2 deletions src/snapshot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use std::time::{SystemTime, UNIX_EPOCH};

use lazy_static::lazy_static;
use serde::{Deserialize, Serialize};
use serde_json;

use super::runtime::get_inline_snapshot_value;

Expand Down Expand Up @@ -210,7 +209,7 @@ impl Snapshot {

/// Returns the snapshot name.
pub fn snapshot_name(&self) -> Option<&str> {
self.snapshot_name.as_ref().map(|x| x.as_str())
self.snapshot_name.as_deref()
}

/// The metadata in the snapshot.
Expand Down

0 comments on commit f7e4c69

Please sign in to comment.