Skip to content

Commit

Permalink
Sync status and frequency
Browse files Browse the repository at this point in the history
  • Loading branch information
inxilpro committed Nov 15, 2024
1 parent 7c94ace commit 196f86d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
7 changes: 6 additions & 1 deletion app/Actions/SyncGroups.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Illuminate\Console\Command;
use Illuminate\Support\Arr;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\App;
use Lorisleiva\Actions\Concerns\AsAction;
use function Laravel\Prompts\confirm;
use function Laravel\Prompts\info;
Expand All @@ -23,7 +24,9 @@ public function handle(): Collection
$groups = $this->groups()
->each(fn(Group|ExternalGroup $g) => $g->save());

SyncDomainsWithForge::run();
if (App::isProduction()) {
SyncDomainsWithForge::run();
}

return $groups;
}
Expand Down Expand Up @@ -76,6 +79,8 @@ protected function syncConfigWithGroup(string $domain, array $config): Group
'timezone',
'bsky_url',
'meetup_url',
'status',
'frequency',
]));

return $group;
Expand Down
6 changes: 4 additions & 2 deletions groups.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@
},
"phpxadl.com": {
"external": false,
"name": "PHP×Adl",
"region": null,
"name": "PHP×ADL",
"region": "Adelaide",
"description": "A Adelaide, Australia PHP meetup for web artisans who want to learn and connect.",
"timezone": "Australia/Adelaide",
"status": "active",
"frequency": "monthly",
"bsky_url": "https://bsky.app/profile/phpxadl.bsky.social"
},
"upstatephp.com": {
Expand Down
15 changes: 11 additions & 4 deletions tests/Feature/GroupsJsonTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@

namespace Tests\Feature;

use App\Models\Group;
use Exception;
use Illuminate\Foundation\Testing\RefreshDatabase;
use App\Enums\GroupStatus;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Str;
use Illuminate\Testing\Assert;
use Tests\TestCase;

Expand All @@ -30,6 +29,14 @@ protected function assertValidGroup(string $domain, array $config): void
Assert::assertNotEmpty(data_get($config, 'description'));
Assert::assertContains(data_get($config, 'timezone'), \DateTimeZone::listIdentifiers());

if ($status = data_get($config, 'status')) {
Assert::assertNotNull(GroupStatus::from($status));
}

if ($frequency = data_get($config, 'frequency')) {
Assert::assertTrue(Str::contains($frequency, ['week', 'month', 'quarter', 'year']));
}

if ($bsky_url = data_get($config, 'bsky_url')) {
Assert::assertEquals(200, Http::get($bsky_url)->status());
}
Expand All @@ -47,7 +54,7 @@ protected function assertValidDomain($value): void
Assert::assertIsString($value, "Domain must be a string.");
Assert::assertTrue(false !== filter_var($value, FILTER_VALIDATE_DOMAIN), "Domain format is invalid.");

$records = dns_get_record("{$value}.", DNS_A|DNS_AAAA);
$records = dns_get_record("{$value}.", DNS_A | DNS_AAAA);

Assert::assertIsArray($records, "There aren't DNS records for $value");
Assert::assertNotEmpty($records, "There aren't DNS records for $value");
Expand Down

0 comments on commit 196f86d

Please sign in to comment.