MCPcopy Index your code
hub / github.com/nodejs/node / testTruncate

Function testTruncate

test/parallel/test-fs-truncate.js:72–97  ·  view source on GitHub ↗
(cb)

Source from the content-addressed store, hash-verified

70
71/* eslint-disable node-core/must-call-assert */
72function testTruncate(cb) {
73 fs.writeFile(filename, data, function(er) {
74 if (er) return cb(er);
75 fs.stat(filename, function(er, stat) {
76 if (er) return cb(er);
77 assert.strictEqual(stat.size, 1024 * 16);
78
79 fs.truncate(filename, 1024, function(er) {
80 if (er) return cb(er);
81 fs.stat(filename, function(er, stat) {
82 if (er) return cb(er);
83 assert.strictEqual(stat.size, 1024);
84
85 fs.truncate(filename, function(er) {
86 if (er) return cb(er);
87 fs.stat(filename, function(er, stat) {
88 if (er) return cb(er);
89 assert.strictEqual(stat.size, 0);
90 cb();
91 });
92 });
93 });
94 });
95 });
96 });
97}
98
99function testFtruncate(cb) {
100 fs.writeFile(filename, data, function(er) {

Callers 1

Calls 4

cbFunction · 0.70
writeFileMethod · 0.45
statMethod · 0.45
truncateMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…