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

feat: Allow for topics to updated via a new method #2256

Merged
merged 13 commits into from
Aug 20, 2019

Conversation

danielgsims
Copy link
Contributor

Creates the Google\Cloud\PubSub\Topic::update method, docs and tests.

Creates the Google\Cloud\PubSub\Topic::update method, docs and tests.
@danielgsims danielgsims requested a review from jdpedrie as a code owner August 19, 2019 03:31
@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Aug 19, 2019
@codecov
Copy link

codecov bot commented Aug 19, 2019

Codecov Report

❗ No coverage uploaded for pull request base (master@223560a). Click here to learn what that means.
The diff coverage is 97.29%.

Impacted file tree graph

@@           Coverage Diff            @@
##             master   #2256   +/-   ##
========================================
  Coverage          ?   92.6%           
  Complexity        ?    4467           
========================================
  Files             ?     307           
  Lines             ?   13323           
  Branches          ?       0           
========================================
  Hits              ?   12338           
  Misses            ?     985           
  Partials          ?       0
Impacted Files Coverage Δ Complexity Δ
PubSub/src/Connection/Grpc.php 87.43% <100%> (ø) 48 <2> (?)
PubSub/src/Connection/Rest.php 97.05% <100%> (ø) 28 <1> (?)
PubSub/src/Topic.php 99% <95.23%> (ø) 33 <7> (?)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 223560a...96175f9. Read the comment docs.

* the allowed regions. An empty list means that no regions are
* allowed, and is not a valid configuration. * }
* @param array $options [optional] Configuration options.
* @param array $options.updateMask A list of field paths to be modified. Nested
Copy link
Contributor

Choose a reason for hiding this comment

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

Document this in the same nested manner as $topic and its sub options.

* key names should be dot-separated, e.g. `messageStoragePolicy.allowedPersistenceRegions`.
* Google Cloud PHP will attempt to infer this value on your
* behalf, however modification of map fields with arbitrary keys
* (such as labels or push config attributes) requires an explicit
Copy link
Contributor

Choose a reason for hiding this comment

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

push config attributes are not applicable to this method. allowed persistence regions may be, though.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, I changed it to reflect the correct fields.

$topic = $topics->current();

$policy = [
'allowedPersistenceRegions' => ['us-central1', 'us-east1']
Copy link
Contributor

@jdpedrie jdpedrie Aug 19, 2019

Choose a reason for hiding this comment

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

fix spacing at start of line.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

*/
public function testUpdateTopic($client)
{
$topics = $client->topics();
Copy link
Contributor

Choose a reason for hiding this comment

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

Create a topic for the test rather than modifying an existing one. See the test immediately above for how to create a topic and enqueue it for cleanup at the end of the test run. (Same for the other system test you added)

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't mind using resources already setup by other tests. If we do that, though, it would be nice to use the @depends annotation and make sure the data pre-modification differs from the end result. In this case, it would probably be easier to just create a new resource.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated the test to add new topics.

if (!$updateMaskPaths) {
$iterator = new \RecursiveIteratorIterator(new \RecursiveArrayIterator($topic));
foreach ($iterator as $leafValue) {
$excludes = ['name', 'kmsKeyName'];
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's take kmsKeyName out of this array. If a user provides a kmsKeyName to this method, they should see the error telling them it's immutable, otherwise they may not realize that the value has not changed. It may be good to do the same for Subscription::update() w.r.t. the topic name in the near future.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I removed this, and removed the test where I confirmed filtering out immutable fields.

danielgsims and others added 4 commits August 19, 2019 10:54
*/
public function testUpdateTopic($client)
{
$topics = $client->topics();
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't mind using resources already setup by other tests. If we do that, though, it would be nice to use the @depends annotation and make sure the data pre-modification differs from the end result. In this case, it would probably be easier to just create a new resource.

Co-Authored-By: John Pedrie <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants