public void SuggestsLabelsForBugs() { var jiraApi = new Mock <IJiraApi>(); var bug = new JiraBug("SC-1234", "AutoBug", "OutOfMemoryException", "{\n\"MethodTypeName\": \"[RedGate.Shared.SQL]RedG", "Open", 12); jiraApi.Setup(x => x.FromId("SC-1234")).ReturnsAsync(bug); var commandParser = CommandParser.For("suggest labels for SC-1234"); var jiraBugProcessor = new JiraLabelSuggester(commandParser, jiraApi.Object); var result = jiraBugProcessor.ProcessMessage(new Message("a-channel", "a-user", "msg")); Assert.AreEqual("bugtype:oom repo:sharedsql", result.Responses.Single().Message); }
private IEnumerable <string> SuggestionsFor(JiraBug bug) { var titleSuggestions = new Dictionary <string, string> { { "OutOfMemoryException", "bugtype:oom" }, { "ErrorsOccurredDuringScriptFileParsingException", "bugtype:parsefail" }, { "NullReferenceException", "bugtype:nullref" }, { "NotImplementedException", "bugtype:notimplementedexception" }, { "AccessViolationException", "bugtype:wtf" }, { "InvalidProgramException", "bugtype:wtf" }, { "MissingMethodException", "bugtype:wtf" }, }; foreach (var suggestion in titleSuggestions) { if (bug.Title.Contains(suggestion.Key)) { yield return(suggestion.Value); } } var descriptionSuggestions = new Dictionary <string, string> { { "\"MethodTypeName\": \"[RedGate.SQLCompare.Engine]", "repo:sqlcompareengine" }, { "\"MethodTypeName\": \"[RedGate.SQLDataCompare.Engine]", "repo:sqldatacompareengine" }, { "\"MethodTypeName\": \"[RedGate.Shared.SQL]", "repo:sharedsql" }, { "\"MethodTypeName\": \"[RedGate.SQLCompare.ASTParser]", "repo:sqlcompareparser" }, { "\"MethodTypeName\": \"[RedGate.SQLToolsUI]", "repo:sqltoolsui" }, { "\"MethodTypeName\": \"[RedGate.BackupReader]", "repo:sqlbackupreader" }, { "RedGate.SQLSourceControl.Engine", "seenin:soc" }, { "ToCommitChangeSet(", "feature:soc-commit" }, { "ToRetrieveChangeSet(", "feature:soc-getlatest" }, { "CompareTable(", "bugtype:comparisonfail" }, { "BackupReader", "feature:backupreader" }, { "Failed to get an object name for id", "bugtype:objectidfail" }, }; foreach (var suggestion in descriptionSuggestions) { if (bug.Description.Contains(suggestion.Key)) { yield return(suggestion.Value); } } }
private static object GetComments(JiraBug bug) { return(bug.CommentCount + " " + (bug.CommentCount == 1 ? "comment" : "comments")); }
private static string FormatBug(JiraBug bug) { return(string.Format("<{0}|{1}> | {2} | {3} | {4} | {5}", "https://jira.red-gate.com/browse/" + bug.Id, bug.Id, bug.Type, bug.Title, bug.Status, GetComments(bug))); }