Skip to content

Commit

Permalink
Improve integration tests that rely on add-ons
Browse files Browse the repository at this point in the history
  • Loading branch information
RTLcoil authored Nov 9, 2020
1 parent 008d0af commit 4d0ac81
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Shared.IntegrationTests/AdminApi/UpdateResourcesTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public void TestOcrUpdate()
Assert.True(updateResult.Error.Message.StartsWith(ILLEGAL_MESSAGE));
}

[Test, IgnoreAddon("adv_ocr")]
[Test, IgnoreAddon("ocr"), RetryWithDelay]
public void TestOcrUpdateResult()
{
// should support requesting ocr info from adv_ocr addon
Expand Down
17 changes: 12 additions & 5 deletions Shared.IntegrationTests/IntegrationTestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ public class IgnoreAddonAttribute : Attribute, ITestAction

public IgnoreAddonAttribute(string name)
{
_mAddonName = name;
_mAddonName = (name ?? string.Empty).ToLower();
}

public ActionTargets Targets { get; private set; }
Expand All @@ -495,10 +495,17 @@ public void AfterTest(ITest test) { }

public void BeforeTest(ITest test)
{
var addonsToRun = Environment.GetEnvironmentVariable("CLD_TEST_ADDONS");
if (string.IsNullOrEmpty(addonsToRun) ||
!addonsToRun.Contains(_mAddonName) &&
!addonsToRun.ToLower().Equals("all"))
var environmentVariable = Environment.GetEnvironmentVariable("CLD_TEST_ADDONS");
var addonsList = (environmentVariable ?? string.Empty).ToLower()
.Split(',')
.Select(addon => addon.Trim())
.ToList();

var allTestsShouldRun = addonsList.Count == 1 && addonsList[0] == "all";
var addonNotInList = !addonsList.Contains(_mAddonName);
var noAddonsDefined = !addonsList.Any();

if (noAddonsDefined || addonNotInList && !allTestsShouldRun)
{
Assert.Ignore(
$"Please enable {_mAddonName} plugin in your account and set CLD_TEST_ADDONS environment variable");
Expand Down
2 changes: 1 addition & 1 deletion Shared.IntegrationTests/UploadApi/ExplicitMethodsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ public void TestPredominant()
Assert.NotZero(explicitResult.Predominant.Cloudinary.Length);
}

[Test, IgnoreAddon("webpurify")]
[Test, IgnoreAddon("webpurify"), RetryWithDelay]
public void TestWebPurifyForExplicitResult()
{
var explicitResult = ArrangeAndGetExplicitResult(true);
Expand Down
6 changes: 3 additions & 3 deletions Shared.IntegrationTests/UploadApi/UploadMethodsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ public void TestModerationManual()
Assert.AreEqual(ModerationStatus.Pending, getResult.Moderation[0].Status);
}

[Test, IgnoreAddon("aws_rek")]
[Test, IgnoreAddon("rekognition"), RetryWithDelay]
public void TestModerationAwsRek()
{
var uploadParams = new ImageUploadParams()
Expand All @@ -284,7 +284,7 @@ public void TestModerationAwsRek()
Assert.AreEqual(MODERATION_AWS_REK, uploadResult.Moderation[0].Kind);
}

[Test, IgnoreAddon("webpurify")]
[Test, IgnoreAddon("webpurify"), RetryWithDelay]
public void TestModerationWebpurify()
{
var uploadParams = new ImageUploadParams()
Expand All @@ -300,7 +300,7 @@ public void TestModerationWebpurify()
Assert.AreEqual(MODERATION_WEBPURIFY, uploadResult.Moderation[0].Kind);
}

[Test, IgnoreAddon("rekognition")]
[Test, IgnoreAddon("rekognition"), RetryWithDelay]
public void TestRekognitionFace()
{
// should support rekognition face
Expand Down

0 comments on commit 4d0ac81

Please sign in to comment.