Skip to content

Commit 514490b

Browse files
committed
tests: ensure that collections of valid migrations are consistent
1 parent 705ef65 commit 514490b

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

rusqlite_migration/src/tests/helpers.rs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,41 @@ pub fn all_valid_down() -> Vec<M<'static>> {
100100
]
101101
}
102102

103+
#[test]
104+
fn all_valid_consistent() {
105+
let all_up = all_valid_up();
106+
let all_down = all_valid_down();
107+
108+
assert_eq!(all_up.len(), all_down.len());
109+
assert_ne!(all_up.len(), 0);
110+
111+
for i in 0..all_up.len() {
112+
let M {
113+
up: left_up,
114+
up_hook: _,
115+
down: left_down,
116+
down_hook: _,
117+
foreign_key_check: left_foreign_key_check,
118+
comment: left_comment,
119+
} = all_up[i];
120+
let M {
121+
up: right_up,
122+
up_hook: _,
123+
down: right_down,
124+
down_hook: _,
125+
foreign_key_check: right_foreign_key_check,
126+
comment: right_comment,
127+
} = all_down[i];
128+
129+
assert_eq!(left_up, right_up);
130+
assert_eq!(left_foreign_key_check, right_foreign_key_check);
131+
assert_eq!(left_comment, right_comment);
132+
133+
assert!(left_down.is_none());
134+
assert!(right_down.is_some());
135+
}
136+
}
137+
103138
pub fn m_invalid0() -> M<'static> {
104139
M::up("CREATE TABLE table3()")
105140
}

0 commit comments

Comments
 (0)