Skip to content

Commit

Permalink
Fix pubsub adapter (#35)
Browse files Browse the repository at this point in the history
* Send attributes to pubsub

* Set fixture with valid data
  • Loading branch information
jjponz authored Feb 3, 2020
1 parent 1e2d591 commit 0b8d26f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions lib/postoffice/adapters/pubsub.ex
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ defmodule Postoffice.Adapters.Pubsub do
@impl true
def publish(endpoint, message) do
Logger.info("Publishing PubSub message to #{endpoint}")
%{payload: payload, attributes: _attributes} = message
%{payload: payload, attributes: attributes} = message
# Authenticate
{:ok, token} = Goth.Token.for_scope("https://www.googleapis.com/auth/cloud-platform")
Logger.info("successfully generated token for pubsub")
Expand All @@ -16,7 +16,8 @@ defmodule Postoffice.Adapters.Pubsub do
request = %GoogleApi.PubSub.V1.Model.PublishRequest{
messages: [
%GoogleApi.PubSub.V1.Model.PubsubMessage{
data: Base.encode64(Poison.encode!(payload))
data: Base.encode64(Poison.encode!(payload)),
attributes: attributes
}
]
}
Expand Down
4 changes: 2 additions & 2 deletions test/postoffice/handlers/pubsub_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ defmodule Postoffice.Handlers.PubsubTest do
alias Postoffice.Messaging.Message

@valid_message_attrs %{
attributes: %{},
payload: %{},
attributes: %{"attr" => "some_value"},
payload: %{"key" => "value"},
public_id: "7488a646-e31f-11e4-aace-600308960662"
}
@valid_publisher_attrs %{
Expand Down

0 comments on commit 0b8d26f

Please sign in to comment.