Skip to content

Commit

Permalink
CT-1849 - bucket lastShareChangeDate update test
Browse files Browse the repository at this point in the history
  • Loading branch information
vojtabiberle committed Nov 26, 2024
1 parent c702a8b commit eb313ad
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions tests/Backend/CommonPart1/BucketsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,8 @@ public function testBucketOwner(string $devBranchType, string $userRole): void
$this->assertSame("Owner of Bucket in.c-{$bucketName} not found", $e->getMessage());
}

$this->assertNull($bucket['lastShareChangeDate']);

try {
$this->_testClient->updateBucketOwner($bucketId, new BucketOwnerUpdateOptions(id: 99999999));
$this->fail('Should fail.');
Expand Down Expand Up @@ -640,6 +642,51 @@ public function testBucketOwner(string $devBranchType, string $userRole): void
$bucket = $this->_testClient->getBucket($bucketId);
$this->assertEquals($ownerId, $bucket['owner']['id']);
$this->assertEquals($ownerName, $bucket['owner']['name']);
$this->assertNotNull($bucket['lastShareChangeDate']);
}

/**
* @dataProvider provideComponentsClientTypeBasedOnSuite
*/
public function testBucketDescriptionMetadata()

Check failure on line 651 in tests/Backend/CommonPart1/BucketsTest.php

View workflow job for this annotation

GitHub Actions / tests (8.1)

Method Keboola\Test\Backend\CommonPart1\BucketsTest::testBucketDescriptionMetadata() has no return type specified.

Check failure on line 651 in tests/Backend/CommonPart1/BucketsTest.php

View workflow job for this annotation

GitHub Actions / tests (8.2)

Method Keboola\Test\Backend\CommonPart1\BucketsTest::testBucketDescriptionMetadata() has no return type specified.

Check failure on line 651 in tests/Backend/CommonPart1/BucketsTest.php

View workflow job for this annotation

GitHub Actions / tests (8.3)

Method Keboola\Test\Backend\CommonPart1\BucketsTest::testBucketDescriptionMetadata() has no return type specified.
{
$this->initEvents($this->_testClient);

$bucketName = 'bucketMetadataDescriptionTesting';
$metadataProvider = 'user';
$descriptionKey = 'KBC.description';

$this->dropBucketIfExists($this->_testClient, "in.c-{$bucketName}", true);
$bucketId = $this->_testClient->createBucket($bucketName, self::STAGE_IN);

$bucket = $this->_testClient->getBucket($bucketId);
$this->assertNull($bucket['lastShareChangeDate']);

$metadataClient = new Metadata($this->_testClient);

$bucketMetadata = $metadataClient->listBucketMetadata($bucketId);
$this->assertEmpty($bucketMetadata);

$metadataClient->postBucketMetadata($bucketId, $metadataProvider, [[ 'key' => $descriptionKey, 'value' => 'Testing bucket description']]);

$eventAssertCallback = function ($events) use ($bucketId) {
$this->assertCount(1, $events);

$this->assertSame('bucket', $events[0]['objectType']);
$this->assertSame($bucketId, $events[0]['objectId']);
};

$query = new EventsQueryBuilder();
$query->setEvent('storage.bucketMetadataSet')
->setTokenId($this->tokenId)
->setObjectId($bucketId);
$this->assertEventWithRetries($this->_testClient, $eventAssertCallback, $query);

$bucketMetadata = $metadataClient->listBucketMetadata($bucketId);
$this->assertNotEmpty($bucketMetadata);

$bucket = $this->_testClient->getBucket($bucketId);
$this->assertNotNull($bucket['lastShareChangeDate']);
}

public function provideComponentsClientTypeBasedOnSuite(): array
Expand Down

0 comments on commit eb313ad

Please sign in to comment.