Skip to content

Commit

Permalink
Add tests for search resources by asset_id
Browse files Browse the repository at this point in the history
  • Loading branch information
YomesInc authored May 29, 2022
1 parent a8271a7 commit bcd049f
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions CloudinaryDotNet.IntegrationTests/SearchApi/SearchApiTest.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using CloudinaryDotNet.Actions;
Expand All @@ -13,7 +14,7 @@ class SearchApiTest : IntegrationTestBase
private string m_expressionPublicId;
private string m_singleResourcePublicId;
private string[] m_publicIdsSorted;

private Dictionary<string, string> m_assetIds = new Dictionary<string, string>();
private const int INDEXING_WAIT_TIME = 5000;

private const string SORT_FIELD = "public_id";
Expand Down Expand Up @@ -54,14 +55,25 @@ public void InitSearchTests()
uploadParams.Context = new StringDictionary { { "some key", "some value" } };
}
m_publicIdsSorted[i] = publicId;
m_cloudinary.Upload(uploadParams);
var r = m_cloudinary.Upload(uploadParams);
m_assetIds.Add(publicId, r.AssetId);
}

Array.Sort(m_publicIdsSorted);
m_expressionPublicId = $"public_id: {m_publicIdsSorted[0]}";
Thread.Sleep(INDEXING_WAIT_TIME);
}

[TestCase("asset_id=")]
[TestCase("asset_id:")]
[RetryWithDelay]
public void TestSearchByAssetId(string key)
{
var result = m_cloudinary.Search().Expression($"{key}{m_assetIds[m_singleResourcePublicId]}").Execute();
Assert.AreEqual(1, result.Resources.Count());
Assert.AreEqual(m_singleResourcePublicId, result.Resources.First().PublicId);
}

[Test, RetryWithDelay]
public void TestSearchApiFindResourcesByTag()
{
Expand Down

0 comments on commit bcd049f

Please sign in to comment.