Skip to content

Commit

Permalink
missing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianmroz-allegro committed Nov 7, 2022
1 parent 3bca05e commit 34cbf0a
Showing 1 changed file with 41 additions and 2 deletions.
43 changes: 41 additions & 2 deletions src/common/models/cluster/cluster.mocha.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { expect, use } from "chai";
import equivalent from "../../../client/utils/test-utils/equivalent";
import { RequestDecorator } from "../../../server/utils/request-decorator/request-decorator";
import { RetryOptions } from "../../../server/utils/retry-options/retry-options";
import { ClusterAuthJS } from "../cluster-auth/cluster-auth";
import { ClusterJS, fromConfig } from "./cluster";

use(equivalent);
Expand Down Expand Up @@ -47,7 +48,8 @@ describe("Cluster", () => {
title: "",
type: "druid",
url: "http://bazz",
version: null
version: null,
auth: undefined
});
});

Expand All @@ -67,6 +69,42 @@ describe("Cluster", () => {
expect(() => fromConfig({ name: "native", url: "http://foobar" })).to.throw("name can not be 'native'");
});

it("should read auth options", () => {
const cluster = fromConfig({
name: "foobar",
url: "http://foobar",
auth: { type: "http-basic", password: "pass", username: "foobar" }
});

expect(cluster.auth).to.be.deep.equal({
type: "http-basic", password: "pass", username: "foobar"
});
});

it("should throw on unrecognized auth type", () => {
expect(() => fromConfig({
name: "foobar",
url: "http://foobar",
auth: { type: "unknown-method" } as any as ClusterAuthJS
})).to.throw("Unrecognized authorization type: unknown-method");
});

it("should throw on missing username", () => {
expect(() => fromConfig({
name: "foobar",
url: "http://foobar",
auth: { type: "http-basic", username: undefined, password: "pass" }
})).to.throw("username field is required");
});

it("should throw on missing password", () => {
expect(() => fromConfig({
name: "foobar",
url: "http://foobar",
auth: { type: "http-basic", username: "foobar", password: undefined }
})).to.throw("password field is required");
});

it("should read retry options", () => {
const cluster = fromConfig({
name: "foobar",
Expand Down Expand Up @@ -146,7 +184,8 @@ describe("Cluster", () => {
version: "new-version",
type: "druid",
requestDecorator: null,
retry: new RetryOptions()
retry: new RetryOptions(),
auth: undefined
});
});
});
Expand Down

0 comments on commit 34cbf0a

Please sign in to comment.