Skip to content

Can't get local simulated events unmarshalled correctly after following the latest docs #85

@ferparra

Description

@ferparra

Hi everyone,

I've been trying to mock a pub/sub event on my local dev according to the docs at https://github.com/GoogleCloudPlatform/functions-framework-nodejs/tree/master/docs#local-testing-of-cloud-events. Nothing special, I'm just trying to manipulate the data object passed as a parameter to the function (which I assume should be unmarshalled, given that I'm starting the server with --signature-type=event).

Function code:
exports.helloPubSub = (data, context) => console.log(data);

Mock Json:

{
  "message": {
    "attributes": {
      "key": "value"
    },
    "data": "SGVsbG8gQ2xvdWQgUHViL1N1YiEgSGVyZSBpcyBteSBtZXNzYWdlIQ==",
    "messageId": "136969346945"
  },
  "subscription": "projects/myproject/subscriptions/mysubscription"
}

Output

{
  '{  "message": {    "attributes": {      "key": "value"    },    "data": "SGVsbG8gQ2xvdWQgUHViL1N1YiEgSGVyZSBpcyBteSBtZXNzYWdlIQ': '=",    "messageId": "136969346945"  },  "subscription": "projects/myproject/subscriptions/mysubscription"}'

All of the above is pretty standard. However, I can't get to parse the resulting object in any meaningful way.

Would you be able to shed some light on this issue?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions