Skip to content

Commit

Permalink
adding way to run test suite in new project iron-io#95
Browse files Browse the repository at this point in the history
  • Loading branch information
Roman Dzvinkovsky committed Oct 15, 2012
1 parent b123878 commit 281bca3
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
16 changes: 16 additions & 0 deletions test/Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,22 @@ Rake::TestTask.new do |t|
end
end

if ENV['NEW_PROJECT']
require_relative '../lib/iron_worker_ng.rb'

client = IronWorkerNG::Client.new
name = 'IWtest ' + Time.now.strftime('%b %-d %T')
resp = client.api.post('projects', name: name)
res = JSON.parse(resp.body)
raise "Failed to create new project: #{res}" unless
res['msg'].start_with? 'Project Created'

ENV['IRON_PROJECT_ID'] = res['id']
end
if ENV['IRON_PROJECT_ID']
t.options = "-- --project-id=#{ENV['IRON_PROJECT_ID']}"
end

t.libs << "lib" << "test" << examples_tests_dir
files = FileList['test/**/test_**.rb',
examples_tests_dir + '/**/test_*.rb']
Expand Down
10 changes: 9 additions & 1 deletion test/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
require 'minitest/unit'
require 'minitest/reporters'
require 'tempfile'
require 'optparse'

require_relative '../lib/iron_worker_ng.rb'
require_relative 'iron_io_config.rb'
Expand Down Expand Up @@ -40,7 +41,14 @@ class IWNGTest < Test::Unit::TestCase
attr_accessor :client

def setup
@client = IronWorkerNG::Client.new(:env => 'test')
options = { env: 'test' }
OptionParser.new do |opts|
opts.on('--project-id PROJECT_ID', String) do |p|
options[:project_id] = p
end
end.parse!

@client = IronWorkerNG::Client.new options
end

def get_all_tasks(options = { :from_time => (Time.now - 60 * 60).to_i })
Expand Down

0 comments on commit 281bca3

Please sign in to comment.