diff --git a/src/TaskManager/Plug-ins/Argo/ArgoClient.cs b/src/TaskManager/Plug-ins/Argo/ArgoClient.cs index 30f9f5fb8..b802a9134 100755 --- a/src/TaskManager/Plug-ins/Argo/ArgoClient.cs +++ b/src/TaskManager/Plug-ins/Argo/ArgoClient.cs @@ -143,13 +143,17 @@ public async Task Argo_GetWorkflowTemplateAsync(string argoNam public virtual async Task Argo_CreateWorkflowTemplateAsync(string argoNamespace, WorkflowTemplateCreateRequest body, CancellationToken cancellationToken) { Guard.Against.NullOrWhiteSpace(argoNamespace); - Guard.Against.Null(body); + Guard.Against.Null(body.Template); var urlBuilder = new StringBuilder(); urlBuilder.Append(CultureInfo.InvariantCulture, $"{FormattedBaseUrl}/api/v1/workflow-templates/{argoNamespace}"); var method = "POST"; - var content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(body)); + var stringBody = Newtonsoft.Json.JsonConvert.SerializeObject(body); + var content = new StringContent(stringBody); + + var _logger = NLog.LogManager.GetCurrentClassLogger(); + _logger.Debug($"Sending content to Argo :{stringBody}"); return await SendRequest(content, urlBuilder, method, cancellationToken).ConfigureAwait(false); } diff --git a/src/TaskManager/Plug-ins/Argo/Controllers/TemplateController.cs b/src/TaskManager/Plug-ins/Argo/Controllers/TemplateController.cs index 8d121ffa7..92cf17a11 100644 --- a/src/TaskManager/Plug-ins/Argo/Controllers/TemplateController.cs +++ b/src/TaskManager/Plug-ins/Argo/Controllers/TemplateController.cs @@ -16,6 +16,7 @@ using System.Text; using Argo; using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; @@ -72,6 +73,8 @@ public async Task> CreateArgoTemplate() } [Route("{name}")] + [ProducesResponseType(StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status500InternalServerError)] [HttpDelete] public async Task> DeleteArgoTemplate(string name) { @@ -82,7 +85,12 @@ public async Task> DeleteArgoTemplate(string name) try { - return Ok(await _argoPlugin.DeleteArgoTemplate(name)); + var result = await _argoPlugin.DeleteArgoTemplate(name); + if (result is true) + { + return Ok(); + } + return StatusCode(StatusCodes.Status500InternalServerError); } catch (Exception) { diff --git a/tests/UnitTests/TaskManager.Argo.Tests/ArgoClientTest.cs b/tests/UnitTests/TaskManager.Argo.Tests/ArgoClientTest.cs index 4d9716573..b06b3a47c 100644 --- a/tests/UnitTests/TaskManager.Argo.Tests/ArgoClientTest.cs +++ b/tests/UnitTests/TaskManager.Argo.Tests/ArgoClientTest.cs @@ -224,7 +224,7 @@ public async Task Argo_CreateWorkflowTemplateAsync() ArgoClient argoClient = new(httpclient); var result = await argoClient.Argo_CreateWorkflowTemplateAsync("argo", - new WorkflowTemplateCreateRequest { Namespace = "argo" }, + new WorkflowTemplateCreateRequest { Namespace = "argo", Template = new WorkflowTemplate() }, CancellationToken.None); Assert.NotNull(result); diff --git a/tests/UnitTests/TaskManager.Argo.Tests/Controller/TemplateControllerTests.cs b/tests/UnitTests/TaskManager.Argo.Tests/Controller/TemplateControllerTests.cs index 3637d068b..80be66426 100644 --- a/tests/UnitTests/TaskManager.Argo.Tests/Controller/TemplateControllerTests.cs +++ b/tests/UnitTests/TaskManager.Argo.Tests/Controller/TemplateControllerTests.cs @@ -145,10 +145,11 @@ public async Task DeleteArgoTemplate_Controller_ReturnsOk() _argoLogger.Object, Options); + ArgoClient.Setup(a => a.Argo_DeleteWorkflowTemplateAsync(It.IsAny(), It.IsAny(), It.IsAny())).Returns(Task.FromResult(true)); + var result = await TemplateController.DeleteArgoTemplate("template"); - Assert.IsType>(result); - var okResult = Assert.IsType(result.Result); + var okResult = Assert.IsType(result.Result); Assert.Equal((int)HttpStatusCode.OK, okResult.StatusCode); }