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

Ensure that quickstart examples actually work. #4398

Merged
merged 1 commit into from Nov 15, 2017
Merged

Ensure that quickstart examples actually work. #4398

merged 1 commit into from Nov 15, 2017

Conversation

tseaver
Copy link
Contributor

@tseaver tseaver commented Nov 15, 2017

Closes #4394.

@tseaver tseaver added api: pubsub Issues related to the Pub/Sub API. documentation labels Nov 15, 2017
@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Nov 15, 2017
project_id=os.getenv('GOOGLE_CLOUD_PROJECT'),
topic='MY_TOPIC_NAME', # Set this to something appropriate.
)
subscription_name = 'projects/{project_id}/subscriptions/{sub}'.format(
project_id=os.getenv('GOOGLE_CLOUD_PROJECT'),
sub='MY_SUBSCRIPTION_NAME', # Set this to something appropriate.
)
subscription = subscriber.create_subscription(topic, subscription)
subscription = subscriber.create_subscription(
name=subscription_name, topic=topic_name)

This comment was marked as spam.

@tseaver
Copy link
Contributor Author

tseaver commented Nov 15, 2017

@dhermes adding the names makes the call site more robust: back-end / generated code which changes the ordering won't break us, and when they do change the name, we get a nice, informative TypeError, instead of staring at the obscure back-end message:

(StatusCode.INVALID_ARGUMENT, Invalid resource name given (name=projects/PROJECTID/topics/TOPICNAME). Refer to https://cloud.google.com/pubsub/overview#names for more information.)

Since that string is a valid topic resource name, I stared at that for a long whilve before figuring out that the error was that topic_name and name were reversed.

@tseaver tseaver merged commit 79a782f into googleapis:master Nov 15, 2017
@tseaver tseaver deleted the 4394-pubusb-quickstart-examples branch November 15, 2017 20:57
@duggelz
Copy link

duggelz commented Nov 15, 2017

Does anyone have any experience with running code/tests inside documentation via sphinx? E.g http://www.sphinx-doc.org/en/stable/ext/doctest.html

@dhermes
Copy link
Contributor

dhermes commented Nov 15, 2017

I have lots of it! Hit me up on Hangouts?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: pubsub Issues related to the Pub/Sub API. cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants