Skip to content

Commit cc9b8bb

Browse files
committed
Improve gitea tests
1 parent d0ef4de commit cc9b8bb

1 file changed

Lines changed: 29 additions & 14 deletions

File tree

tests/VCS/Adapter/GiteaTest.php

Lines changed: 29 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -385,8 +385,9 @@ public function testGetCommit(): void
385385
$this->assertArrayHasKey('commitAuthorUrl', $result);
386386

387387
$this->assertSame($commitHash, $result['commitHash']);
388-
$this->assertStringContainsString($customMessage, $result['commitMessage']);
389-
$this->assertNotEmpty($result['commitAuthor']);
388+
$this->assertSame('utopia', $result['commitAuthor']);
389+
$this->assertStringStartsWith($customMessage, $result['commitMessage']);
390+
$this->assertStringContainsString('gravatar.com', $result['commitAuthorAvatar']);
390391
$this->assertNotEmpty($result['commitUrl']);
391392

392393
$this->vcsAdapter->deleteRepository(self::$owner, $repositoryName);
@@ -400,22 +401,36 @@ public function testGetLatestCommit(): void
400401
$firstMessage = 'First commit';
401402
$secondMessage = 'Second commit';
402403
$this->vcsAdapter->createFile(self::$owner, $repositoryName, 'README.md', '# Test', $firstMessage);
404+
405+
$commit1 = $this->vcsAdapter->getLatestCommit(self::$owner, $repositoryName, 'main');
406+
407+
$this->assertIsArray($commit1);
408+
$this->assertArrayHasKey('commitHash', $commit1);
409+
$this->assertArrayHasKey('commitMessage', $commit1);
410+
$this->assertArrayHasKey('commitAuthor', $commit1);
411+
$this->assertArrayHasKey('commitUrl', $commit1);
412+
$this->assertArrayHasKey('commitAuthorAvatar', $commit1);
413+
$this->assertArrayHasKey('commitAuthorUrl', $commit1);
414+
415+
$this->assertNotEmpty($commit1['commitHash']);
416+
$this->assertSame('utopia', $commit1['commitAuthor']);
417+
$this->assertStringStartsWith($firstMessage, $commit1['commitMessage']);
418+
$this->assertStringContainsString('gravatar.com', $commit1['commitAuthorAvatar']);
419+
$this->assertNotEmpty($commit1['commitUrl']);
420+
421+
$commit1Hash = $commit1['commitHash'];
422+
403423
$this->vcsAdapter->createFile(self::$owner, $repositoryName, 'test.txt', 'test content', $secondMessage);
404424

405-
$result = $this->vcsAdapter->getLatestCommit(self::$owner, $repositoryName, 'main');
425+
$commit2 = $this->vcsAdapter->getLatestCommit(self::$owner, $repositoryName, 'main');
406426

407-
$this->assertIsArray($result);
408-
$this->assertArrayHasKey('commitHash', $result);
409-
$this->assertArrayHasKey('commitMessage', $result);
410-
$this->assertArrayHasKey('commitAuthor', $result);
411-
$this->assertArrayHasKey('commitUrl', $result);
412-
$this->assertArrayHasKey('commitAuthorAvatar', $result);
413-
$this->assertArrayHasKey('commitAuthorUrl', $result);
427+
$this->assertIsArray($commit2);
428+
$this->assertNotEmpty($commit2['commitHash']);
429+
$this->assertStringStartsWith($secondMessage, $commit2['commitMessage']);
414430

415-
$this->assertNotEmpty($result['commitHash']);
416-
$this->assertStringContainsString($secondMessage, $result['commitMessage']);
417-
$this->assertNotEmpty($result['commitAuthor']);
418-
$this->assertNotEmpty($result['commitUrl']);
431+
$commit2Hash = $commit2['commitHash'];
432+
433+
$this->assertNotSame($commit1Hash, $commit2Hash);
419434

420435
$this->vcsAdapter->deleteRepository(self::$owner, $repositoryName);
421436
}

0 commit comments

Comments
 (0)