Skip to content

Commit

Permalink
Make sure all TestProjects* are deleted for QA (Azure#30322)
Browse files Browse the repository at this point in the history
Missed a couple cases in PR Azure#30276
  • Loading branch information
heaths authored Aug 4, 2022
1 parent b42e15a commit a9eaa7b
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,7 @@ protected string CreateTestProjectName()

protected void CreateProject(string projectName = default)
{
if (projectName == default)
projectName = CreateTestProjectName();

projectName ??= CreateTestProjectName();
RequestContent creationRequestContent = RequestContent.Create(
new
{
Expand All @@ -69,9 +67,7 @@ protected void CreateProject(string projectName = default)

protected async Task<Response> CreateProjectAsync(string projectName = default)
{
if (projectName == default)
projectName = CreateTestProjectName();

projectName ??= CreateTestProjectName();
RequestContent creationRequestContent = RequestContent.Create(
new
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,7 @@ public async Task SupportsAadAuthentication()

string testProjectName = CreateTestProjectName();

RequestContent creationRequestContent = RequestContent.Create(
new
{
description = "This is the description for a test project",
language = "en",
multilingualResource = false,
settings = new
{
defaultAnswer = "No answer found for your question."
}
}
);

Response createProjectResponse = await client.CreateProjectAsync(testProjectName, creationRequestContent);
Response createProjectResponse = await CreateProjectAsync(testProjectName);
Response projectDetailsResponse = await client.GetProjectDetailsAsync(testProjectName);

Assert.AreEqual(201, createProjectResponse.Status);
Expand Down Expand Up @@ -249,6 +236,7 @@ public async Task Import()
});

Operation<BinaryData> importOperation = await Client.ImportAsync(WaitUntil.Completed, testProjectName, importRequestContent, importFormat);
EnqueueProjectDeletion(testProjectName);

Response projectDetails = await Client.GetProjectDetailsAsync(testProjectName);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
using Azure.Core;
using Microsoft.Azure.CognitiveServices.Knowledge.QnAMaker;
using Microsoft.Azure.CognitiveServices.Knowledge.QnAMaker.Models;
using NUnit.Framework;

#pragma warning disable IDE0051 // Remove unused private members

namespace Azure.AI.Language.QuestionAnswering.Tests.Samples
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ public async Task CreateAndDeploy()
);

Response creationResponse = client.CreateProject(newProjectName, creationRequestContent);
#if !SNIPPET
EnqueueProjectDeletion(newProjectName);
#endif

// Projects can be retrieved as follows
Pageable<BinaryData> projects = client.GetProjects();
Expand Down Expand Up @@ -148,6 +151,9 @@ public async Task CreateAndDeployAsync()
);

Response creationResponse = await client.CreateProjectAsync(newProjectName, creationRequestContent);
#if !SNIPPET
EnqueueProjectDeletion(newProjectName);
#endif

// Projects can be retrieved as follows
AsyncPageable<BinaryData> projects = client.GetProjectsAsync();
Expand Down

0 comments on commit a9eaa7b

Please sign in to comment.