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

Fix failing gateway tests with this one simple trick! #1006

Merged
merged 3 commits into from
Sep 8, 2017
Merged
Show file tree
Hide file tree
Changes from 2 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
43 changes: 35 additions & 8 deletions test/gateway/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ const directoryContent = {
'index.html': loadFixture(__dirname, './test-folder/index.html', 'ipfs'),
'nested-folder/hello.txt': loadFixture(__dirname, './test-folder/nested-folder/hello.txt', 'ipfs'),
'nested-folder/ipfs.txt': loadFixture(__dirname, './test-folder/nested-folder/ipfs.txt', 'ipfs'),
'nested-folder/nested.html': loadFixture(__dirname, './test-folder/nested-folder/nested.html', 'ipfs')
'nested-folder/nested.html': loadFixture(__dirname, './test-folder/nested-folder/nested.html', 'ipfs'),
'cat-folder/cat.jpg': loadFixture(__dirname, './test-folder/cat-folder/cat.jpg', 'ipfs')
}

describe('HTTP Gateway', () => {
Expand All @@ -38,17 +39,17 @@ describe('HTTP Gateway', () => {
}
})

const content = (name) => ({
path: `test-folder/${name}`,
content: directoryContent[name]
})

const emptyDir = (name) => ({ path: `test-folder/${name}` })

series([
(cb) => http.api.start(true, cb),
(cb) => {
gateway = http.api.server.select('Gateway')
const content = (name) => ({
path: `test-folder/${name}`,
content: directoryContent[name]
})

const emptyDir = (name) => ({ path: `test-folder/${name}` })

const expectedRootMultihash = 'QmbQD7EMEL1zeebwBsWEfA3ndgSS6F7S6iTuwuqasPgVRi'

const dirs = [
Expand Down Expand Up @@ -79,6 +80,32 @@ describe('HTTP Gateway', () => {
expect(file.hash).to.equal(expectedMultihash)
cb()
})
},
(cb) => {
const expectedMultihash = 'QmT78zSuBmuS4z925WZfrqQ1qHaJ56DQaTfyMUF7F8ff5o'

http.api.node.files.add(Buffer.from('hello world' + '\n'), (err, res) => {
expect(err).to.not.exist()
const file = res[0]
expect(file.path).to.equal(expectedMultihash)
expect(file.hash).to.equal(expectedMultihash)
cb()
})
},
(cb) => {
const expectedMultihash = 'QmW2WQi7j6c7UgJTarActp7tDNikE4B2qXtFCfLPdsgaTQ'

let dir = [
content('cat-folder/cat.jpg')
]

http.api.node.files.add(dir, (err, res) => {
expect(err).to.not.exist()
const file = res[1]
expect(file.path).to.equal('test-folder/cat-folder')
expect(file.hash).to.equal(expectedMultihash)
cb()
})
}
], done)
})
Expand Down
Binary file added test/gateway/test-folder/cat-folder/cat.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.