Skip to content

Commit

Permalink
add unit tests for deletion+upload attempt
Browse files Browse the repository at this point in the history
  • Loading branch information
Romain authored and aenario committed Feb 2, 2018
1 parent fcac42b commit d6b9b23
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion test/unit/remote/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import crypto from 'crypto'
import EventEmitter from 'events'
import fs from 'fs'
import fs from 'fs-extra'
import { pick } from 'lodash'
import path from 'path'
import sinon from 'sinon'
Expand Down Expand Up @@ -168,6 +168,19 @@ describe('Remote', function () {
await this.remote.addFileAsync(metadata)
await should(cozy.files.statByPath('/foo/bar')).be.fulfilled()
})

it('does not throw if the file does not exists locally anymore', async function () {
const metadata: Metadata = metadataBuilders.file().path('foo').build()
this.remote.other = {
createReadStreamAsync (localDoc) {
return fs.readFileAsync('/path/do/not/exists')
}
}
await this.remote.addFileAsync(metadata)
should.exist(metadata.remote._id)
should.exist(metadata.remote._rev)
should.exist(metadata._deleted)
})
})

describe('addFolderAsync', () => {
Expand Down Expand Up @@ -274,6 +287,19 @@ describe('Remote', function () {
md5sum: old.md5sum
})
})

it('does not throw if the file does not exists locally anymore', async function () {
const metadata: Metadata = metadataBuilders.file().path('foo').build()
this.remote.other = {
createReadStreamAsync (localDoc) {
return fs.readFileAsync('/path/do/not/exists')
}
}
await this.remote.addFileAsync(metadata)
should.exist(metadata.remote._id)
should.exist(metadata.remote._rev)
should.exist(metadata._deleted)
})
})
}

Expand Down

0 comments on commit d6b9b23

Please sign in to comment.