History

[ref] the drop test

Sebastian Thiel committed 5 years ago

Commit e472bde1 parent 059f8361 file · +38 −2Browse files

Unified · Split

git-ref/tests/file/transaction/prepare_and_commit/create_or_update.rs+38−2
@@ -80,8 +80,44 @@ fn reference_with_old_value_must_exist_when_creating_it_and_have_that_value() {} · 79 unmodified lines
8080 fn reference_without_old_value_must_not_exist_already_when_creating_it() {}
8181
8282 #[test]
83−#[ignore]
84−fn cancellation_after_preparation_leaves_no_change() {}
83+fn cancellation_after_preparation_leaves_no_change() {
84+ let (dir, store) = empty_store().unwrap();
85+
86+ let tx = store.transaction(
87+ Some(RefEdit {
88+ change: Change::Update {
89+ log: LogChange {
90+ mode: RefLog::AndReference,
91+ force_create_reflog: false,
92+ message: Default::default(),
93+ },
94+ new: Target::Symbolic("refs/heads/main".try_into().unwrap()),
95+ mode: Create::Only,
96+ },
97+ name: "HEAD".try_into().unwrap(),
98+ deref: false,
99+ }),
100+ Fail::Immediately,
101+ );
102+
103+ assert_eq!(
104+ std::fs::read_dir(dir.path()).unwrap().count(),
105+ 0,
106+ "nothing happens before preparation"
107+ );
108+
109+ let tx = tx.prepare().unwrap();
110+
111+ assert_eq!(
112+ std::fs::read_dir(dir.path()).unwrap().count(),
113+ 1,
114+ "the lock file was created"
115+ );
116+
117+ drop(tx);
118+
119+ assert_eq!(std::fs::read_dir(dir.path()).unwrap().count(), 0, "everything vanished");
120+}
85121
86122 #[test]
87123 fn symbolic_head_missing_referent_then_update_referent() -> crate::Result {

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t