Skip to content

Commit 641c2e8

Browse files
committed
refactor: move display test in separate file
This should make maintenance easier as the number of those files grows. Also update the insta snapshots by running: ``` cargo insta test --accept --unreferenced delete ```
1 parent 4310847 commit 641c2e8

13 files changed

+55
-35
lines changed

rusqlite_migration/src/tests/core.rs

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -573,28 +573,3 @@ fn test_pending_migrations_errors() -> Result<(), Box<dyn std::error::Error>> {
573573

574574
Ok(())
575575
}
576-
577-
#[test]
578-
fn test_display() {
579-
insta::assert_snapshot!("up_only", m_valid0_up());
580-
insta::assert_snapshot!("up_only_alt", format!("{:#}", m_valid0_up()));
581-
582-
insta::assert_snapshot!("up_down", m_valid0_down());
583-
insta::assert_snapshot!("up_down_alt", format!("{:#}", m_valid0_down()));
584-
585-
insta::assert_snapshot!("up_down_fk", m_valid_fk_down());
586-
insta::assert_snapshot!("up_down_fk_alt", format!("{:#}", m_valid_fk_down()));
587-
588-
let everything = M {
589-
up: "UP",
590-
up_hook: Some(Box::new(|_: &Transaction| Ok(()))),
591-
down: Some("DOWN"),
592-
down_hook: Some(Box::new(|_: &Transaction| Ok(()))),
593-
foreign_key_check: true,
594-
comment: Some("Comment, likely a filename in practice!"),
595-
};
596-
insta::assert_snapshot!("everything", everything);
597-
insta::assert_debug_snapshot!("everything_debug", everything);
598-
insta::assert_compact_debug_snapshot!("everything_compact_debug", everything);
599-
insta::assert_snapshot!("everything_alt", format!("{everything:#}"));
600-
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// SPDX-License-Identifier: Apache-2.0
2+
// Copyright Clément Joly and contributors.
3+
//
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
//
8+
// http://www.apache.org/licenses/LICENSE-2.0
9+
//
10+
// Unless required by applicable law or agreed to in writing, software
11+
// distributed under the License is distributed on an "AS IS" BASIS,
12+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
// See the License for the specific language governing permissions and
14+
// limitations under the License.
15+
16+
use insta::assert_snapshot;
17+
18+
use crate::tests::helpers::{all_valid_down, m_valid0_down, m_valid0_up, m_valid_fk_down};
19+
use crate::*;
20+
21+
#[test]
22+
fn test_m_display() {
23+
insta::assert_snapshot!("up_only", m_valid0_up());
24+
insta::assert_snapshot!("up_only_alt", format!("{:#}", m_valid0_up()));
25+
26+
insta::assert_snapshot!("up_down", m_valid0_down());
27+
insta::assert_snapshot!("up_down_alt", format!("{:#}", m_valid0_down()));
28+
29+
insta::assert_snapshot!("up_down_fk", m_valid_fk_down());
30+
insta::assert_snapshot!("up_down_fk_alt", format!("{:#}", m_valid_fk_down()));
31+
32+
let everything = M {
33+
up: "UP",
34+
up_hook: Some(Box::new(|_: &Transaction| Ok(()))),
35+
down: Some("DOWN"),
36+
down_hook: Some(Box::new(|_: &Transaction| Ok(()))),
37+
foreign_key_check: true,
38+
comment: Some("Comment, likely a filename in practice!"),
39+
};
40+
insta::assert_snapshot!("everything", everything);
41+
insta::assert_debug_snapshot!("everything_debug", everything);
42+
insta::assert_compact_debug_snapshot!("everything_compact_debug", everything);
43+
insta::assert_snapshot!("everything_alt", format!("{everything:#}"));
44+
}

rusqlite_migration/src/tests/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,5 @@
1717
mod builder;
1818

1919
mod core;
20+
mod display;
2021
mod helpers;

rusqlite_migration/src/tests/snapshots/rusqlite_migration__tests__core__everything.snap renamed to rusqlite_migration/src/tests/snapshots/rusqlite_migration__tests__display__everything.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
source: rusqlite_migration/src/tests/core.rs
2+
source: rusqlite_migration/src/tests/display.rs
33
expression: everything
44
snapshot_kind: text
55
---
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
source: rusqlite_migration/src/tests/core.rs
2+
source: rusqlite_migration/src/tests/display.rs
33
expression: "format!(\"{everything:#}\")"
44
snapshot_kind: text
55
---
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
source: rusqlite_migration/src/tests/core.rs
2+
source: rusqlite_migration/src/tests/display.rs
33
expression: everything
44
snapshot_kind: text
55
---
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
source: rusqlite_migration/src/tests/core.rs
2+
source: rusqlite_migration/src/tests/display.rs
33
expression: everything
44
snapshot_kind: text
55
---

rusqlite_migration/src/tests/snapshots/rusqlite_migration__tests__core__up_down.snap renamed to rusqlite_migration/src/tests/snapshots/rusqlite_migration__tests__display__up_down.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
source: rusqlite_migration/src/tests/core.rs
2+
source: rusqlite_migration/src/tests/display.rs
33
expression: m_valid0_down()
44
snapshot_kind: text
55
---

rusqlite_migration/src/tests/snapshots/rusqlite_migration__tests__core__up_down_alt.snap renamed to rusqlite_migration/src/tests/snapshots/rusqlite_migration__tests__display__up_down_alt.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
source: rusqlite_migration/src/tests/core.rs
2+
source: rusqlite_migration/src/tests/display.rs
33
expression: "format!(\"{:#}\", m_valid0_down())"
44
snapshot_kind: text
55
---

rusqlite_migration/src/tests/snapshots/rusqlite_migration__tests__core__up_down_fk.snap renamed to rusqlite_migration/src/tests/snapshots/rusqlite_migration__tests__display__up_down_fk.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
source: rusqlite_migration/src/tests/core.rs
2+
source: rusqlite_migration/src/tests/display.rs
33
expression: m_valid_fk_down()
44
snapshot_kind: text
55
---

0 commit comments

Comments
 (0)