Skip to content

Commit f2a9b3f

Browse files
committed
update index::entry::stat tests
1 parent d7f250d commit f2a9b3f

File tree

2 files changed

+304
-222
lines changed

2 files changed

+304
-222
lines changed

gix-index/src/entry/stat.rs

Lines changed: 0 additions & 222 deletions
Original file line numberDiff line numberDiff line change
@@ -191,225 +191,3 @@ impl Default for Options {
191191
}
192192
}
193193
}
194-
195-
#[cfg(test)]
196-
mod test {
197-
use filetime::FileTime;
198-
199-
use crate::entry::stat::{Options, Time};
200-
use crate::entry::Stat;
201-
202-
#[test]
203-
fn use_nsec() {
204-
let stat1 = Stat {
205-
mtime: Time { secs: 0, nsecs: 0 },
206-
ctime: Time { secs: 0, nsecs: 0 },
207-
dev: 0,
208-
ino: 0,
209-
uid: 0,
210-
gid: 0,
211-
size: 0,
212-
};
213-
let stat2 = Stat {
214-
mtime: Time { secs: 0, nsecs: 10 },
215-
ctime: Time { secs: 0, nsecs: 0 },
216-
dev: 0,
217-
ino: 0,
218-
uid: 0,
219-
gid: 0,
220-
size: 0,
221-
};
222-
223-
assert!(stat1.matches(&stat2, Options::default()));
224-
assert!(!stat1.matches(
225-
&stat2,
226-
Options {
227-
use_nsec: true,
228-
..Default::default()
229-
}
230-
));
231-
assert!(stat1.matches(
232-
&stat2,
233-
Options {
234-
use_nsec: true,
235-
check_stat: false,
236-
..Default::default()
237-
}
238-
));
239-
}
240-
241-
#[test]
242-
fn use_ctime() {
243-
let stat1 = Stat {
244-
mtime: Time { secs: 0, nsecs: 0 },
245-
ctime: Time { secs: 1, nsecs: 2 },
246-
dev: 0,
247-
ino: 0,
248-
uid: 0,
249-
gid: 0,
250-
size: 0,
251-
};
252-
let stat2 = Stat {
253-
mtime: Time { secs: 0, nsecs: 0 },
254-
ctime: Time { secs: 3, nsecs: 4 },
255-
dev: 0,
256-
ino: 0,
257-
uid: 0,
258-
gid: 0,
259-
size: 0,
260-
};
261-
262-
assert!(!stat1.matches(&stat2, Options::default()));
263-
assert!(!stat1.matches(
264-
&stat2,
265-
Options {
266-
use_nsec: true,
267-
..Default::default()
268-
}
269-
));
270-
assert!(stat1.matches(
271-
&stat2,
272-
Options {
273-
trust_ctime: false,
274-
..Default::default()
275-
}
276-
));
277-
}
278-
279-
#[test]
280-
fn use_stdev() {
281-
let stat1 = Stat {
282-
mtime: Time { secs: 0, nsecs: 0 },
283-
ctime: Time { secs: 0, nsecs: 0 },
284-
dev: 0,
285-
ino: 0,
286-
uid: 0,
287-
gid: 0,
288-
size: 0,
289-
};
290-
let stat2 = Stat {
291-
mtime: Time { secs: 0, nsecs: 0 },
292-
ctime: Time { secs: 0, nsecs: 0 },
293-
dev: 1,
294-
ino: 0,
295-
uid: 0,
296-
gid: 0,
297-
size: 0,
298-
};
299-
300-
assert!(stat1.matches(&stat2, Options::default()));
301-
assert!(!stat1.matches(
302-
&stat2,
303-
Options {
304-
use_stdev: true,
305-
..Default::default()
306-
}
307-
));
308-
}
309-
310-
#[test]
311-
fn check_stat() {
312-
let stat1 = Stat {
313-
mtime: Time { secs: 0, nsecs: 0 },
314-
ctime: Time { secs: 0, nsecs: 0 },
315-
dev: 0,
316-
ino: 0,
317-
uid: 0,
318-
gid: 0,
319-
size: 0,
320-
};
321-
let mut stat2 = stat1;
322-
assert!(stat1.matches(&stat2, Options::default()));
323-
assert!(stat1.matches(
324-
&stat2,
325-
Options {
326-
check_stat: false,
327-
..Default::default()
328-
}
329-
));
330-
stat2.ino = 1;
331-
assert!(!stat1.matches(&stat2, Options::default()));
332-
assert!(stat1.matches(
333-
&stat2,
334-
Options {
335-
check_stat: false,
336-
..Default::default()
337-
}
338-
));
339-
stat2 = stat1;
340-
stat2.uid = 1;
341-
assert!(!stat1.matches(&stat2, Options::default()));
342-
assert!(stat1.matches(
343-
&stat2,
344-
Options {
345-
check_stat: false,
346-
..Default::default()
347-
}
348-
));
349-
stat2 = stat1;
350-
stat2.gid = 1;
351-
assert!(!stat1.matches(&stat2, Options::default()));
352-
assert!(stat1.matches(
353-
&stat2,
354-
Options {
355-
check_stat: false,
356-
..Default::default()
357-
}
358-
));
359-
stat2 = stat1;
360-
stat2.size = 1;
361-
assert!(!stat1.matches(&stat2, Options::default()));
362-
assert!(!stat1.matches(
363-
&stat2,
364-
Options {
365-
check_stat: false,
366-
..Default::default()
367-
}
368-
));
369-
}
370-
371-
#[test]
372-
fn racy_timestamp() {
373-
let stat1 = Stat {
374-
mtime: Time { secs: 1, nsecs: 10 },
375-
ctime: Time { secs: 0, nsecs: 0 },
376-
dev: 0,
377-
ino: 0,
378-
uid: 0,
379-
gid: 0,
380-
size: 0,
381-
};
382-
assert!(stat1.is_racy(FileTime::from_unix_time(1, 0), Options::default()));
383-
assert!(stat1.is_racy(
384-
FileTime::from_unix_time(1, 0),
385-
Options {
386-
use_nsec: true,
387-
..Default::default()
388-
}
389-
));
390-
assert!(stat1.is_racy(FileTime::from_unix_time(1, 10), Options::default()));
391-
assert!(stat1.is_racy(
392-
FileTime::from_unix_time(1, 10),
393-
Options {
394-
use_nsec: true,
395-
..Default::default()
396-
}
397-
));
398-
assert!(stat1.is_racy(FileTime::from_unix_time(1, 20), Options::default()));
399-
assert!(!stat1.is_racy(
400-
FileTime::from_unix_time(1, 20),
401-
Options {
402-
use_nsec: true,
403-
..Default::default()
404-
}
405-
));
406-
assert!(!stat1.is_racy(FileTime::from_unix_time(2, 0), Options::default()));
407-
assert!(!stat1.is_racy(
408-
FileTime::from_unix_time(2, 0),
409-
Options {
410-
use_nsec: true,
411-
..Default::default()
412-
}
413-
));
414-
}
415-
}

0 commit comments

Comments
 (0)