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

Add idempotence rules to the DSL #21

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Add idempotence rules to the DSL #21

wants to merge 2 commits into from

Conversation

mavnn
Copy link
Contributor

@mavnn mavnn commented Oct 18, 2019

Experimental idea: this PR adds "idempotence rules" to edge tests, allowing you to override values that might change from run to run of the edge tests.

pin_value pins a value of a specific field in the JSON:

controller ApplicationController do
  action :home do
    edge "write elm file" do
      perform_get
      pin_value(["key1", "key2"], 10)
      produce_elm_file('Home')
    end
  end
end

will error if the JSON created doesn't contain an item at json_data["key1"]["key2"]. If it does contain an item, it will override it with the pinned value supplied (10).

The more general add_idempotence_rule just allows you to supply a block which can carry out arbitrary transformations on the generated JSON hash:

controller ApplicationController do
  action :home do
    edge "write elm file" do
      perform_get
      add_idempotence_rule do |json_data|
        json_data["key1"]["key2"] = 10
      end
      produce_elm_file('Home')
    end
  end
end

@mavnn mavnn requested a review from avh4 October 18, 2019 16:51
@rekahsoft rekahsoft added the hold label Aug 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants