Commit a64dd5ee authored by Leo Iannacone's avatar Leo Iannacone

use fucking done() to wait for conclusion - avoid false positive

parent 2e503eaf
......@@ -11,6 +11,7 @@ should = require('should')
server = null
exec = (c) ->
c = c.replace('"', '\"')
exec_orig("echo '#{c}' >> commands.log")
exec_orig(c)
......@@ -44,10 +45,10 @@ class Helper
append_file: (distribution, debpack, extension, data) ->
file_path = path.join(@base, distribution, 'pool', debpack, debpack) + '.' + extension
@make_package(distribution, debpack)
exec("echo #{data} >> #{file_path}")
exec("echo '#{data}' >> #{file_path}")
append_json: (data) ->
exec("echo #{data} >> #{@json}")
exec("echo '#{data}' >> #{@json}")
clean: (distribution, debpack, file_extension) ->
b_path = @base
......@@ -79,93 +80,106 @@ class Helper
helper = new Helper()
launch_server() if process.env.SERVER
client = null
options =
transports: ['websocket'],
'force new connection': true
describe 'client', ->
before( ->
before( (done) ->
launch_server() if process.env.SERVER
helper.append_json('{"status": "build", "package": "test_1.2.3", "distribution": "unstable"}')
helper.make_distribution('trusty')
helper.make_distribution('unstable')
helper.append_json('{"status": "build", "package": "test_1.2.3", "uploader": "", "distribution": "unstable"}')
done()
)
beforeEach( ->
client = io.connect("http://#{config.host}:#{config.port}")
beforeEach( (done) ->
client = io.connect("http://#{config.host}:#{config.port}", options)
client.once 'connect', ->
done()
)
afterEach( ->
afterEach( (done) ->
client.disconnect()
done()
)
it 'get distributions', (done)->
client.on events.broadcast.distributions, (data) ->
client.once events.broadcast.distributions, (data) ->
data.should.be.eql(['trusty', 'unstable'])
done()
it 'get debomatic status', (done) ->
client.on events.broadcast.status_debomatic, (data) ->
client.once events.broadcast.status_debomatic, (data) ->
data.running.should.be.false
done()
it 'get package status', (done) ->
client.on events.broadcast.status, (data) ->
client.once events.client.status, (data) ->
data = data[0]
data.status.should.be.eql('build')
data.distribution.should.be.eql('unstable')
data.package.should.be.eql('test_1.2.3')
done()
it 'on getting distribution packages', ->
it 'on getting distribution packages', (done) ->
helper.make_package('unstable', 'test_1.2.3')
helper.make_package('unstable', 'test_1.2.4')
client.emit(events.client.distribution_packages, helper.get_query('unstable'))
client.on events.client.distribution_packages, (data) ->
client.once events.client.distribution_packages, (data) ->
data.distribution.name.should.be.eql('unstable')
packages_name = []
for p in data.distribution.packages
packages_name.push(p.orig_name)
packages_name.should.be.eql(['test_1.2.3', 'test_1.2.4'])
done()
it 'on getting package list', ->
it 'on getting package list', (done) ->
helper.make_file('unstable', 'test_1.2.3', 'buildlog', 'test')
helper.make_file('unstable', 'test_1.2.3', 'lintian', 'test')
client.emit(events.client.package_files_list, helper.get_query('unstable', 'test_1.2.3'))
client.on events.client.package_files_list, (data) ->
client.once events.client.package_files_list, (data) ->
data.distribution.name.should.be.eql('unstable')
data.package.orig_name.should.be.eql('test_1.2.3')
files_name = []
for f in data.package.files
files_name.push(f.name)
files_name.should.be.eql(['buildlog', 'lintian'])
done()
describe 'on getting file', ->
it 'full content', ->
it 'full content', (done) ->
helper.make_file('unstable', 'test_1.2.3', 'buildlog', 'this is a test')
client.emit(events.client.file, helper.get_query('unstable', 'test_1.2.3', 'buildlog'))
client.on events.client.file, (data) ->
client.once events.client.file, (data) ->
data.distribution.name.should.be.eql('unstable')
data.package.orig_name.should.be.eql('test_1.2.3')
data.file.name.should.be.eql('buildlog')
data.file.content.should.be.eql('this is a test\n')
done()
it 'new content', (done) ->
client.on events.client.file_newcontent, (data) ->
client.once events.client.file_newcontent, (data) ->
data.distribution.name.should.be.eql('unstable')
data.package.orig_name.should.be.eql('test_1.2.3')
data.file.name.should.be.eql('buildlog')
data.file.new_content.should.be.eql('this is an appending test\n')
done()
client.emit(events.client.file, helper.get_query('unstable', 'test_1.2.3', 'buildlog'))
helper.append_file('unstable', 'test_1.2.3', 'buildlog', 'this is an appending test')
describe 'on build package ends', ->
it 'should receive a status update', (done) ->
str = '{"status": "build", "success": true, "package": "test_1.2.3", "uploader": "", "distribution": "unstable"}'
helper.append_json(str)
client.on events.broadcast.status_update, (data) ->
data.success.should.not.be.ok
client.once events.broadcast.status_update, (data) ->
data.success.should.be.ok
done()
process.on 'exit', () ->
client.disconnect()
helper.clean_all()
#helper.clean_all()# if process.env.SERVER
server.kill() if process.env.SERVER
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment