Skip to content

Commit

Permalink
Make green
Browse files Browse the repository at this point in the history
  • Loading branch information
orta committed Dec 9, 2017
1 parent 635f054 commit 2da280d
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 12 deletions.
6 changes: 3 additions & 3 deletions source/commands/danger-pr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import * as jsome from "jsome"
import { FakeCI } from "../ci_source/providers/Fake"
import { GitHub } from "../platforms/GitHub"
import { GitHubAPI } from "../platforms/github/GitHubAPI"
import { Executor } from "../runner/Executor"
import { Executor, ExecutorOptions } from "../runner/Executor"
import { pullRequestParser } from "../platforms/github/pullRequestParser"
import { runDangerfileEnvironment } from "../runner/runners/inline"
import { dangerfilePath } from "./utils/file-utils"
Expand Down Expand Up @@ -68,12 +68,12 @@ if (program.args.length === 0) {

// Run Danger traditionally
async function runDanger(source: FakeCI, platform: GitHub, file: string) {
const config = {
const config: ExecutorOptions = {
stdoutOnly: app.textOnly,
verbose: app.verbose,
jsonOnly: false,
dangerID: "default",
}

const exec = new Executor(source, platform, inlineRunner, config)

const runtimeEnv = await exec.setupDanger()
Expand Down
5 changes: 3 additions & 2 deletions source/commands/danger-process.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as chalk from "chalk"
import * as program from "commander"

import { getPlatformForEnv } from "../platforms/platform"
import { Executor } from "../runner/Executor"
import { Executor, ExecutorOptions } from "../runner/Executor"
import runDangerSubprocess, { prepareDangerDSL } from "./utils/runDangerSubprocess"
import setSharedArgs, { SharedCLI } from "./utils/sharedDangerfileArgs"
import getRuntimeCISource from "./utils/getRuntimeCISource"
Expand Down Expand Up @@ -57,10 +57,11 @@ getRuntimeCISource(app).then(source => {
}

if (platform) {
const config = {
const config: ExecutorOptions = {
stdoutOnly: app.textOnly,
verbose: app.verbose,
jsonOnly: false,
dangerID: app.id || "default",
}

jsonDSLGenerator(platform).then(dangerJSONDSL => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ exports[`generating messages leaves space between <td>s to allow GitHub to rende
1 warning: _Maybe you meant ...
1 messages
1 markdown notices
DangerID: danger-id-example-id;
-->
<table>
Expand Down
15 changes: 8 additions & 7 deletions source/runner/templates/_tests/_githubIssueTemplates.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,51 +9,52 @@ import { template as githubResultsTemplate } from "../../templates/githubIssueTe

describe("generating messages", () => {
it("shows no tables for empty results", () => {
const issues = githubResultsTemplate(emptyResults)
const issues = githubResultsTemplate("blankID", emptyResults)
expect(issues).not.toContain("Fails")
expect(issues).not.toContain("Warnings")
expect(issues).not.toContain("Messages")
})

it("shows no tables for results without messages", () => {
const issues = githubResultsTemplate(failsResultsWithoutMessages)
const issues = githubResultsTemplate("blankID", failsResultsWithoutMessages)
expect(issues).not.toContain("Fails")
expect(issues).not.toContain("Warnings")
expect(issues).not.toContain("Messages")
})

it("Shows the failing messages in a table", () => {
const issues = githubResultsTemplate(failsResults)
const issues = githubResultsTemplate("blankID", failsResults)
expect(issues).toContain("Fails")
expect(issues).not.toContain("Warnings")
})

it("Shows the warning messages in a table", () => {
const issues = githubResultsTemplate(warnResults)
const issues = githubResultsTemplate("blankID", warnResults)
expect(issues).toContain("Warnings")
expect(issues).not.toContain("Fails")
})

it("does not break commonmark rules around line breaks", () => {
const issues = githubResultsTemplate(warnResults)
const issues = githubResultsTemplate("blankID", warnResults)
expect(issues).not.toMatch(/(\r?\n){2}[ \t]+</)
})

it("Should include summary on top of message", () => {
const issues = githubResultsTemplate(summaryResults)
const issues = githubResultsTemplate("blankID", summaryResults)
const expected = `
<!--
1 failure: Failing message F...
1 warning: Warning message W...
1 messages
1 markdown notices
DangerID: danger-id-blankID;
-->`

expect(issues).toContain(expected)
})

it("leaves space between <td>s to allow GitHub to render message content as markdown", () => {
const issues = githubResultsTemplate({
const issues = githubResultsTemplate("example-id", {
fails: [{ message: "**Failure:** Something failed!" }],
warnings: [{ message: "_Maybe you meant to run `yarn install`?_" }],
messages: [{ message: "```ts\nfunction add(a: number, b: number): number {\n return a + b\n}\n```" }],
Expand Down

0 comments on commit 2da280d

Please sign in to comment.