Skip to content

Commit

Permalink
chore: add tests for added files
Browse files Browse the repository at this point in the history
  • Loading branch information
achingbrain committed Apr 18, 2024
1 parent 6a5db09 commit ac97883
Show file tree
Hide file tree
Showing 21 changed files with 1,153 additions and 7 deletions.
83 changes: 77 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@
"lint": "aegir lint",
"lint:fix": "aegir lint --fix",
"clean": "aegir clean",
"dep-check": "aegir dep-check -i electron-fetch",
"dep-check": "aegir dep-check -i electron-fetch buffer",
"release": "aegir release"
},
"dependencies": {
Expand Down Expand Up @@ -205,8 +205,10 @@
"@types/pako": "^2.0.3",
"@types/readable-stream": "^4.0.11",
"@types/sinon": "^17.0.3",
"@web-std/file": "^3.0.3",
"aegir": "^42.2.5",
"blockstore-core": "^4.4.1",
"buffer": "^6.0.3",
"delay": "^6.0.0",
"did-jwt": "^8.0.4",
"interface-blockstore": "^5.2.10",
Expand Down
Empty file.
1 change: 1 addition & 0 deletions test/fixtures/another-dir/hello.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
hello
Empty file added test/fixtures/dir/.hidden.txt
Empty file.
Empty file added test/fixtures/dir/file-1.txt
Empty file.
Empty file added test/fixtures/dir/file-2.js
Empty file.
Empty file added test/fixtures/dir/file-3.css
Empty file.
Empty file.
Empty file added test/fixtures/file-0.html
Empty file.
1 change: 1 addition & 0 deletions test/fixtures/file.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
hello world
53 changes: 53 additions & 0 deletions test/lib/files/format-mode.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/* eslint-env mocha */

import { expect } from 'aegir/chai'
import { formatMode } from '../../../src/lib/files/format-mode.js'

describe('format-mode', function () {
it('formats mode for directories', function () {
expect(formatMode(parseInt('0777', 8), true)).to.equal('drwxrwxrwx')
})

it('formats mode for files', function () {
expect(formatMode(parseInt('0777', 8), false)).to.equal('-rwxrwxrwx')
})

it('setgid, setuid and stick bit', function () {
expect(formatMode(parseInt('1777', 8), false)).to.equal('-rwxrwxrwt')
expect(formatMode(parseInt('2777', 8), false)).to.equal('-rwxrwsrwx')
expect(formatMode(parseInt('4777', 8), false)).to.equal('-rwsrwxrwx')
expect(formatMode(parseInt('5777', 8), false)).to.equal('-rwsrwxrwt')
expect(formatMode(parseInt('6777', 8), false)).to.equal('-rwsrwsrwx')
expect(formatMode(parseInt('7777', 8), false)).to.equal('-rwsrwsrwt')
})

it('formats user', function () {
expect(formatMode(parseInt('0100', 8), false)).to.equal('---x------')
expect(formatMode(parseInt('0200', 8), false)).to.equal('--w-------')
expect(formatMode(parseInt('0300', 8), false)).to.equal('--wx------')
expect(formatMode(parseInt('0400', 8), false)).to.equal('-r--------')
expect(formatMode(parseInt('0500', 8), false)).to.equal('-r-x------')
expect(formatMode(parseInt('0600', 8), false)).to.equal('-rw-------')
expect(formatMode(parseInt('0700', 8), false)).to.equal('-rwx------')
})

it('formats group', function () {
expect(formatMode(parseInt('0010', 8), false)).to.equal('------x---')
expect(formatMode(parseInt('0020', 8), false)).to.equal('-----w----')
expect(formatMode(parseInt('0030', 8), false)).to.equal('-----wx---')
expect(formatMode(parseInt('0040', 8), false)).to.equal('----r-----')
expect(formatMode(parseInt('0050', 8), false)).to.equal('----r-x---')
expect(formatMode(parseInt('0060', 8), false)).to.equal('----rw----')
expect(formatMode(parseInt('0070', 8), false)).to.equal('----rwx---')
})

it('formats other', function () {
expect(formatMode(parseInt('0001', 8), false)).to.equal('---------x')
expect(formatMode(parseInt('0002', 8), false)).to.equal('--------w-')
expect(formatMode(parseInt('0003', 8), false)).to.equal('--------wx')
expect(formatMode(parseInt('0004', 8), false)).to.equal('-------r--')
expect(formatMode(parseInt('0005', 8), false)).to.equal('-------r-x')
expect(formatMode(parseInt('0006', 8), false)).to.equal('-------rw-')
expect(formatMode(parseInt('0007', 8), false)).to.equal('-------rwx')
})
})
14 changes: 14 additions & 0 deletions test/lib/files/format-mtime.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/* eslint-env mocha */

import { expect } from 'aegir/chai'
import { formatMtime } from '../../../src/lib/files/format-mtime.js'

describe('format-mtime', function () {
it('formats mtime', function () {
expect(formatMtime({ secs: 15768000n, nsecs: 0 })).to.include('1970')
})

it('formats empty mtime', function () {
expect(formatMtime()).to.equal('-')
})
})
Loading

0 comments on commit ac97883

Please sign in to comment.