-
-
Notifications
You must be signed in to change notification settings - Fork 5
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
Test #26
Merged
Merged
Test #26
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
44cfe6f
fix: handle to commit change php cs fixer
tanhongit b9175d3
fix: add permission for auto commit on workflow
tanhongit 70be006
Merge branch 'main' into test
tanhongit 9746132
Merge branch 'main' into test
tanhongit 895f594
add pest test package
tanhongit 8ad4398
fix: add script to get config files on composer command
tanhongit 22f2238
update bash install and config test
tanhongit d2982b1
add tests for validate access event and notifier
tanhongit aad9017
update workflows
tanhongit File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/bin/bash | ||
|
||
echo "Setting up config files for Telegram Git Notifier..." | ||
|
||
mkdir -p storage/json/tgn | ||
|
||
json_files=( | ||
"github-events.json" | ||
"gitlab-events.json" | ||
"tgn-settings.json" | ||
) | ||
|
||
for file in "${json_files[@]}"; do | ||
if [ ! -f "storage/json/tgn/$file" ]; then | ||
cp "./config/jsons/$file" "storage/json/tgn/$file" | ||
echo "Created storage/json/tgn/$file" | ||
fi | ||
done | ||
|
||
if [[ "$(uname -s -r)" == *"Linux"* && "$(cat /etc/os-release)" == *"Ubuntu"* ]]; then | ||
chmod 777 storage/json/tgn/*.json | ||
fi | ||
|
||
echo "Telegram Git Notifier config files are ready!" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phpunit | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.4/phpunit.xsd" | ||
bootstrap="vendor/autoload.php" | ||
backupGlobals="false" | ||
colors="true" | ||
processIsolation="false" | ||
stopOnFailure="false" | ||
cacheDirectory=".phpunit.cache" | ||
backupStaticProperties="false" | ||
> | ||
<coverage> | ||
<report> | ||
<html outputDirectory="build/coverage"/> | ||
<text outputFile="build/coverage.txt"/> | ||
<clover outputFile="build/logs/clover.xml"/> | ||
</report> | ||
</coverage> | ||
<testsuites> | ||
<testsuite name="Telegram Git Notifier Test Suite"> | ||
<directory>tests</directory> | ||
</testsuite> | ||
</testsuites> | ||
<source> | ||
<include> | ||
<directory suffix=".php">src/</directory> | ||
</include> | ||
</source> | ||
</phpunit> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
|
||
use LbilTech\TelegramGitNotifier\Bot; | ||
|
||
beforeEach(function () { | ||
$this->bot = new Bot(); | ||
}); | ||
|
||
it('should return true', function () { | ||
$this->assertTrue(true); | ||
}); | ||
|
||
it('platform can be set for event with platform parameter', function () { | ||
$this->bot->setPlatFormForEvent('gitlab'); | ||
expect($this->bot->event->platform)->toBe('gitlab'); | ||
}); | ||
|
||
it('platform can be set for event with null parameter', function () { | ||
$this->bot->setPlatFormForEvent(); | ||
expect($this->bot->event->platform)->toBe('github'); | ||
}); | ||
|
||
it('platform can be set for event with platform file', function () { | ||
$this->bot->setPlatFormForEvent('gitlab', 'storage/json/tgn/gitlab-events.json'); | ||
expect($this->bot->event->platform)->toBe('gitlab'); | ||
expect($this->bot->event->getPlatformFile())->toBe('storage/json/tgn/gitlab-events.json'); | ||
}); | ||
|
||
it('can get json config for event - github', function () { | ||
$this->bot->setPlatFormForEvent(); | ||
expect($this->bot->event->getEventConfig())->toBeArray(); | ||
expect($this->bot->event->getEventConfig())->toHaveKey('issue_comment'); | ||
}); | ||
|
||
it('can get json config for event - gitlab', function () { | ||
$this->bot->setPlatFormForEvent('gitlab', 'storage/json/tgn/gitlab-events.json'); | ||
expect($this->bot->event->getEventConfig())->toBeArray(); | ||
expect($this->bot->event->getEventConfig())->toHaveKey('tag_push'); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
use LbilTech\TelegramGitNotifier\Notifier; | ||
|
||
beforeEach(function () { | ||
$this->nofitier = new Notifier(); | ||
}); | ||
|
||
it('validates that the event files exist', function () { | ||
$this->nofitier->setPlatFormForEvent('gitlab', 'storage/json/tgn/gitlab-events.json'); | ||
expect($this->nofitier->event->getEventConfig())->toBeArray(); | ||
expect($this->nofitier->event->getEventConfig())->toHaveKey('tag_push'); | ||
|
||
$this->nofitier->setPlatFormForEvent('github', 'storage/json/tgn/github-events.json'); | ||
expect($this->nofitier->event->getEventConfig())->toBeArray(); | ||
expect($this->nofitier->event->getEventConfig())->toHaveKey('issue_comment'); | ||
}); | ||
|
||
it('can parse notification chat IDs', function () { | ||
$chatThreadMapping = $this->nofitier->parseNotifyChatIds('-1201937489183;-1008168942527:46,2'); | ||
expect($chatThreadMapping)->toBeArray(); | ||
expect($chatThreadMapping)->toHaveKey('-1008168942527'); | ||
expect($chatThreadMapping['-1008168942527'])->toBeArray(); | ||
expect($chatThreadMapping['-1008168942527'])->toBe([0 => '46', 1 => '2']); | ||
}); |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?php | ||
|
||
use LbilTech\TelegramGitNotifier\Bot; | ||
use LbilTech\TelegramGitNotifier\Objects\Validator; | ||
|
||
beforeEach(function () { | ||
$this->bot = new Bot(); | ||
$this->bot->updateSetting('storage/json/tgn/setting.json'); | ||
$this->bot->setPlatFormForEvent(); | ||
$this->validator = new Validator($this->bot->setting, $this->bot->event); | ||
}); | ||
|
||
it('can validate the event that has no action to send a notification - GitHub', function () { | ||
$result = $this->validator->isAccessEvent('github', 'push', (object)[]); | ||
expect($result)->toBeTrue(); | ||
}); | ||
|
||
it('can validate the event that has an action to send a notification - GitHub', function () { | ||
$result = $this->validator->isAccessEvent('github', 'pull_request', (object)[ | ||
'action' => 'opened', | ||
]); | ||
expect($result)->toBeTrue(); | ||
}); | ||
|
||
it('can\'t validate the event that has an action but no payload to send a notification - GitHub', function () { | ||
$result = $this->validator->isAccessEvent('github', 'pull_request', (object)[]); | ||
expect($result)->toBeFalse(); | ||
}); | ||
|
||
it('can validate the event that has no action to send a notification - gitlab', function () { | ||
$this->bot->setPlatFormForEvent('gitlab'); | ||
$result = $this->validator->isAccessEvent('gitlab', 'push', (object)[]); | ||
expect($result)->toBeTrue(); | ||
}); | ||
|
||
it('can validate the event that has an action to send a notification - gitlab', function () { | ||
$this->bot->setPlatFormForEvent('gitlab'); | ||
$result = $this->validator->isAccessEvent('gitlab', 'merge_request', (object)[ | ||
'action' => 'open', | ||
]); | ||
expect($result)->toBeTrue(); | ||
}); | ||
|
||
it('can\'t validate the event that has an action but no payload to send a notification - gitlab', function () { | ||
$this->bot->setPlatFormForEvent('gitlab'); | ||
$result = $this->validator->isAccessEvent('gitlab', 'merge_request', (object)[]); | ||
expect($result)->toBeFalse(); | ||
}); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove auto-create cache in github action when using ramsey/composer-install