Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

reorg tests #275

Merged
merged 1 commit into from
May 26, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion test/browser.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
'use strict'

require('./core-tests/browser')
require('./core/browser')
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
18 changes: 18 additions & 0 deletions test/core/both/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/* eslint-env mocha */
'use strict'

const fs = require('fs')

describe('--both', () => {
const tests = fs.readdirSync(__dirname)

tests.filter((file) => {
if (file === 'index.js') {
return false
} else {
return true
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this could be much simpler

tests.filter((file) => file !== 'index.js')

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

adding that to the network tests :)

}).forEach((file) => {
require('./' + file)
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const bl = require('bl')
const API = require('ipfs-api')
const multiaddr = require('multiaddr')

const IPFS = require('../../src/core')
const IPFS = require('../../../src/core')

function makeBlock () {
return new Block(`IPFS is awesome ${Math.random()}`)
Expand All @@ -22,7 +22,7 @@ describe('bitswap', () => {
let ipfs

beforeEach((done) => {
ipfs = new IPFS(require('./repo-path'))
ipfs = new IPFS(require('../../utils/repo-path'))
ipfs.load(done)
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,22 @@
const expect = require('chai').expect
const base58 = require('bs58')
const fs = require('fs')
const IPFS = require('../../src/core')
const IPFS = require('../../../src/core')
const Block = require('ipfs-block')
const path = require('path')

const isNode = require('detect-node')

const fileA = isNode
? fs.readFileSync(path.join(__dirname, '../go-ipfs-repo/blocks/12207028/122070286b9afa6620a66f715c7020d68af3d10e1a497971629c07606bfdb812303d.data'))
: require('buffer!./../go-ipfs-repo/blocks/12207028/122070286b9afa6620a66f715c7020d68af3d10e1a497971629c07606bfdb812303d.data')
? fs.readFileSync(path.join(__dirname, '../../go-ipfs-repo/blocks/12207028/122070286b9afa6620a66f715c7020d68af3d10e1a497971629c07606bfdb812303d.data'))
: require('buffer!./../../go-ipfs-repo/blocks/12207028/122070286b9afa6620a66f715c7020d68af3d10e1a497971629c07606bfdb812303d.data')

// TODO use arrow funtions again when https://github.com/webpack/webpack/issues/1944 is fixed
describe('block', function () {
var ipfs

before((done) => {
ipfs = new IPFS(require('./repo-path'))
ipfs = new IPFS(require('../../utils/repo-path'))
ipfs.load(done)
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@

const expect = require('chai').expect

const IPFS = require('../../src/core')
const IPFS = require('../../../src/core')

describe('bootstrap', () => {
var ipfs

before((done) => {
ipfs = new IPFS(require('./repo-path'))
ipfs = new IPFS(require('../../utils/repo-path'))
ipfs.load(done)
})

Expand Down
15 changes: 3 additions & 12 deletions test/core-tests/test-config.js → test/core/both/test-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
'use strict'

const expect = require('chai').expect
const IPFS = require('../../src/core')
const IPFS = require('../../../src/core')

describe('config', () => {
var defaultConfig = {
Expand Down Expand Up @@ -68,7 +68,7 @@ describe('config', () => {
var ipfs

before((done) => {
ipfs = new IPFS(require('./repo-path'))
ipfs = new IPFS(require('../../utils/repo-path'))
ipfs.load(done)
})

Expand All @@ -81,7 +81,7 @@ describe('config', () => {
})

it('replace', (done) => {
ipfs = new IPFS(require('./repo-path'))
ipfs = new IPFS(require('../../utils/repo-path'))
ipfs.config.replace({}, (err) => {
expect(err).to.not.exist
ipfs.config.show((err, config) => {
Expand All @@ -94,13 +94,4 @@ describe('config', () => {
})
})
})

// cli only feature built with show and replace
// it.skip('edit', (done) => {
// ipfs = new IPFS(require('./repo-pathe'))
// ipfs.config((err, config) => {
// expect(err).to.not.exist
// done()
// })
// })
})
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ const expect = require('chai').expect
const Readable = require('stream').Readable
const bs58 = require('bs58')

const IPFS = require('../../src/core')
const IPFS = require('../../../src/core')

describe('files', () => {
let ipfs

before((done) => {
ipfs = new IPFS(require('./repo-path'))
ipfs = new IPFS(require('../../utils/repo-path'))
ipfs.load(done)
})

Expand Down
4 changes: 2 additions & 2 deletions test/core-tests/test-id.js → test/core/both/test-id.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@

const expect = require('chai').expect

const IPFS = require('../../src/core')
const IPFS = require('../../../src/core')

describe('id', () => {
var ipfs

before((done) => {
ipfs = new IPFS(require('./repo-path'))
ipfs = new IPFS(require('../../utils/repo-path'))
ipfs.load(done)
})

Expand Down
4 changes: 2 additions & 2 deletions test/core-tests/test-init.js → test/core/both/test-init.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
'use strict'

const expect = require('chai').expect
const IPFS = require('../../src/core')
const createTempRepo = require('../utils/temp-repo')
const IPFS = require('../../../src/core')
const createTempRepo = require('../../utils/temp-repo')

describe('init', function () {
this.timeout(50 * 1000)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

const test = require('interface-ipfs-core')

const IPFS = require('../../src/core')
const IPFS = require('../../../src/core')

const common = {
setup: function (cb) {
const ipfs = new IPFS(require('./repo-path'))
const ipfs = new IPFS(require('../../utils/repo-path'))
ipfs.load(() => {
cb(null, ipfs)
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@

const expect = require('chai').expect

const IPFS = require('../../src/core')
const IPFS = require('../../../src/core')

describe('version', () => {
var ipfs

before((done) => {
ipfs = new IPFS(require('./repo-path'))
ipfs = new IPFS(require('../../utils/repo-path'))
ipfs.load(done)
})

Expand Down
17 changes: 17 additions & 0 deletions test/core/browser-only/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/* eslint-env mocha */
'use strict'

const fs = require('fs')

describe('--browser only', () => {
const tests = fs.readdirSync(__dirname)
tests.filter((file) => {
if (file === 'index.js') {
return false
} else {
return true
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

}).forEach((file) => {
require('./' + file)
})
})
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
'use strict'

15 changes: 3 additions & 12 deletions test/core-tests/browser.js → test/core/browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const idb = window.indexedDB ||
idb.deleteDatabase('ipfs')
idb.deleteDatabase('ipfs/blocks')

describe('IPFS Repo Tests on the Browser', function () {
describe('core', function () {
this.timeout(10000)
before(function (done) {
var repoData = []
Expand Down Expand Up @@ -44,15 +44,6 @@ describe('IPFS Repo Tests on the Browser', function () {
}), done)
})

it('--', () => {
const testsContext = require.context('.', true, /test-*/)
testsContext
.keys()
.filter((key) => {
return !(key.endsWith('-node.js') || key.endsWith('-node'))
})
.forEach((key) => {
testsContext(key)
})
})
require('./both')
require('./browser-only')
})
36 changes: 36 additions & 0 deletions test/core/node-only/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/* eslint-env mocha */
'use strict'

const fs = require('fs')
const ncp = require('ncp').ncp
const expect = require('chai').expect
const path = require('path')
const clean = require('../../utils/clean')

describe('--node only', () => {
const repoExample = path.join(__dirname, '../../go-ipfs-repo')
const repoTests = require('../../utils/repo-path')

before((done) => {
clean(repoTests)
ncp(repoExample, repoTests, (err) => {
expect(err).to.equal(null)
done()
})
})

after(() => {
clean(repoTests)
})

const tests = fs.readdirSync(__dirname)
tests.filter((file) => {
if (file === 'index.js') {
return false
} else {
return true
}
}).forEach((file) => {
require('./' + file)
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
'use strict'

const expect = require('chai').expect
const IPFS = require('../../src/core')
const createTempRepo = require('../utils/temp-repo')
const IPFS = require('../../../src/core')
const createTempRepo = require('../../utils/temp-repo')

describe('init (Node.js specific)', function () {
this.timeout(10000)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

const expect = require('chai').expect

const createTempNode = require('../utils/temp-node')
const createTempNode = require('../../utils/temp-node')

describe('swarm', function () {
this.timeout(20000)
Expand Down
19 changes: 3 additions & 16 deletions test/core-tests/index.js → test/core/node.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
/* eslint-env mocha */
'use strict'

const fs = require('fs')
const ncp = require('ncp').ncp
const expect = require('chai').expect
const path = require('path')
const clean = require('../utils/clean')

describe('core', () => {
const repoExample = path.join(__dirname, '../go-ipfs-repo')
const repoTests = require('./repo-path')
const repoTests = require('../utils/repo-path')

before((done) => {
clean(repoTests)
Expand All @@ -22,18 +21,6 @@ describe('core', () => {
after(() => {
clean(repoTests)
})

describe('--all', () => {
const tests = fs.readdirSync(__dirname)
tests.filter((file) => {
if (file === 'index.js' ||
file.endsWith('browser.js')) {
return false
} else {
return true
}
}).forEach((file) => {
require('./' + file)
})
})
require('./both')
require('./node-only')
})
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions test/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ if (process.env.TEST) {
}

if (testCore) {
require('./core-tests')
require('./core/node')
}

if (testHTTP) {
require('./http-api-tests')
require('./http-api')
}

if (testCLI) {
require('./cli-tests')
require('./cli')
}
File renamed without changes.