Skip to content

Commit

Permalink
add nanoseconds test
Browse files Browse the repository at this point in the history
  • Loading branch information
jayree committed Jun 20, 2023
1 parent ace42f9 commit 0fa17a2
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
1 change: 1 addition & 0 deletions __tests__/__fixtures__/test-GitIndex-timestamp/nano.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
validate nanoseconds
33 changes: 32 additions & 1 deletion __tests__/test-GitIndex.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@

const path = require('path')

const { GitIndex, GitIndexManager } = require('isomorphic-git/internal-apis')
const {
GitIndex,
GitIndexManager,
FileSystem,
} = require('isomorphic-git/internal-apis')

const { normalizeStats } = require('../src/utils/normalizeStats.js')

const { makeFixture } = require('./__helpers__/FixtureFS.js')

Expand Down Expand Up @@ -128,4 +134,29 @@ describe('GitIndex', () => {
expect(ctimeSeconds).not.toBeNull()
expect(ctimeNanoseconds).not.toBeNull()
})
;(process.browser ? xit : it)(
'ensure nanoseconds of files are equal with index',
async () => {
const _fs = Object.assign({}, require('fs'))
const fs = new FileSystem(_fs)

const buffer = await fs.read(path.join('.git/index'))
const index = await GitIndex.from(buffer)
const file = '__tests__/__fixtures__/test-GitIndex-timestamp/nano.txt'

const stats = normalizeStats(await fs.lstat(file))
expect(index.entriesMap.get(file).ctimeSeconds).toEqual(
stats.ctimeSeconds
)
expect(index.entriesMap.get(file).ctimeNanoseconds).toEqual(
stats.ctimeNanoseconds
)
expect(index.entriesMap.get(file).mtimeSeconds).toEqual(
stats.mtimeSeconds
)
expect(index.entriesMap.get(file).mtimeNanoseconds).toEqual(
stats.mtimeNanoseconds
)
}
)
})

0 comments on commit 0fa17a2

Please sign in to comment.