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

test: use os.tmpdir() #1126

Merged
merged 3 commits into from
Dec 5, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
test: use os.tmpdir()
  • Loading branch information
richardschneider committed Dec 4, 2017
commit ba0aa65441455702830e9b5c001318b40594a1b3
4 changes: 2 additions & 2 deletions test/cli/daemon.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ const ipfsCmd = require('../utils/ipfs-exec')
const pull = require('pull-stream')
const toPull = require('stream-to-pull-stream')
const os = require('os')
const fs = require('fs')
const path = require('path')
const fs = require('fs')

const isWindows = os.platform() === 'win32'

Expand Down Expand Up @@ -65,7 +65,7 @@ describe('daemon', () => {
let ipfs

beforeEach(() => {
repoPath = '/tmp/ipfs-test-not-found-' + Math.random().toString().substring(2, 8)
repoPath = path.join(os.tmpdir(), 'ipfs-test-not-found-' + Math.random().toString().substring(2, 8))
Copy link
Member

Choose a reason for hiding this comment

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

If you don't mind here as well (ref ipfs-inactive/ipfs-performance-profiling#12 (comment))

ipfs = ipfsCmd(repoPath)
})

Expand Down
4 changes: 3 additions & 1 deletion test/core/create-node.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ const dirtyChai = require('dirty-chai')
const expect = chai.expect
chai.use(dirtyChai)
const series = require('async/series')
const os = require('os')
const path = require('path')

const isNode = require('detect-node')
const IPFS = require('../../src/core')
Expand All @@ -19,7 +21,7 @@ describe('create node', function () {
this.timeout(80 * 1000)

const node = new IPFS({
repo: '/tmp/ipfs-repo-' + Math.random(),
repo: path.join(os.tmpdir(), 'ipfs-repo-' + Math.random()),
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@diasdavid Good idea. I don't like seeing Math.random, because I always worry if a cryptographically secure P/RNG should be used.

config: {
Addresses: {
Swarm: []
Expand Down
4 changes: 3 additions & 1 deletion test/utils/ipfs-factory-instance/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
const series = require('async/series')
const each = require('async/each')
const hat = require('hat')
const os = require('os')
const path = require('path')

const defaultConfig = require('./default-config.json')
const IPFS = require('../../../src/core')
Expand Down Expand Up @@ -30,7 +32,7 @@ function Factory () {
}

if (!repoPath) {
repoPath = '/tmp/.ipfs-' + hat()
repoPath = path.join(os.tmpdir(), '.ipfs-' + hat())
}

const config = Object.assign({}, defaultConfig, suppliedConfig)
Expand Down