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 metadata functionality. #98

Merged
merged 1 commit into from
Apr 4, 2016

Conversation

danhper
Copy link
Collaborator

@danhper danhper commented Apr 2, 2016

This PR will allow us to pass custom metadata to the webdriver, through the user agent string,
which should be enough to handle the use case described in #71.

For example

:ok = Ecto.Adapters.SQL.Sandbox.checkout(MyRepo, [])
Hound.start_session(metadata: %{parent: self()})

Task.start_link fn ->
  user_agent = conn |> get_resp_header("user-agent") |> List.first
  %{parent: parent} = Hound.Metadata.extract(user_agent)
  :ok = Ecto.Adapters.SQL.Sandbox.allow(MyRepo, parent, self())
end

To make this possible, additional capabilities are now passed through the :driver keys, which is a breaking change.

What do you think?

/cc @HashNuke @josevalim

@HashNuke
Copy link
Owner

HashNuke commented Apr 3, 2016

@tuvistavie Looks good. Would be nice to have a wrapper around it though (and call it as support for ecto-sandboxed tests). Users/devs don't need to know that we are using user-agent string to make it work.

@danhper
Copy link
Collaborator Author

danhper commented Apr 3, 2016

@HashNuke Thanks for the feedback!
I was also thinking the same thing, but as we do not depend on Plug and I do not think it is worth depending on it simply for this, I was wondering what to do.

What do you think?

@HashNuke
Copy link
Owner

HashNuke commented Apr 3, 2016

@tuvistavie ah right. My bad. Just noticed the get_resp_header.
Merge it when you are ready.

P.S: Feel free to make releases whenever you think it is appropriate. Hence the hex access :)

on_exit fn-> Hound.end_session end
pid = Hound.start_session(unquote(opts))
on_exit fn ->
Hound.end_session(pid)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This callback should not be required as start_session should monitor the caller and shut it down.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am going to check this, thank you.

@josevalim
Copy link
Contributor

It looks great, I have added some comments. :)

@danhper danhper force-pushed the add-metadata-functionality branch from 08ae32e to 0e91ced Compare April 4, 2016 06:35
@danhper
Copy link
Collaborator Author

danhper commented Apr 4, 2016

@HashNuke Thank you! I will make a new release once we conclude the discussion in phoenixframework/phoenix_ecto#41 and I merge this PR 😃

@josevalim Thank you very much for the feedback. I just updated the PR, integrating the format you suggested.

@josevalim
Copy link
Contributor

:shipit:

@danhper danhper merged commit 1a6f6f4 into HashNuke:master Apr 4, 2016
@danhper danhper deleted the add-metadata-functionality branch April 4, 2016 07:04
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

Successfully merging this pull request may close these issues.

None yet

3 participants