From 5ec695376f0514f60e4916bdbe1f6f7f84c66878 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Tue, 11 Feb 2020 15:23:27 +0100 Subject: [PATCH] Tests for querying by metadata. --- .../TestSuite.ApiTests/AssetTests.cs | 24 ++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/backend/tools/TestSuite/TestSuite.ApiTests/AssetTests.cs b/backend/tools/TestSuite/TestSuite.ApiTests/AssetTests.cs index 27101b86b..ec414e1e0 100644 --- a/backend/tools/TestSuite/TestSuite.ApiTests/AssetTests.cs +++ b/backend/tools/TestSuite/TestSuite.ApiTests/AssetTests.cs @@ -162,13 +162,31 @@ namespace TestSuite.ApiTests var asset_1 = await _.UploadFileAsync("Assets/logo-squared.png", "image/png"); - // STEP 2: Query asset - var assets = await _.Assets.GetAssetsAsync(_.AppName, new AssetQuery + // STEP 2: Query asset by pixel width. + var assets_1 = await _.Assets.GetAssetsAsync(_.AppName, new AssetQuery { Filter = "metadata/pixelWidth eq 600" }); - Assert.Contains(assets.Items, x => x.Id == asset_1.Id); + Assert.Contains(assets_1.Items, x => x.Id == asset_1.Id); + + + // STEP 3: Add custom metadata. + asset_1.Metadata["custom"] = "foo"; + + await _.Assets.PutAssetAsync(_.AppName, asset_1.Id.ToString(), new AnnotateAssetDto + { + Metadata = asset_1.Metadata + }); + + + // STEP 4: Query asset by custom metadata + var assets_2 = await _.Assets.GetAssetsAsync(_.AppName, new AssetQuery + { + Filter = "metadata/custom eq 'foo'" + }); + + Assert.Contains(assets_2.Items, x => x.Id == asset_1.Id); } } }