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:
Joe Previte 2022-02-15 16:19:22 -07:00 committed by GitHub
parent e3e9f052c4
commit 94f378c196
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 9 deletions

View File

@ -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", () => {

View File

@ -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()