mirror of
https://github.com/danog/code-server.git
synced 2024-11-30 04:39:46 +01:00
feat(testing): add test for parse
when error in args + config (#4866)
* chore: fmt cleanup * feat(parse): add test error w/config
This commit is contained in:
parent
e3e9f052c4
commit
94f378c196
@ -361,6 +361,16 @@ describe("parser", () => {
|
||||
"$argon2i$v=19$m=4096,t=3,p=1$0qr/o+0t00hsbjfqcksfdq$ofcm4rl6o+b7oxpua4qlxubypbbpsf+8l531u7p9hyy",
|
||||
})
|
||||
})
|
||||
it("should throw an error for invalid config values", async () => {
|
||||
const fakePath = "/fake-config-path"
|
||||
const expectedErrMsg = `error reading ${fakePath}: `
|
||||
|
||||
expect(() =>
|
||||
parse(["--foo"], {
|
||||
configFile: fakePath,
|
||||
}),
|
||||
).toThrowError(expectedErrMsg)
|
||||
})
|
||||
})
|
||||
|
||||
describe("cli", () => {
|
||||
|
@ -1,5 +1,5 @@
|
||||
import * as http from "http"
|
||||
import { logger } from "@coder/logger"
|
||||
import * as http from "http"
|
||||
import { AddressInfo } from "net"
|
||||
import * as path from "path"
|
||||
import { SettingsProvider, UpdateSettings } from "../../../src/node/settings"
|
||||
@ -218,8 +218,8 @@ describe("update", () => {
|
||||
it("should reject if response has status code 500", async () => {
|
||||
if (isAddressInfo(_address)) {
|
||||
const mockURL = `http://${_address.address}:${_address.port}/reject-status-code`
|
||||
let provider = new UpdateProvider(mockURL, settings())
|
||||
let update = await provider.getUpdate(true)
|
||||
const provider = new UpdateProvider(mockURL, settings())
|
||||
const update = await provider.getUpdate(true)
|
||||
|
||||
expect(update.version).toBe("unknown")
|
||||
expect(logger.error).toHaveBeenCalled()
|
||||
@ -233,8 +233,8 @@ describe("update", () => {
|
||||
it("should reject if no location header provided", async () => {
|
||||
if (isAddressInfo(_address)) {
|
||||
const mockURL = `http://${_address.address}:${_address.port}/no-location-header`
|
||||
let provider = new UpdateProvider(mockURL, settings())
|
||||
let update = await provider.getUpdate(true)
|
||||
const provider = new UpdateProvider(mockURL, settings())
|
||||
const update = await provider.getUpdate(true)
|
||||
|
||||
expect(update.version).toBe("unknown")
|
||||
expect(logger.error).toHaveBeenCalled()
|
||||
@ -249,8 +249,8 @@ describe("update", () => {
|
||||
version = "4.1.1"
|
||||
if (isAddressInfo(_address)) {
|
||||
const mockURL = `http://${_address.address}:${_address.port}/with-location-header`
|
||||
let provider = new UpdateProvider(mockURL, settings())
|
||||
let update = await provider.getUpdate(true)
|
||||
const provider = new UpdateProvider(mockURL, settings())
|
||||
const update = await provider.getUpdate(true)
|
||||
|
||||
expect(logger.error).not.toHaveBeenCalled()
|
||||
expect(update.version).toBe("4.1.1")
|
||||
@ -260,8 +260,8 @@ describe("update", () => {
|
||||
it("should reject if more than 10 redirects", async () => {
|
||||
if (isAddressInfo(_address)) {
|
||||
const mockURL = `http://${_address.address}:${_address.port}/redirect/11`
|
||||
let provider = new UpdateProvider(mockURL, settings())
|
||||
let update = await provider.getUpdate(true)
|
||||
const provider = new UpdateProvider(mockURL, settings())
|
||||
const update = await provider.getUpdate(true)
|
||||
|
||||
expect(update.version).toBe("unknown")
|
||||
expect(logger.error).toHaveBeenCalled()
|
||||
|
Loading…
Reference in New Issue
Block a user