test: update DatabaseSchemaTest and WipeLegacySongDataTest for new schema

This commit is contained in:
Thorsten Bus 2026-05-03 22:21:49 +02:00
parent bf153b2906
commit 2a02f65517
2 changed files with 15 additions and 13 deletions

View file

@ -6,8 +6,6 @@
use App\Models\Slide;
use App\Models\Song;
use App\Models\SongArrangement;
use App\Models\SongArrangementGroup;
use App\Models\SongGroup;
use App\Models\SongSlide;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\Schema;
@ -26,13 +24,18 @@
'failed_jobs',
'services',
'songs',
'song_groups',
'labels',
'song_slides',
'song_arrangements',
'song_arrangement_groups',
'song_arrangement_labels',
'service_songs',
'slides',
'cts_sync_log',
'macros',
'macro_collections',
'macro_assignments',
'service_macro_overrides',
'service_macro_assignments',
];
foreach ($expectedTables as $table) {
@ -40,23 +43,24 @@
}
});
test('dropped tables no longer exist', function () {
expect(Schema::hasTable('song_groups'))->toBeFalse();
expect(Schema::hasTable('song_arrangement_groups'))->toBeFalse();
});
test('all factories create valid records', function () {
Service::factory()->create();
Song::factory()->create();
SongGroup::factory()->create();
SongSlide::factory()->create();
SongArrangement::factory()->create();
SongArrangementGroup::factory()->create();
ServiceSong::factory()->create();
Slide::factory()->create();
CtsSyncLog::factory()->create();
expect(Service::count())->toBeGreaterThan(0)
->and(Song::count())->toBeGreaterThan(0)
->and(SongGroup::count())->toBeGreaterThan(0)
->and(SongSlide::count())->toBeGreaterThan(0)
->and(SongArrangement::count())->toBeGreaterThan(0)
->and(SongArrangementGroup::count())->toBeGreaterThan(0)
->and(ServiceSong::count())->toBeGreaterThan(0)
->and(Slide::count())->toBeGreaterThan(0)
->and(CtsSyncLog::count())->toBeGreaterThan(0);

View file

@ -6,11 +6,9 @@
test('wipe migration is no-op on fresh database', function () {
expect(DB::table('songs')->count())->toBe(0);
expect(Schema::hasTable('songs'))->toBeTrue();
expect(Schema::hasTable('song_groups'))->toBeTrue();
expect(DB::table('song_groups')->count())->toBe(0);
expect(Schema::hasTable('song_groups'))->toBeFalse();
});
test('wipe migration guard: song_groups exists but is empty after fresh install', function () {
expect(Schema::hasTable('song_groups'))->toBeTrue();
expect(DB::table('song_groups')->count())->toBe(0);
test('wipe migration guard: song_groups does not exist after schema refactor', function () {
expect(Schema::hasTable('song_groups'))->toBeFalse();
});