-
Notifications
You must be signed in to change notification settings - Fork 205
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1725 from intuit/canary-binaries
enable canary releases for upload-assets plugin
- Loading branch information
Showing
8 changed files
with
668 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import envCi from "env-ci"; | ||
|
||
jest.mock("env-ci"); | ||
|
||
const envSpy = envCi as jest.Mock; | ||
envSpy.mockImplementation(() => ({ | ||
isCi: true, | ||
pr: 123, | ||
})); | ||
|
||
import Auto, { SEMVER } from "@auto-it/core"; | ||
import { makeHooks } from "@auto-it/core/dist/utils/make-hooks"; | ||
import path from "path"; | ||
|
||
import { dummyLog } from "@auto-it/core/dist/utils/logger"; | ||
import UploadAssets from "../src"; | ||
import endent from "endent"; | ||
|
||
const options = { | ||
owner: "test", | ||
repo: "repo", | ||
}; | ||
|
||
jest.spyOn(console, "log").mockImplementation(); | ||
|
||
describe("Upload Assets Plugin", () => { | ||
test("should add to pr body for pull requests", async () => { | ||
const plugin = new UploadAssets([ | ||
path.join(__dirname, "./test-assets/macos"), | ||
]); | ||
const hooks = makeHooks(); | ||
const uploadReleaseAsset = jest | ||
.fn() | ||
.mockImplementation(({ name }) => | ||
Promise.resolve({ | ||
data: { id: 2, name, browser_download_url: `http://${name}` }, | ||
}) | ||
); | ||
const createRelease = jest.fn().mockResolvedValue({ data: { id: 1 } }); | ||
const addToPrBody = jest.fn(); | ||
|
||
plugin.apply(({ | ||
hooks, | ||
logger: dummyLog(), | ||
git: { | ||
options, | ||
addToPrBody, | ||
github: { | ||
repos: { uploadReleaseAsset, createRelease }, | ||
paginate: jest.fn().mockResolvedValue([]), | ||
}, | ||
}, | ||
} as unknown) as Auto); | ||
|
||
await hooks.canary.promise({ | ||
canaryIdentifier: "canary.123", | ||
bump: SEMVER.patch, | ||
}); | ||
|
||
expect(addToPrBody).toHaveBeenCalledWith( | ||
endent` | ||
:baby_chick: Download canary assets: | ||
[macos-canary.123](http://macos-canary.123) | ||
`, | ||
123, | ||
"canary-assets" | ||
); | ||
}); | ||
}); |
Oops, something went wrong.