Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Writing tests for workers #125

Open
langalex opened this issue Nov 10, 2012 · 5 comments
Open

Writing tests for workers #125

langalex opened this issue Nov 10, 2012 · 5 comments

Comments

@langalex
Copy link

Provide a way to write automated tests for workers. The tests should include building the code package to ensure all files and gems are required correctly.

@iced
Copy link
Contributor

iced commented Nov 26, 2012

@romand-ironio it's for you. suggestion - add method for code package which will show list of files and runtime-specific things (like gems).

@langalex
Copy link
Author

I basically created this ticket as a conversation starter. Basically what I would like to see are two things:

integrated

A way to run workers as part of an integration test suite (in-process). Here's what I'm doing right now:

# a helper for testing workers
# to use a helper just call TestWorkers::<WorkerName>.perform(params)
module TestWorkers
  def self.const_missing(name)
    path = Rails.root.join('workers')
    $LOAD_PATH << path.to_s unless $LOAD_PATH.include?(path.to_s)
    code = File.read(path.join(name.to_s.underscore + '.rb'))
    klass = Class.new
    klass.class_eval "attr_reader :params
    def perform(_params)
      @params = JSON.parse(_params.to_json) # deep stringify keys
      #{code}
    end", __FILE__, __LINE__
    const_set name, klass
    klass
  end
end

And then in a test:

TestWorkers::MyWorker.new.perform :x => :y

Isolated

A way to test a worker in an isolated way to make sure all its dependencies are correct. This would probably use

IronWorkerNG::Code::Base.new(:workerfile => workerfile).run

so what's missing here IMHO is maybe an integration with RSpec.

@iced
Copy link
Contributor

iced commented Nov 26, 2012

Can you please come to support channel @ http://get.iron.io/chat so we can discuss?

@langalex
Copy link
Author

sorry don't have time at the moment. happy to contribute here from time to time.

@iced
Copy link
Contributor

iced commented Nov 26, 2012

any time - we usually have 2-3 devs sitting there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants