private IEnumerable <string> DoCloseBugs(RhinoTestCase testCase, string status, string resolution, IEnumerable <string> labels, IEnumerable <string> bugs) { // close bugs var closedBugs = new List <string>(); foreach (var bug in bugs) { var isClosed = testCase.CloseBug(bugIssueKey: bug, status, resolution, labels, client); // logs if (isClosed) { closedBugs.Add($"{Utilities.GetUrl(client.Authentication.Collection)}/browse/{bug}"); continue; } logger?.Info($"Close-Bug -Bug [{bug}] -Test [{testCase.Key}] = false"); } // context if (!testCase.Context.ContainsKey(ContextEntry.BugClosed) || !(testCase.Context[ContextEntry.BugClosed] is IEnumerable <string>)) { testCase.Context[ContextEntry.BugClosed] = new List <string>(); } var onBugsClosed = (testCase.Context[ContextEntry.BugClosed] as IEnumerable <string>).ToList(); onBugsClosed.AddRange(closedBugs); testCase.Context[ContextEntry.BugClosed] = onBugsClosed; // get return(onBugsClosed); }
private string DoCreateBug(RhinoTestCase testCase) { // get bug response var response = testCase.CreateBug(client); // results return(response == default ? "-1" : $"{Utilities.GetUrl(client.Authentication.Collection)}/browse/{response["key"]}"); }
/// <summary> /// Updates an existing bug (partial updates are supported, i.e. you can submit and update specific fields only). /// </summary> /// <param name="testCase">Rhino.Api.Contracts.AutomationProvider.RhinoTestCase by which to update automation provider bug.</param> public string OnUpdateBug(RhinoTestCase testCase, string status, string resolution) { // get existing bugs var isBugs = testCase.Context.ContainsKey("bugs") && testCase.Context["bugs"] != default; var bugs = isBugs ? (IEnumerable <string>)testCase.Context["bugs"] : Array.Empty <string>(); // exit conditions if (bugs.All(i => string.IsNullOrEmpty(i))) { return("-1"); } // possible duplicates if (bugs.Count() > 1) { var issues = client.Get(idsOrKeys: bugs).Where(i => testCase.IsBugMatch(bug: i, assertDataSource: true)); var onBugs = issues .OrderBy(i => $"{i["key"]}") .Skip(1) .Select(i => $"{i.SelectToken("key")}") .Where(i => !string.IsNullOrEmpty(i)); var labels = new[] { "Duplicate" }; DoCloseBugs(testCase, status, resolution: !string.IsNullOrEmpty(resolution) ? "Duplicate" : string.Empty, labels, bugs: onBugs); } // update bugs = client .Get(idsOrKeys: bugs) .Select(i => i.AsJObject()) .Where(i => testCase.IsBugMatch(bug: i, assertDataSource: false)) .Select(i => $"{i.SelectToken("key")}") .Where(i => !string.IsNullOrEmpty(i)); testCase.UpdateBug(idOrKey: bugs.FirstOrDefault(), client); // get return($"{Utilities.GetUrl(client.Authentication.Collection)}/browse/{bugs.FirstOrDefault()}"); }