Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(cli): don't crash when checking for updates from integration vers…
…ion with a long name (#16227) Fixes: #9429 Fixes: #16126 Ref: https://prisma-company.slack.com/archives/C02FZENHD4N/p1668078372144739
- Loading branch information
Showing
2 changed files
with
56 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import { printUpdateMessage } from '../utils/printUpdateMessage' | ||
|
||
function printUpdateMessageFromTo(from: string, to: string): void { | ||
printUpdateMessage({ | ||
status: 'ok', | ||
data: { | ||
client_event_id: '', | ||
previous_client_event_id: '', | ||
product: '', | ||
cli_path_hash: '', | ||
local_timestamp: '', | ||
previous_version: from, | ||
current_version: to, | ||
current_release_date: Date.now(), | ||
current_download_url: '', | ||
current_changelog_url: '', | ||
package: 'prisma', | ||
release_tag: to, | ||
install_command: '', | ||
project_website: '', | ||
outdated: true, | ||
alerts: [], | ||
}, | ||
}) | ||
} | ||
|
||
const consoleErrorMock = jest.spyOn(console, 'error').mockImplementation() | ||
|
||
afterEach(() => { | ||
consoleErrorMock.mockReset() | ||
}) | ||
|
||
test('normal release', () => { | ||
printUpdateMessageFromTo('4.5.0', '4.6.0') | ||
expect(consoleErrorMock.mock.calls[0][0]).toMatchInlineSnapshot(` | ||
┌─────────────────────────────────────────────────────────┐ | ||
│ Update available 4.5.0 -> 4.6.0 │ | ||
│ Run the following to update │ | ||
│ npm i --save-dev prisma@4.6.0 │ | ||
│ npm i @prisma/client@4.6.0 │ | ||
└─────────────────────────────────────────────────────────┘ | ||
`) | ||
}) | ||
|
||
test('integration version with long name', () => { | ||
printUpdateMessageFromTo('4.5.0-integration-use-keep-alive-for-node-fetch.1', '4.6.0') | ||
expect(consoleErrorMock.mock.calls[0][0]).toMatchInlineSnapshot(` | ||
┌───────────────────────────────────────────────────────────────────────────────┐ | ||
│ Update available 4.5.0-integration-use-keep-alive-for-node-fetch.1 -> 4.6.0 │ | ||
│ Run the following to update │ | ||
│ npm i --save-dev prisma@4.6.0 │ | ||
│ npm i @prisma/client@4.6.0 │ | ||
└───────────────────────────────────────────────────────────────────────────────┘ | ||
`) | ||
}) |
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