From 28a84ef14dcfabe00df6a3bc10e06a356fec3181 Mon Sep 17 00:00:00 2001 From: Duncan McClean Date: Wed, 10 Jan 2024 15:44:39 +0000 Subject: [PATCH] Test meta file isn't created --- tests/Assets/AssetTest.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tests/Assets/AssetTest.php b/tests/Assets/AssetTest.php index 19209fcfb1..ef0ae17998 100644 --- a/tests/Assets/AssetTest.php +++ b/tests/Assets/AssetTest.php @@ -720,6 +720,23 @@ public function it_properly_merges_new_unsaved_data_to_meta() $this->assertEquals($expectedAfterMerge, $asset->meta()); } + /** @test */ + public function it_does_not_write_to_meta_file_when_asset_does_not_exist() + { + Storage::fake('test'); + + $container = Facades\AssetContainer::make('test')->disk('test'); + $asset = (new Asset)->container($container)->path('foo/test.txt'); + + // No meta file should exist yet... + $this->assertFalse(Storage::disk('test')->exists('foo/.meta/test.txt.yaml')); + + // Calling `meta` should return an empty meta array, but not write a meta file... + $meta = $asset->meta(); + $this->assertEquals(['data' => []], $meta); + $this->assertFalse(Storage::disk('test')->exists('foo/.meta/test.txt.yaml')); + } + /** @test */ public function it_gets_meta_path() {