Skip to content

Commit

Permalink
Update autorest.csharp to 3.0.0-beta.20221012.1 (Azure#31770)
Browse files Browse the repository at this point in the history
* Update autorest.csharp to 3.0.0-beta.20221012.1

* Remove workarounds for Question Answering

Now that we're fixing Azure/autorest.csharp#2726 I can remove the workarounds. Also, some tests were only recorded because we have never sent the `Accept` request header in LROs, which the explicit method calls generated on the client did. That's tracked in Azure/autorest.csharp#2765

Co-authored-by: Heath Stewart <heaths@microsoft.com>
  • Loading branch information
2 people authored and sofiar-msft committed Dec 7, 2022
1 parent 93ea366 commit 403c878
Show file tree
Hide file tree
Showing 11 changed files with 757 additions and 1,169 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,11 @@ public async Task DeployProject()
Operation<AsyncPageable<BinaryData>> updateSourcesOperation = await Client.UpdateSourcesAsync(WaitUntil.Completed, testProjectName, updateSourcesRequestContent);

string testDeploymentName = "production";
Operation<BinaryData> deploymentOperation = await Client.DeployProjectAsync(WaitUntil.Started, testProjectName, testDeploymentName);

await deploymentOperation.WaitForCompletionAsync();
AsyncPageable<BinaryData> deployments = Client.GetDeploymentsAsync(testProjectName);
Operation<BinaryData> deploymentOperation = await Client.DeployProjectAsync(WaitUntil.Completed, testProjectName, testDeploymentName);
BinaryData deployment = deploymentOperation.Value;

Assert.True(deploymentOperation.HasCompleted);
Assert.That((await deployments.ToEnumerableAsync()).Any(deployment => deployment.ToString().Contains(testDeploymentName)));
Assert.That(deployment.ToString(), Contains.Substring(testDeploymentName));
}

[RecordedTest]
Expand Down Expand Up @@ -114,12 +112,7 @@ public async Task UpdateQnAs()
});

Operation<AsyncPageable<BinaryData>> updateQnasOperation = await Client.UpdateQnasAsync(WaitUntil.Completed, testProjectName, updateQnasRequestContent);

// BUGBUG: This gets the job state.
// AsyncPageable<BinaryData> sources = updateQnasOperation.Value;

// This works, but is not the intended use case.
AsyncPageable<BinaryData> sources = Client.GetQnasAsync(testProjectName);
AsyncPageable<BinaryData> sources = updateQnasOperation.Value;

Assert.True(updateQnasOperation.HasCompleted);
Assert.AreEqual(200, updateQnasOperation.GetRawResponse().Status);
Expand Down Expand Up @@ -152,12 +145,7 @@ public async Task UpdateSources()
});

Operation<AsyncPageable<BinaryData>> updateSourcesOperation = await Client.UpdateSourcesAsync(WaitUntil.Completed, testProjectName, updateSourcesRequestContent);

// BUGBUG: This gets the job state.
// AsyncPageable<BinaryData> sources = updateSourcesOperation.Value;

// This works, but is not the intended use case.
AsyncPageable<BinaryData> sources = Client.GetSourcesAsync(testProjectName);
AsyncPageable<BinaryData> sources = updateSourcesOperation.Value;

Assert.True(updateSourcesOperation.HasCompleted);
Assert.AreEqual(200, updateSourcesOperation.GetRawResponse().Status);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,8 @@ public void CreateAndDeploy()

Operation<Pageable<BinaryData>> updateSourcesOperation = client.UpdateSources(WaitUntil.Completed, newProjectName, updateSourcesRequestContent);

#if SNIPPET
// Knowledge Sources can be retrieved as follows
Pageable<BinaryData> sources = updateSourcesOperation.Value;
#else
// TODO: Remove this condition once https://github.com/Azure/autorest.csharp/issues/2726 is fixed.
Pageable<BinaryData> sources = client.GetSources(newProjectName);
#endif

Console.WriteLine("Sources: ");
foreach (BinaryData source in sources)
Expand Down Expand Up @@ -186,13 +181,8 @@ public async Task CreateAndDeployAsync()

Operation<AsyncPageable<BinaryData>> updateSourcesOperation = await client.UpdateSourcesAsync(WaitUntil.Completed, newProjectName, updateSourcesRequestContent);

#if SNIPPET
// Knowledge Sources can be retrieved as follows
AsyncPageable<BinaryData> sources = updateSourcesOperation.Value;
#else
// TODO: Remove this condition once https://github.com/Azure/autorest.csharp/issues/2726 is fixed.
AsyncPageable<BinaryData> sources = client.GetSourcesAsync(newProjectName);
#endif

Console.WriteLine("Sources: ");
await foreach (BinaryData source in sources)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,8 @@ public void KnowledgeSources()

Operation<Pageable<BinaryData>> updateSourcesOperation = client.UpdateSources(WaitUntil.Completed, testProjectName, updateSourcesRequestContent);

#if SNIPPET
// Updated Knowledge Sources can be retrieved as follows
Pageable<BinaryData> sources = updateSourcesOperation.Value;
#else
// TODO: Remove this condition once https://github.com/Azure/autorest.csharp/issues/2726 is fixed.
Pageable<BinaryData> sources = client.GetSources(testProjectName);
#endif

Console.WriteLine("Sources: ");
foreach (BinaryData source in sources)
Expand Down Expand Up @@ -89,13 +84,8 @@ public void KnowledgeSources()

Operation<Pageable<BinaryData>> updateQnasOperation = Client.UpdateQnas(WaitUntil.Completed, testProjectName, updateQnasRequestContent);

#if SNIPPET
// QnAs can be retrieved as follows
Pageable<BinaryData> qnas = updateQnasOperation.Value;
#else
// TODO: Remove this condition once https://github.com/Azure/autorest.csharp/issues/2726 is fixed.
Pageable<BinaryData> qnas = client.GetQnas(testProjectName);
#endif

Console.WriteLine("Qnas: ");
foreach (var qna in qnas)
Expand Down Expand Up @@ -201,13 +191,8 @@ public async Task KnowledgeSourcesAsync()

Operation<AsyncPageable<BinaryData>> updateSourcesOperation = await client.UpdateSourcesAsync(WaitUntil.Completed, testProjectName, updateSourcesRequestContent);

#if SNIPPET
// Updated Knowledge Sources can be retrieved as follows
AsyncPageable<BinaryData> sources = updateSourcesOperation.Value;
#else
// TODO: Remove this condition once https://github.com/Azure/autorest.csharp/issues/2726 is fixed.
AsyncPageable<BinaryData> sources = client.GetSourcesAsync(testProjectName);
#endif

Console.WriteLine("Sources: ");
await foreach (BinaryData source in sources)
Expand Down Expand Up @@ -243,13 +228,8 @@ public async Task KnowledgeSourcesAsync()

Operation<AsyncPageable<BinaryData>> updateQnasOperation = await Client.UpdateQnasAsync(WaitUntil.Completed, testProjectName, updateQnasRequestContent);

#if SNIPPET
// QnAs can be retrieved as follows
AsyncPageable<BinaryData> qnas = updateQnasOperation.Value;
#else
// TODO: Remove this condition once https://github.com/Azure/autorest.csharp/issues/2726 is fixed.
AsyncPageable<BinaryData> qnas = client.GetQnasAsync(testProjectName);
#endif

Console.WriteLine("Qnas: ");
await foreach (var qna in qnas)
Expand Down
Loading

0 comments on commit 403c878

Please sign in to comment.