[Service Bus] Fix linting problems in test files (#13892)
This PR fixes about 150 linter errors and warnings in the test files of the Service Bus package. Use `Hide whitespace changes" option to look at the real impacting changes Related to #10781
This commit is contained in:
Родитель
8c5b07d2ce
Коммит
f3e0f2c48a
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -31,7 +31,7 @@ describe("Operation Options", () => {
|
|||
// This describe block ensures that abort signal works as expected and
|
||||
// the OperationOptions are plugged in for all the methods
|
||||
describe("Abort Signal", () => {
|
||||
async function verifyAbortError(func: Function): Promise<void> {
|
||||
async function verifyAbortError(func: () => Promise<any>): Promise<void> {
|
||||
try {
|
||||
await func();
|
||||
assert.fail();
|
||||
|
|
|
@ -81,7 +81,7 @@ describe("Message Lock Renewal", () => {
|
|||
await checkWithTimeout(
|
||||
async () => {
|
||||
[peekedMsg] = await receiver.peekMessages(1);
|
||||
return peekedMsg != undefined;
|
||||
return peekedMsg !== undefined;
|
||||
},
|
||||
100,
|
||||
5000
|
||||
|
|
|
@ -57,7 +57,7 @@ describe("Retries - ManagementClient", () => {
|
|||
}
|
||||
|
||||
function mockManagementClientToThrowError(): void {
|
||||
const fakeFunction = async function() {
|
||||
const fakeFunction = async function(): Promise<never> {
|
||||
numberOfTimesManagementClientInvoked++;
|
||||
throw new MessagingError("Hello there, I'm an error");
|
||||
};
|
||||
|
@ -72,7 +72,7 @@ describe("Retries - ManagementClient", () => {
|
|||
receiverMgmtClient["_makeManagementRequest"] = fakeFunction;
|
||||
}
|
||||
|
||||
async function mockManagementClientAndVerifyRetries(func: Function): Promise<void> {
|
||||
async function mockManagementClientAndVerifyRetries(func: () => Promise<void>): Promise<void> {
|
||||
mockManagementClientToThrowError();
|
||||
let errorThrown = false;
|
||||
try {
|
||||
|
@ -235,7 +235,7 @@ describe("Retries - MessageSender", () => {
|
|||
(sender as ServiceBusSenderImpl)["_sender"]["open"] = fakeFunction;
|
||||
}
|
||||
|
||||
async function mockInitAndVerifyRetries(func: Function): Promise<void> {
|
||||
async function mockInitAndVerifyRetries(func: () => Promise<void>): Promise<void> {
|
||||
mockInitToThrowError();
|
||||
let errorThrown = false;
|
||||
try {
|
||||
|
@ -338,7 +338,7 @@ describe("Retries - Receive methods", () => {
|
|||
}
|
||||
|
||||
function mockBatchingReceiveToThrowError(): void {
|
||||
const fakeFunction = async function() {
|
||||
const fakeFunction = async function(): Promise<never> {
|
||||
numberOfTimesTried++;
|
||||
throw new MessagingError("Hello there, I'm an error");
|
||||
};
|
||||
|
@ -362,7 +362,7 @@ describe("Retries - Receive methods", () => {
|
|||
}
|
||||
}
|
||||
|
||||
async function mockReceiveAndVerifyRetries(func: Function): Promise<void> {
|
||||
async function mockReceiveAndVerifyRetries(func: () => Promise<void>): Promise<void> {
|
||||
mockBatchingReceiveToThrowError();
|
||||
let errorThrown = false;
|
||||
try {
|
||||
|
|
|
@ -588,7 +588,9 @@ describe("ServiceBusClient live tests", () => {
|
|||
let errorReceiveStream: string = "";
|
||||
try {
|
||||
receiver.subscribe({
|
||||
async processMessage() {},
|
||||
async processMessage() {
|
||||
/** Nothing to do here */
|
||||
},
|
||||
async processError(e) {
|
||||
console.log(e);
|
||||
}
|
||||
|
@ -837,7 +839,7 @@ describe("ServiceBusClient live tests", () => {
|
|||
});
|
||||
});
|
||||
|
||||
function reduceRetries(receiver: ServiceBusReceiver) {
|
||||
function reduceRetries(receiver: ServiceBusReceiver): void {
|
||||
// for some tests the important thing is just to run a single retry cycle (and then report)
|
||||
// the error. This reduces everything so we run a short retry cycle.
|
||||
//
|
||||
|
|
|
@ -167,7 +167,7 @@ describe("Streaming Receiver Tests", () => {
|
|||
body: "can stop and start a subscription message 1"
|
||||
});
|
||||
|
||||
const { subscription, msg: receivedMsg } = await new Promise<{
|
||||
const { subscription: subscription1, msg: receivedMsg } = await new Promise<{
|
||||
subscription: { close(): Promise<void> };
|
||||
msg: string;
|
||||
}>((resolve, reject) => {
|
||||
|
@ -182,7 +182,7 @@ describe("Streaming Receiver Tests", () => {
|
|||
});
|
||||
|
||||
receivedMsg.should.equal("can stop and start a subscription message 1");
|
||||
await subscription.close();
|
||||
await subscription1.close();
|
||||
|
||||
await sender2.sendMessages({
|
||||
body: "can stop and start a subscription message 2"
|
||||
|
@ -982,7 +982,7 @@ export function createOnDetachedProcessErrorFake(): sinon.SinonSpy & {
|
|||
assertErrors: () => void;
|
||||
};
|
||||
|
||||
const assertErrors = () => {
|
||||
const assertErrors = (): void => {
|
||||
const errors: string[] = [];
|
||||
|
||||
for (const callArgs of processErrorFake.args) {
|
||||
|
|
|
@ -172,7 +172,6 @@ describe("Streaming with sessions", () => {
|
|||
"MessageId is different than expected"
|
||||
);
|
||||
return Promise.resolve();
|
||||
``;
|
||||
},
|
||||
processError
|
||||
});
|
||||
|
@ -295,12 +294,11 @@ describe("Streaming with sessions", () => {
|
|||
receiver.subscribe(
|
||||
{
|
||||
async processMessage(msg: ServiceBusReceivedMessage) {
|
||||
return receiver.abandonMessage(msg).then(() => {
|
||||
return receiver.abandonMessage(msg).then(async () => {
|
||||
abandonFlag = 1;
|
||||
if ((receiver as ServiceBusSessionReceiverImpl)["_isReceivingMessages"]()) {
|
||||
return receiver.close();
|
||||
}
|
||||
return Promise.resolve();
|
||||
});
|
||||
},
|
||||
processError
|
||||
|
|
|
@ -205,7 +205,9 @@ describe("AbortSignal", () => {
|
|||
|
||||
const sender = new MessageSender(
|
||||
createConnectionContextForTests({
|
||||
onCreateAwaitableSenderCalled: () => {}
|
||||
onCreateAwaitableSenderCalled: () => {
|
||||
/** Nothing to do here */
|
||||
}
|
||||
}),
|
||||
"fakeEntityPath",
|
||||
{}
|
||||
|
@ -242,7 +244,9 @@ describe("AbortSignal", () => {
|
|||
);
|
||||
closeables.push(sender);
|
||||
|
||||
sender["_negotiateClaim"] = async () => {};
|
||||
sender["_negotiateClaim"] = async () => {
|
||||
/** Nothing to do here */
|
||||
};
|
||||
|
||||
try {
|
||||
await sender.createBatch({ abortSignal: taggedAbortSignal });
|
||||
|
@ -316,7 +320,9 @@ describe("AbortSignal", () => {
|
|||
const messageReceiver = new StreamingReceiver(fakeContext, "fakeEntityPath", defaultOptions);
|
||||
closeables.push(messageReceiver);
|
||||
|
||||
messageReceiver["_negotiateClaim"] = async () => {};
|
||||
messageReceiver["_negotiateClaim"] = async () => {
|
||||
/** Nothing to do here */
|
||||
};
|
||||
|
||||
try {
|
||||
await messageReceiver["_init"]({} as ReceiverOptions, abortSignal);
|
||||
|
@ -354,7 +360,9 @@ describe("AbortSignal", () => {
|
|||
|
||||
session.subscribe(
|
||||
{
|
||||
processMessage: async (_msg) => {},
|
||||
processMessage: async (_msg) => {
|
||||
/** Nothing to do here */
|
||||
},
|
||||
processError: async (args) => {
|
||||
receivedErrors.push(args.error);
|
||||
}
|
||||
|
@ -386,7 +394,9 @@ describe("AbortSignal", () => {
|
|||
await new Promise<void>((resolve) => {
|
||||
receiver.subscribe(
|
||||
{
|
||||
processMessage: async (_msg: any) => {},
|
||||
processMessage: async (_msg: any) => {
|
||||
/** Nothing to do here */
|
||||
},
|
||||
processError: async (args: ProcessErrorArgs) => {
|
||||
resolve();
|
||||
receivedErrors.push(args.error);
|
||||
|
|
|
@ -393,7 +393,7 @@ describe("ATOM Serializers", () => {
|
|||
}
|
||||
|
||||
class MockSerializer implements AtomXmlSerializer {
|
||||
serialize(resource: any): object {
|
||||
serialize(resource: any): Record<string, unknown> {
|
||||
const property1 = "LockDuration";
|
||||
const property2 = "MaxSizeInMegabytes";
|
||||
|
||||
|
|
|
@ -51,7 +51,9 @@ describe("autoLockRenewer unit tests", () => {
|
|||
} as ManagementClient;
|
||||
|
||||
renewLockSpy = sinon.spy(managementClient, "renewLock");
|
||||
onErrorFake = sinon.fake(async (_err: Error | MessagingError) => {});
|
||||
onErrorFake = sinon.fake(async (_err: Error | MessagingError) => {
|
||||
/** Nothing to do here */
|
||||
});
|
||||
|
||||
autoLockRenewer = LockRenewer.create(
|
||||
{
|
||||
|
|
|
@ -212,8 +212,12 @@ describe("Receiver unit tests", () => {
|
|||
|
||||
const subscription = receiverImpl.subscribe(
|
||||
{
|
||||
processError: async (_err) => {},
|
||||
processMessage: async (_msg) => {}
|
||||
processError: async (_err) => {
|
||||
/** Nothing to do here */
|
||||
},
|
||||
processMessage: async (_msg) => {
|
||||
/** Nothing to do here */
|
||||
}
|
||||
},
|
||||
{
|
||||
abortSignal
|
||||
|
@ -222,8 +226,12 @@ describe("Receiver unit tests", () => {
|
|||
|
||||
// subscription should just be auto-closed already
|
||||
const subscription2 = receiverImpl.subscribe({
|
||||
processError: async (_err) => {},
|
||||
processMessage: async (_msg) => {}
|
||||
processError: async (_err) => {
|
||||
/** Nothing to do here */
|
||||
},
|
||||
processMessage: async (_msg) => {
|
||||
/** Nothing to do here */
|
||||
}
|
||||
});
|
||||
|
||||
await subscription.close(); // and closing it "out of order" shouldn't be an issue either.
|
||||
|
@ -244,7 +252,9 @@ describe("Receiver unit tests", () => {
|
|||
processError: async (err) => {
|
||||
reject(err);
|
||||
},
|
||||
processMessage: async (_msg) => {}
|
||||
processMessage: async (_msg) => {
|
||||
/** Nothing to do here */
|
||||
}
|
||||
} as InternalMessageHandlers);
|
||||
});
|
||||
|
||||
|
@ -351,7 +361,9 @@ describe("Receiver unit tests", () => {
|
|||
initWasCalled = true;
|
||||
return;
|
||||
},
|
||||
close: async () => {},
|
||||
close: async () => {
|
||||
/** Nothing to do here */
|
||||
},
|
||||
name: "my pre-existing receiver"
|
||||
} as Pick<StreamingReceiver, "init" | "close" | "name">;
|
||||
|
||||
|
@ -367,7 +379,9 @@ describe("Receiver unit tests", () => {
|
|||
lockRenewer: undefined,
|
||||
receiveMode: "peekLock",
|
||||
abortSignal: expectedAbortSignal,
|
||||
onError: (_args) => {}
|
||||
onError: (_args) => {
|
||||
/** Nothing to do here */
|
||||
}
|
||||
});
|
||||
|
||||
assert.isTrue(initWasCalled, "initialize should be called on the original receiver");
|
||||
|
@ -386,7 +400,9 @@ describe("Receiver unit tests", () => {
|
|||
await impl["_createStreamingReceiver"]({
|
||||
lockRenewer: undefined,
|
||||
receiveMode: "peekLock",
|
||||
onError: (_args) => {}
|
||||
onError: (_args) => {
|
||||
/** Nothing to do here */
|
||||
}
|
||||
});
|
||||
|
||||
assert.exists(impl["_streamingReceiver"], "new streaming receiver should be called");
|
||||
|
|
|
@ -58,7 +58,7 @@ describe("sender unit tests", () => {
|
|||
|
||||
try {
|
||||
await sender.sendMessages(
|
||||
// @ts-expect-error
|
||||
// @ts-expect-error We are trying invalid types on purpose to test the error thrown
|
||||
invalidValue
|
||||
);
|
||||
assert.fail("You should not be seeing this.");
|
||||
|
@ -82,7 +82,7 @@ describe("sender unit tests", () => {
|
|||
|
||||
try {
|
||||
batch.tryAddMessage(
|
||||
// @ts-expect-error
|
||||
// @ts-expect-error We are trying invalid types on purpose to test the error thrown
|
||||
invalidValue
|
||||
);
|
||||
assert.fail("You should not be seeing this.");
|
||||
|
@ -106,7 +106,7 @@ describe("sender unit tests", () => {
|
|||
|
||||
try {
|
||||
await sender.scheduleMessages(
|
||||
// @ts-expect-error
|
||||
// @ts-expect-error We are trying invalid types on purpose to test the error thrown
|
||||
invalidValue,
|
||||
new Date()
|
||||
);
|
||||
|
|
|
@ -16,7 +16,7 @@ import {
|
|||
ServiceBusSessionReceiver,
|
||||
ServiceBusSessionReceiverImpl
|
||||
} from "../../../src/receivers/sessionReceiver";
|
||||
import { AbortController } from "@azure/abort-controller";
|
||||
import { AbortController, AbortSignalLike } from "@azure/abort-controller";
|
||||
const assert = chai.assert;
|
||||
|
||||
const allLockModes: ("peekLock" | "receiveAndDelete")[] = ["peekLock", "receiveAndDelete"];
|
||||
|
@ -341,7 +341,10 @@ describe("serviceBusClient unit tests", () => {
|
|||
});
|
||||
});
|
||||
});
|
||||
function createAbortSignal() {
|
||||
function createAbortSignal(): {
|
||||
signal: AbortSignalLike;
|
||||
abortedPropertyWasChecked: boolean;
|
||||
} {
|
||||
const abortSignal = new AbortController().signal;
|
||||
const result = {
|
||||
signal: abortSignal,
|
||||
|
|
|
@ -96,8 +96,12 @@ describe("StreamingReceiver unit tests", () => {
|
|||
);
|
||||
|
||||
streamingReceiver.subscribe(
|
||||
async (_msg) => {},
|
||||
async (_err) => {}
|
||||
async (_msg) => {
|
||||
/** Nothing to do here */
|
||||
},
|
||||
async (_err) => {
|
||||
/** Nothing to do here */
|
||||
}
|
||||
);
|
||||
|
||||
assert.equal(
|
||||
|
@ -133,8 +137,12 @@ describe("StreamingReceiver unit tests", () => {
|
|||
);
|
||||
|
||||
streamingReceiver.subscribe(
|
||||
async (_msg) => {},
|
||||
async (_err) => {}
|
||||
async (_msg) => {
|
||||
/** Nothing to do here */
|
||||
},
|
||||
async (_err) => {
|
||||
/** Nothing to do here */
|
||||
}
|
||||
);
|
||||
|
||||
assert.equal(
|
||||
|
@ -160,8 +168,12 @@ describe("StreamingReceiver unit tests", () => {
|
|||
defaultInitArgs.assert();
|
||||
|
||||
streamingReceiver.subscribe(
|
||||
async (_msg) => {},
|
||||
async (_err) => {}
|
||||
async (_msg) => {
|
||||
/** Nothing to do here */
|
||||
},
|
||||
async (_err) => {
|
||||
/** Nothing to do here */
|
||||
}
|
||||
);
|
||||
|
||||
assert.isTrue(streamingReceiver.isReceivingMessages);
|
||||
|
@ -186,8 +198,12 @@ describe("StreamingReceiver unit tests", () => {
|
|||
defaultInitArgs.assert();
|
||||
|
||||
streamingReceiver.subscribe(
|
||||
async (_msg) => {},
|
||||
async (_err) => {}
|
||||
async (_msg) => {
|
||||
/** Nothing to do here */
|
||||
},
|
||||
async (_err) => {
|
||||
/** Nothing to do here */
|
||||
}
|
||||
);
|
||||
|
||||
assert.isTrue(streamingReceiver.isReceivingMessages);
|
||||
|
@ -212,8 +228,12 @@ describe("StreamingReceiver unit tests", () => {
|
|||
defaultInitArgs.assert();
|
||||
|
||||
streamingReceiver.subscribe(
|
||||
async (_msg) => {},
|
||||
async (_err) => {}
|
||||
async (_msg) => {
|
||||
/** Nothing to do here */
|
||||
},
|
||||
async (_err) => {
|
||||
/** Nothing to do here */
|
||||
}
|
||||
);
|
||||
|
||||
assert.isTrue(
|
||||
|
|
|
@ -130,7 +130,9 @@ describe("Tracing tests", () => {
|
|||
throw new Error("This message failed when we tried to process it");
|
||||
}
|
||||
},
|
||||
processError: async (_err) => {}
|
||||
processError: async (_err) => {
|
||||
/** Nothing to do here */
|
||||
}
|
||||
},
|
||||
{
|
||||
tracingOptions
|
||||
|
@ -187,7 +189,9 @@ describe("Tracing tests", () => {
|
|||
throw new Error("This message failed when we tried to process it");
|
||||
}
|
||||
},
|
||||
processError: async (_err) => {}
|
||||
processError: async (_err) => {
|
||||
/** Nothing to do here */
|
||||
}
|
||||
},
|
||||
{
|
||||
tracingOptions
|
||||
|
@ -258,7 +262,11 @@ describe("Tracing tests", () => {
|
|||
});
|
||||
});
|
||||
|
||||
function stubCreateProcessingSpan(receiver: any) {
|
||||
function stubCreateProcessingSpan(
|
||||
receiverToStub: any
|
||||
): {
|
||||
span?: TestSpan;
|
||||
} {
|
||||
const data: {
|
||||
span?: TestSpan;
|
||||
} = {};
|
||||
|
@ -278,7 +286,7 @@ describe("Tracing tests", () => {
|
|||
return data.span;
|
||||
};
|
||||
|
||||
receiver["_createProcessingSpan"] = fakeCreateProcessingSpan;
|
||||
receiverToStub["_createProcessingSpan"] = fakeCreateProcessingSpan;
|
||||
return data;
|
||||
}
|
||||
|
||||
|
@ -355,17 +363,17 @@ describe("Tracing tests", () => {
|
|||
});
|
||||
|
||||
it("trace - normal", async () => {
|
||||
const tracer = new TestTracer();
|
||||
const span = tracer.startSpan("whatever");
|
||||
|
||||
await trace(async () => {}, span);
|
||||
await trace(async () => {
|
||||
/** Nothing to do here */
|
||||
}, span);
|
||||
|
||||
span.status!.code.should.equal(CanonicalCode.OK);
|
||||
span.endCalled.should.be.ok;
|
||||
});
|
||||
|
||||
it("trace - throws", async () => {
|
||||
const tracer = new TestTracer();
|
||||
const span = tracer.startSpan("whatever");
|
||||
|
||||
await trace(async () => {
|
||||
|
@ -383,10 +391,6 @@ class TestTracer2 extends TestTracer {
|
|||
public spanOptions: SpanOptions | undefined;
|
||||
public spanName: string | undefined;
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
}
|
||||
|
||||
startSpan(nameArg: string, optionsArg?: SpanOptions): TestSpan {
|
||||
this.spanName = nameArg;
|
||||
this.spanOptions = optionsArg;
|
||||
|
|
|
@ -40,7 +40,9 @@ export function createConnectionContextForTests(
|
|||
let initWasCalled = false;
|
||||
|
||||
const fakeConnectionContext = {
|
||||
async readyToOpenLink(): Promise<void> {},
|
||||
async readyToOpenLink(): Promise<void> {
|
||||
/** Nothing to do here */
|
||||
},
|
||||
isConnectionClosing(): boolean {
|
||||
return false;
|
||||
},
|
||||
|
@ -86,7 +88,9 @@ export function createConnectionContextForTests(
|
|||
(receiver as any).connection = { id: "connection-id" };
|
||||
return receiver;
|
||||
},
|
||||
async close(): Promise<void> {}
|
||||
async close(): Promise<void> {
|
||||
/** Nothing to do here */
|
||||
}
|
||||
},
|
||||
tokenCredential: {
|
||||
getToken() {
|
||||
|
@ -100,8 +104,12 @@ export function createConnectionContextForTests(
|
|||
async init() {
|
||||
initWasCalled = true;
|
||||
},
|
||||
async negotiateClaim(): Promise<void> {},
|
||||
async close(): Promise<void> {}
|
||||
async negotiateClaim(): Promise<void> {
|
||||
/** Nothing to do here */
|
||||
},
|
||||
async close(): Promise<void> {
|
||||
/** Nothing to do here */
|
||||
}
|
||||
},
|
||||
initWasCalled
|
||||
};
|
||||
|
|
|
@ -21,11 +21,11 @@ export abstract class ServiceBusTest<TOptions> extends PerfStressTest<TOptions>
|
|||
this.sbClient = sbClient;
|
||||
}
|
||||
|
||||
public async globalSetup() {
|
||||
public async globalSetup(): Promise<void> {
|
||||
await ServiceBusTest.sbAdminClient.createQueue(ServiceBusTest.queueName);
|
||||
}
|
||||
|
||||
public async globalCleanup() {
|
||||
public async globalCleanup(): Promise<void> {
|
||||
await ServiceBusTest.sbAdminClient.deleteQueue(ServiceBusTest.queueName);
|
||||
await this.sbClient.close();
|
||||
}
|
||||
|
|
|
@ -147,7 +147,7 @@ describe("Listing methods - PagedAsyncIterableIterator", function(): void {
|
|||
"listSubscriptionsRuntimeProperties",
|
||||
"listRules"
|
||||
].forEach((methodName) => {
|
||||
describe(`${methodName}`, () => {
|
||||
describe(`${methodName}`, (): void => {
|
||||
function getIter() {
|
||||
let iterator;
|
||||
if (methodName.includes("Subscription")) {
|
||||
|
@ -744,9 +744,9 @@ describe("Atom management - Authentication", function(): void {
|
|||
const name = testCase.entityType === EntityType.SUBSCRIPTION ? "subscriptionName" : "name";
|
||||
const paramsToExclude = ["createdAt", "accessedAt", "modifiedAt"];
|
||||
for (const info of response) {
|
||||
if (info[name] == testCase[1].alwaysBeExistingEntity) {
|
||||
if (info[name] === testCase[1].alwaysBeExistingEntity) {
|
||||
assert.deepEqualExcluding(info, testCase[1].output, paramsToExclude);
|
||||
} else if (info[name] == testCase[2].alwaysBeExistingEntity) {
|
||||
} else if (info[name] === testCase[2].alwaysBeExistingEntity) {
|
||||
assert.deepEqualExcluding(info, testCase[2].output, paramsToExclude);
|
||||
}
|
||||
}
|
||||
|
@ -2383,7 +2383,7 @@ describe(`updateRule() using different variations to the input parameter "ruleOp
|
|||
});
|
||||
});
|
||||
|
||||
function checkForValidErrorScenario(err: any, expectedtestOutput: any) {
|
||||
function checkForValidErrorScenario(err: any, expectedtestOutput: any): void {
|
||||
let isErrorExpected = false;
|
||||
|
||||
if (expectedtestOutput.testErrorMessage) {
|
||||
|
@ -2421,7 +2421,7 @@ async function createEntity(
|
|||
ruleOptions?: Omit<Required<CreateSubscriptionOptions>["defaultRuleOptions"], "name">
|
||||
): Promise<any> {
|
||||
if (!overrideOptions) {
|
||||
if (queueOptions == undefined) {
|
||||
if (queueOptions === undefined) {
|
||||
queueOptions = {
|
||||
lockDuration: "PT1M",
|
||||
authorizationRules: [
|
||||
|
@ -2436,19 +2436,19 @@ async function createEntity(
|
|||
};
|
||||
}
|
||||
|
||||
if (topicOptions == undefined) {
|
||||
if (topicOptions === undefined) {
|
||||
topicOptions = {
|
||||
status: "Active"
|
||||
};
|
||||
}
|
||||
|
||||
if (subscriptionOptions == undefined) {
|
||||
if (subscriptionOptions === undefined) {
|
||||
subscriptionOptions = {
|
||||
lockDuration: "PT1M"
|
||||
};
|
||||
}
|
||||
|
||||
if (ruleOptions == undefined) {
|
||||
if (ruleOptions === undefined) {
|
||||
ruleOptions = {
|
||||
filter: {
|
||||
sqlExpression: "stringValue = @stringParam AND intValue = @intParam",
|
||||
|
@ -2460,17 +2460,19 @@ async function createEntity(
|
|||
}
|
||||
|
||||
switch (testEntityType) {
|
||||
case EntityType.QUEUE:
|
||||
case EntityType.QUEUE: {
|
||||
const queueResponse = await serviceBusAtomManagementClient.createQueue(entityPath, {
|
||||
...queueOptions
|
||||
});
|
||||
return queueResponse;
|
||||
case EntityType.TOPIC:
|
||||
}
|
||||
case EntityType.TOPIC: {
|
||||
const topicResponse = await serviceBusAtomManagementClient.createTopic(entityPath, {
|
||||
...topicOptions
|
||||
});
|
||||
return topicResponse;
|
||||
case EntityType.SUBSCRIPTION:
|
||||
}
|
||||
case EntityType.SUBSCRIPTION: {
|
||||
if (!topicPath) {
|
||||
throw new Error(
|
||||
"TestError: Topic path must be passed when invoking tests on subscriptions"
|
||||
|
@ -2484,7 +2486,8 @@ async function createEntity(
|
|||
}
|
||||
);
|
||||
return subscriptionResponse;
|
||||
case EntityType.RULE:
|
||||
}
|
||||
case EntityType.RULE: {
|
||||
if (!topicPath || !subscriptionPath) {
|
||||
throw new Error(
|
||||
"TestError: Topic path AND subscription path must be passed when invoking tests on rules"
|
||||
|
@ -2498,6 +2501,7 @@ async function createEntity(
|
|||
ruleOptions?.action!
|
||||
);
|
||||
return ruleResponse;
|
||||
}
|
||||
}
|
||||
throw new Error("TestError: Unrecognized EntityType");
|
||||
}
|
||||
|
@ -2509,13 +2513,15 @@ async function getEntity(
|
|||
subscriptionPath?: string
|
||||
): Promise<any> {
|
||||
switch (testEntityType) {
|
||||
case EntityType.QUEUE:
|
||||
case EntityType.QUEUE: {
|
||||
const queueResponse = await serviceBusAtomManagementClient.getQueue(entityPath);
|
||||
return queueResponse;
|
||||
case EntityType.TOPIC:
|
||||
}
|
||||
case EntityType.TOPIC: {
|
||||
const topicResponse = await serviceBusAtomManagementClient.getTopic(entityPath);
|
||||
return topicResponse;
|
||||
case EntityType.SUBSCRIPTION:
|
||||
}
|
||||
case EntityType.SUBSCRIPTION: {
|
||||
if (!topicPath) {
|
||||
throw new Error(
|
||||
"TestError: Topic path must be passed when invoking tests on subscriptions"
|
||||
|
@ -2526,7 +2532,8 @@ async function getEntity(
|
|||
entityPath
|
||||
);
|
||||
return subscriptionResponse;
|
||||
case EntityType.RULE:
|
||||
}
|
||||
case EntityType.RULE: {
|
||||
if (!topicPath || !subscriptionPath) {
|
||||
throw new Error(
|
||||
"TestError: Topic path AND subscription path must be passed when invoking tests on rules"
|
||||
|
@ -2538,6 +2545,7 @@ async function getEntity(
|
|||
entityPath
|
||||
);
|
||||
return ruleResponse;
|
||||
}
|
||||
}
|
||||
throw new Error("TestError: Unrecognized EntityType");
|
||||
}
|
||||
|
@ -2548,17 +2556,19 @@ async function getEntityRuntimeProperties(
|
|||
topicPath?: string
|
||||
): Promise<any> {
|
||||
switch (testEntityType) {
|
||||
case EntityType.QUEUE:
|
||||
case EntityType.QUEUE: {
|
||||
const queueResponse = await serviceBusAtomManagementClient.getQueueRuntimeProperties(
|
||||
entityPath
|
||||
);
|
||||
return queueResponse;
|
||||
case EntityType.TOPIC:
|
||||
}
|
||||
case EntityType.TOPIC: {
|
||||
const topicResponse = await serviceBusAtomManagementClient.getTopicRuntimeProperties(
|
||||
entityPath
|
||||
);
|
||||
return topicResponse;
|
||||
case EntityType.SUBSCRIPTION:
|
||||
}
|
||||
case EntityType.SUBSCRIPTION: {
|
||||
if (!topicPath) {
|
||||
throw new Error(
|
||||
"TestError: Topic path must be passed when invoking tests on subscriptions"
|
||||
|
@ -2569,6 +2579,7 @@ async function getEntityRuntimeProperties(
|
|||
entityPath
|
||||
);
|
||||
return subscriptionResponse;
|
||||
}
|
||||
}
|
||||
throw new Error("TestError: Unrecognized EntityType");
|
||||
}
|
||||
|
@ -2578,13 +2589,15 @@ async function getEntitiesRuntimeProperties(
|
|||
topicPath?: string
|
||||
): Promise<any> {
|
||||
switch (testEntityType) {
|
||||
case EntityType.QUEUE:
|
||||
case EntityType.QUEUE: {
|
||||
const queueResponse = await serviceBusAtomManagementClient["getQueuesRuntimeProperties"]();
|
||||
return queueResponse;
|
||||
case EntityType.TOPIC:
|
||||
}
|
||||
case EntityType.TOPIC: {
|
||||
const topicResponse = await serviceBusAtomManagementClient["getTopicsRuntimeProperties"]();
|
||||
return topicResponse;
|
||||
case EntityType.SUBSCRIPTION:
|
||||
}
|
||||
case EntityType.SUBSCRIPTION: {
|
||||
if (!topicPath) {
|
||||
throw new Error(
|
||||
"TestError: Topic path must be passed when invoking tests on subscriptions"
|
||||
|
@ -2594,6 +2607,7 @@ async function getEntitiesRuntimeProperties(
|
|||
"getSubscriptionsRuntimeProperties"
|
||||
](topicPath);
|
||||
return subscriptionResponse;
|
||||
}
|
||||
}
|
||||
throw new Error("TestError: Unrecognized EntityType");
|
||||
}
|
||||
|
@ -2605,13 +2619,15 @@ async function entityExists(
|
|||
subscriptionPath?: string
|
||||
): Promise<any> {
|
||||
switch (testEntityType) {
|
||||
case EntityType.QUEUE:
|
||||
case EntityType.QUEUE: {
|
||||
const queueResponse = await serviceBusAtomManagementClient.queueExists(entityPath);
|
||||
return queueResponse;
|
||||
case EntityType.TOPIC:
|
||||
}
|
||||
case EntityType.TOPIC: {
|
||||
const topicResponse = await serviceBusAtomManagementClient.topicExists(entityPath);
|
||||
return topicResponse;
|
||||
case EntityType.SUBSCRIPTION:
|
||||
}
|
||||
case EntityType.SUBSCRIPTION: {
|
||||
if (!topicPath) {
|
||||
throw new Error(
|
||||
"TestError: Topic path must be passed when invoking tests on subscriptions"
|
||||
|
@ -2622,7 +2638,8 @@ async function entityExists(
|
|||
entityPath
|
||||
);
|
||||
return subscriptionResponse;
|
||||
case EntityType.RULE:
|
||||
}
|
||||
case EntityType.RULE: {
|
||||
if (!topicPath || !subscriptionPath) {
|
||||
throw new Error(
|
||||
"TestError: topic path and subscription path must be passed when invoking tests on rules"
|
||||
|
@ -2634,6 +2651,7 @@ async function entityExists(
|
|||
entityPath
|
||||
);
|
||||
return ruleResponse;
|
||||
}
|
||||
}
|
||||
throw new Error("TestError: Unrecognized EntityType");
|
||||
}
|
||||
|
@ -2650,7 +2668,7 @@ async function updateEntity(
|
|||
ruleOptions?: Omit<RuleProperties, "name">
|
||||
): Promise<any> {
|
||||
if (!overrideOptions) {
|
||||
if (queueOptions == undefined) {
|
||||
if (queueOptions === undefined) {
|
||||
queueOptions = {
|
||||
lockDuration: "PT1M",
|
||||
authorizationRules: [
|
||||
|
@ -2665,19 +2683,19 @@ async function updateEntity(
|
|||
};
|
||||
}
|
||||
|
||||
if (topicOptions == undefined) {
|
||||
if (topicOptions === undefined) {
|
||||
topicOptions = {
|
||||
status: "Active"
|
||||
};
|
||||
}
|
||||
|
||||
if (subscriptionOptions == undefined) {
|
||||
if (subscriptionOptions === undefined) {
|
||||
subscriptionOptions = {
|
||||
lockDuration: "PT1M"
|
||||
};
|
||||
}
|
||||
|
||||
if (ruleOptions == undefined) {
|
||||
if (ruleOptions === undefined) {
|
||||
ruleOptions = {
|
||||
filter: {
|
||||
sqlExpression: "stringValue = @stringParam AND intValue = @intParam",
|
||||
|
@ -2692,21 +2710,23 @@ async function updateEntity(
|
|||
}
|
||||
|
||||
switch (testEntityType) {
|
||||
case EntityType.QUEUE:
|
||||
case EntityType.QUEUE: {
|
||||
const getQueueResponse = await serviceBusAtomManagementClient.getQueue(entityPath);
|
||||
const queueResponse = await serviceBusAtomManagementClient.updateQueue({
|
||||
...getQueueResponse,
|
||||
...queueOptions
|
||||
});
|
||||
return queueResponse;
|
||||
case EntityType.TOPIC:
|
||||
}
|
||||
case EntityType.TOPIC: {
|
||||
const getTopicResponse = await serviceBusAtomManagementClient.getTopic(entityPath);
|
||||
const topicResponse = await serviceBusAtomManagementClient.updateTopic({
|
||||
...getTopicResponse,
|
||||
...topicOptions
|
||||
});
|
||||
return topicResponse;
|
||||
case EntityType.SUBSCRIPTION:
|
||||
}
|
||||
case EntityType.SUBSCRIPTION: {
|
||||
if (!topicPath) {
|
||||
throw new Error(
|
||||
"TestError: Topic path must be passed when invoking tests on subscriptions"
|
||||
|
@ -2721,7 +2741,8 @@ async function updateEntity(
|
|||
...subscriptionOptions
|
||||
});
|
||||
return subscriptionResponse;
|
||||
case EntityType.RULE:
|
||||
}
|
||||
case EntityType.RULE: {
|
||||
if (!topicPath || !subscriptionPath) {
|
||||
throw new Error(
|
||||
"TestError: Topic path AND subscription path must be passed when invoking tests on rules"
|
||||
|
@ -2741,6 +2762,7 @@ async function updateEntity(
|
|||
}
|
||||
);
|
||||
return ruleResponse;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2751,13 +2773,15 @@ async function deleteEntity(
|
|||
subscriptionPath?: string
|
||||
): Promise<any> {
|
||||
switch (testEntityType) {
|
||||
case EntityType.QUEUE:
|
||||
case EntityType.QUEUE: {
|
||||
const queueResponse = await serviceBusAtomManagementClient.deleteQueue(entityPath);
|
||||
return queueResponse;
|
||||
case EntityType.TOPIC:
|
||||
}
|
||||
case EntityType.TOPIC: {
|
||||
const topicResponse = await serviceBusAtomManagementClient.deleteTopic(entityPath);
|
||||
return topicResponse;
|
||||
case EntityType.SUBSCRIPTION:
|
||||
}
|
||||
case EntityType.SUBSCRIPTION: {
|
||||
if (!topicPath) {
|
||||
throw new Error(
|
||||
"TestError: Topic path must be passed when invoking tests on subscriptions"
|
||||
|
@ -2768,7 +2792,8 @@ async function deleteEntity(
|
|||
entityPath
|
||||
);
|
||||
return subscriptionResponse;
|
||||
case EntityType.RULE:
|
||||
}
|
||||
case EntityType.RULE: {
|
||||
if (!topicPath || !subscriptionPath) {
|
||||
throw new Error(
|
||||
"TestError: Topic path AND subscription path must be passed when invoking tests on rules"
|
||||
|
@ -2780,6 +2805,7 @@ async function deleteEntity(
|
|||
entityPath
|
||||
);
|
||||
return ruleResponse;
|
||||
}
|
||||
}
|
||||
throw new Error("TestError: Unrecognized EntityType");
|
||||
}
|
||||
|
@ -2792,19 +2818,21 @@ async function listEntities(
|
|||
maxCount?: number
|
||||
): Promise<any> {
|
||||
switch (testEntityType) {
|
||||
case EntityType.QUEUE:
|
||||
case EntityType.QUEUE: {
|
||||
const queueResponse = await serviceBusAtomManagementClient["getQueues"]({
|
||||
skip,
|
||||
maxCount
|
||||
});
|
||||
return queueResponse;
|
||||
case EntityType.TOPIC:
|
||||
}
|
||||
case EntityType.TOPIC: {
|
||||
const topicResponse = await serviceBusAtomManagementClient["getTopics"]({
|
||||
skip,
|
||||
maxCount
|
||||
});
|
||||
return topicResponse;
|
||||
case EntityType.SUBSCRIPTION:
|
||||
}
|
||||
case EntityType.SUBSCRIPTION: {
|
||||
if (!topicPath) {
|
||||
throw new Error(
|
||||
"TestError: Topic path must be passed when invoking tests on subscriptions"
|
||||
|
@ -2814,7 +2842,8 @@ async function listEntities(
|
|||
"getSubscriptions"
|
||||
](topicPath, { skip, maxCount });
|
||||
return subscriptionResponse;
|
||||
case EntityType.RULE:
|
||||
}
|
||||
case EntityType.RULE: {
|
||||
if (!topicPath || !subscriptionPath) {
|
||||
throw new Error(
|
||||
"TestError: Topic path AND subscription path must be passed when invoking tests on rules"
|
||||
|
@ -2826,6 +2855,7 @@ async function listEntities(
|
|||
{ skip, maxCount }
|
||||
);
|
||||
return ruleResponse;
|
||||
}
|
||||
}
|
||||
throw new Error("TestError: Unrecognized EntityType");
|
||||
}
|
||||
|
|
|
@ -79,7 +79,7 @@ describe("invalid parameters", () => {
|
|||
void
|
||||
> {
|
||||
try {
|
||||
// @ts-expect-error
|
||||
// @ts-expect-error We are trying invalid types on purpose to test the error thrown
|
||||
await receiver.receiveMessages(inputValue);
|
||||
chai.assert.fail("This should not have passed.");
|
||||
} catch (error) {
|
||||
|
@ -96,7 +96,7 @@ describe("invalid parameters", () => {
|
|||
void
|
||||
> {
|
||||
try {
|
||||
// @ts-expect-error
|
||||
// @ts-expect-error We are trying invalid types on purpose to test the error thrown
|
||||
await receiver.peekMessages(inputValue);
|
||||
chai.assert.fail("This should not have passed.");
|
||||
} catch (error) {
|
||||
|
@ -113,7 +113,7 @@ describe("invalid parameters", () => {
|
|||
void
|
||||
> {
|
||||
try {
|
||||
// @ts-expect-error
|
||||
// @ts-expect-error We are trying invalid types on purpose to test the error thrown
|
||||
await receiver.peekMessages(inputValue, {
|
||||
fromSequenceNumber: Long.ZERO
|
||||
});
|
||||
|
@ -224,7 +224,7 @@ describe("invalid parameters", () => {
|
|||
it("Receiver: Invalid ReceiveMode", async function(): Promise<void> {
|
||||
let errorCaught: string = "";
|
||||
try {
|
||||
// @ts-expect-error
|
||||
// @ts-expect-error We are trying invalid values on purpose to test the error thrown
|
||||
sbClient.createReceiver("dummyQueue", { receiveMode: 123 });
|
||||
} catch (error) {
|
||||
errorCaught = error.message;
|
||||
|
@ -239,7 +239,7 @@ describe("invalid parameters", () => {
|
|||
it("Receiver: Invalid SubQueue", async function(): Promise<void> {
|
||||
let errorCaught: string = "";
|
||||
try {
|
||||
// @ts-expect-error
|
||||
// @ts-expect-error We are trying invalid values on purpose to test the error thrown
|
||||
sbClient.createReceiver("dummyQueue", { subQueueType: 123 });
|
||||
} catch (error) {
|
||||
errorCaught = error.message;
|
||||
|
@ -256,7 +256,7 @@ describe("invalid parameters", () => {
|
|||
void
|
||||
> {
|
||||
try {
|
||||
// @ts-expect-error
|
||||
// @ts-expect-error We are trying invalid types on purpose to test the error thrown
|
||||
await receiver.receiveMessages(inputValue);
|
||||
chai.assert.fail("This should not have passed.");
|
||||
} catch (error) {
|
||||
|
@ -271,7 +271,7 @@ describe("invalid parameters", () => {
|
|||
invalidMessageCounts.forEach((inputValue) => {
|
||||
it(`Peek: ${inputValue} as maxMessageCount in Receiver`, async function(): Promise<void> {
|
||||
try {
|
||||
// @ts-expect-error
|
||||
// @ts-expect-error We are trying invalid types on purpose to test the error thrown
|
||||
await receiver.peekMessages(inputValue);
|
||||
chai.assert.fail("This should not have passed.");
|
||||
} catch (error) {
|
||||
|
@ -288,7 +288,7 @@ describe("invalid parameters", () => {
|
|||
void
|
||||
> {
|
||||
try {
|
||||
// @ts-expect-error
|
||||
// @ts-expect-error We are trying invalid types on purpose to test the error thrown
|
||||
await receiver.peekMessages(inputValue, {
|
||||
fromSequenceNumber: Long.ZERO
|
||||
});
|
||||
|
|
|
@ -51,7 +51,7 @@ describe("dead lettering", () => {
|
|||
|
||||
const receivedMessages = await receiver.receiveMessages(1);
|
||||
|
||||
if (receivedMessages.length == 0) {
|
||||
if (receivedMessages.length === 0) {
|
||||
throw new Error("No messages were received");
|
||||
}
|
||||
|
||||
|
@ -198,7 +198,7 @@ describe("abandoning", () => {
|
|||
|
||||
const receivedMessages = await receiver.receiveMessages(1);
|
||||
|
||||
if (receivedMessages.length == 0) {
|
||||
if (receivedMessages.length === 0) {
|
||||
throw new Error("No messages were received");
|
||||
}
|
||||
|
||||
|
@ -321,7 +321,7 @@ describe("deferring", () => {
|
|||
|
||||
const receivedMessages = await receiver.receiveMessages(1);
|
||||
|
||||
if (receivedMessages.length == 0) {
|
||||
if (receivedMessages.length === 0) {
|
||||
throw new Error("No messages were received");
|
||||
}
|
||||
|
||||
|
|
|
@ -79,7 +79,7 @@ describe("Session Lock Renewal", () => {
|
|||
testClientType + ": Batch Receiver: complete() after lock expiry with throws error",
|
||||
async function(): Promise<void> {
|
||||
await beforeEachTest(0);
|
||||
await testBatchReceiverManualLockRenewalErrorOnLockExpiry(testClientType, sender, receiver);
|
||||
await testBatchReceiverManualLockRenewalErrorOnLockExpiry(testClientType);
|
||||
}
|
||||
);
|
||||
|
||||
|
@ -87,7 +87,7 @@ describe("Session Lock Renewal", () => {
|
|||
testClientType + ": Streaming Receiver: renewLock() resets lock duration each time",
|
||||
async function(): Promise<void> {
|
||||
await beforeEachTest(0);
|
||||
await testStreamingReceiverManualLockRenewalHappyCase(sender, receiver);
|
||||
await testStreamingReceiverManualLockRenewalHappyCase();
|
||||
}
|
||||
);
|
||||
|
||||
|
@ -102,7 +102,7 @@ describe("Session Lock Renewal", () => {
|
|||
};
|
||||
|
||||
await beforeEachTest(options.maxAutoRenewLockDurationInMs);
|
||||
await testAutoLockRenewalConfigBehavior(sender, receiver, options);
|
||||
await testAutoLockRenewalConfigBehavior(options);
|
||||
}
|
||||
);
|
||||
|
||||
|
@ -116,7 +116,7 @@ describe("Session Lock Renewal", () => {
|
|||
};
|
||||
|
||||
await beforeEachTest(options.maxAutoRenewLockDurationInMs);
|
||||
await testAutoLockRenewalConfigBehavior(sender, receiver, options);
|
||||
await testAutoLockRenewalConfigBehavior(options);
|
||||
}
|
||||
);
|
||||
|
||||
|
@ -176,9 +176,7 @@ describe("Session Lock Renewal", () => {
|
|||
* Test settling of message from Batch Receiver fails after session lock expires
|
||||
*/
|
||||
async function testBatchReceiverManualLockRenewalErrorOnLockExpiry(
|
||||
entityType: TestClientType,
|
||||
sender: ServiceBusSender,
|
||||
receiver: ServiceBusSessionReceiver
|
||||
entityType: TestClientType
|
||||
): Promise<void> {
|
||||
const testMessage = getTestMessage();
|
||||
testMessage.body = `testBatchReceiverManualLockRenewalErrorOnLockExpiry-${Date.now().toString()}`;
|
||||
|
@ -215,10 +213,7 @@ describe("Session Lock Renewal", () => {
|
|||
/**
|
||||
* Test manual renewLock() using Streaming Receiver with autoLockRenewal disabled
|
||||
*/
|
||||
async function testStreamingReceiverManualLockRenewalHappyCase(
|
||||
sender: ServiceBusSender,
|
||||
receiver: ServiceBusSessionReceiver
|
||||
): Promise<void> {
|
||||
async function testStreamingReceiverManualLockRenewalHappyCase(): Promise<void> {
|
||||
let numOfMessagesReceived = 0;
|
||||
const testMessage = getTestMessage();
|
||||
testMessage.body = `testStreamingReceiverManualLockRenewalHappyCase-${Date.now().toString()}`;
|
||||
|
@ -292,8 +287,6 @@ describe("Session Lock Renewal", () => {
|
|||
}
|
||||
|
||||
async function testAutoLockRenewalConfigBehavior(
|
||||
sender: ServiceBusSender,
|
||||
receiver: ServiceBusSessionReceiver,
|
||||
options: AutoLockRenewalTestOptions
|
||||
): Promise<void> {
|
||||
let numOfMessagesReceived = 0;
|
||||
|
|
|
@ -248,7 +248,7 @@ describe("Sender Tests", () => {
|
|||
|
||||
// Wait until we are sure we have passed the schedule time
|
||||
await delay(30000);
|
||||
await testReceivedMsgsLength(receiver, 0);
|
||||
await testReceivedMsgsLength(0);
|
||||
}
|
||||
|
||||
async function testCancelMultipleScheduleMessages(): Promise<void> {
|
||||
|
@ -268,7 +268,7 @@ describe("Sender Tests", () => {
|
|||
|
||||
// Wait until we are sure we have passed the schedule time
|
||||
await delay(30000);
|
||||
await testReceivedMsgsLength(receiver, 0);
|
||||
await testReceivedMsgsLength(0);
|
||||
}
|
||||
|
||||
it(
|
||||
|
@ -320,7 +320,7 @@ describe("Sender Tests", () => {
|
|||
|
||||
function compareSequenceNumbers(sequenceNumber1: Long.Long, sequenceNumber2: Long.Long): void {
|
||||
should.equal(
|
||||
sequenceNumber1.compare(sequenceNumber2) != 0,
|
||||
sequenceNumber1.compare(sequenceNumber2) !== 0,
|
||||
true,
|
||||
"Returned sequence numbers for parallel requests are the same"
|
||||
);
|
||||
|
@ -333,7 +333,7 @@ describe("Sender Tests", () => {
|
|||
({ sequenceNumber }) => sequenceNumber?.comp(seqNum) === 0
|
||||
);
|
||||
should.equal(
|
||||
msgWithSeqNum == undefined,
|
||||
msgWithSeqNum === undefined,
|
||||
false,
|
||||
`Sequence number ${seqNum} is not found in the received messages!`
|
||||
);
|
||||
|
@ -348,10 +348,7 @@ describe("Sender Tests", () => {
|
|||
await testPeekMsgsLength(receiver, 0);
|
||||
});
|
||||
|
||||
async function testReceivedMsgsLength(
|
||||
receiver: ServiceBusReceiver,
|
||||
expectedReceivedMsgsLength: number
|
||||
): Promise<void> {
|
||||
async function testReceivedMsgsLength(expectedReceivedMsgsLength: number): Promise<void> {
|
||||
const receivedMsgs = await receiver.receiveMessages(expectedReceivedMsgsLength + 1, {
|
||||
maxWaitTimeInMs: 5000
|
||||
});
|
||||
|
|
|
@ -64,6 +64,7 @@ describe("session tests", () => {
|
|||
}
|
||||
|
||||
afterEach(async () => {
|
||||
unexpectedError = undefined;
|
||||
await serviceBusClient.test.afterEach();
|
||||
await serviceBusClient.test.after();
|
||||
});
|
||||
|
@ -73,7 +74,6 @@ describe("session tests", () => {
|
|||
void
|
||||
> {
|
||||
let expectedErrorThrown = false;
|
||||
let unexpectedError;
|
||||
try {
|
||||
await beforeEachTest();
|
||||
} catch (error) {
|
||||
|
@ -99,7 +99,6 @@ describe("session tests", () => {
|
|||
void
|
||||
> {
|
||||
let expectedErrorThrown = false;
|
||||
let unexpectedError;
|
||||
await beforeEachTest("boo");
|
||||
try {
|
||||
await serviceBusClient.test.acceptSessionWithPeekLock(
|
||||
|
|
|
@ -34,7 +34,7 @@ let envVars: any;
|
|||
* or create and return one from configured values if not existing.
|
||||
*/
|
||||
export function getEnvVars(): { [key in EnvVarNames]: string } {
|
||||
if (envVars != undefined) {
|
||||
if (envVars !== undefined) {
|
||||
return envVars;
|
||||
}
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ let client: ServiceBusAdministrationClient;
|
|||
* a new instance constructed based on the connection string configured in environment.
|
||||
*/
|
||||
function getManagementClient(): ServiceBusAdministrationClient {
|
||||
if (client == undefined) {
|
||||
if (client === undefined) {
|
||||
const env = getEnvVars();
|
||||
client = new ServiceBusAdministrationClient(env[EnvVarNames.SERVICEBUS_CONNECTION_STRING]);
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ async function retry(
|
|||
}
|
||||
|
||||
if (!succeeded) {
|
||||
if (lastKnownError != undefined) {
|
||||
if (lastKnownError !== undefined) {
|
||||
lastKnownError.message = operationDescription + " : " + lastKnownError.message;
|
||||
throw lastKnownError;
|
||||
} else {
|
||||
|
|
|
@ -125,12 +125,10 @@ async function createTestEntities(
|
|||
}
|
||||
|
||||
export async function drainAllMessages(receiver: ServiceBusReceiver): Promise<void> {
|
||||
while (true) {
|
||||
let pendingMsgs = true;
|
||||
while (pendingMsgs) {
|
||||
const messages = await receiver.receiveMessages(10, { maxWaitTimeInMs: 1000 });
|
||||
|
||||
if (messages.length === 0) {
|
||||
break;
|
||||
}
|
||||
pendingMsgs = messages.length > 0;
|
||||
}
|
||||
|
||||
await receiver.close();
|
||||
|
@ -331,7 +329,7 @@ export class ServiceBusTestHelpers {
|
|||
// session ID for your receiver.
|
||||
// if you want to get more specific use the `getPeekLockSessionReceiver` method
|
||||
// instead.
|
||||
return await this.acceptSessionWithPeekLock(entityNames, TestMessage.sessionId, options);
|
||||
return this.acceptSessionWithPeekLock(entityNames, TestMessage.sessionId, options);
|
||||
}
|
||||
|
||||
return this.addToCleanup(
|
||||
|
@ -506,19 +504,17 @@ export function createServiceBusClientForTests(
|
|||
|
||||
export async function drainReceiveAndDeleteReceiver(receiver: ServiceBusReceiver): Promise<void> {
|
||||
try {
|
||||
while (true) {
|
||||
let pendingMsgs = true;
|
||||
while (pendingMsgs) {
|
||||
const messages = await receiver.receiveMessages(10, { maxWaitTimeInMs: 1000 });
|
||||
|
||||
if (messages.length === 0) {
|
||||
break;
|
||||
}
|
||||
pendingMsgs = messages.length > 0;
|
||||
}
|
||||
} finally {
|
||||
await receiver.close();
|
||||
}
|
||||
}
|
||||
|
||||
export function getConnectionString() {
|
||||
export function getConnectionString(): string {
|
||||
if (env[EnvVarNames.SERVICEBUS_CONNECTION_STRING] == null) {
|
||||
throw new Error(
|
||||
`No service bus connection string defined in ${EnvVarNames.SERVICEBUS_CONNECTION_STRING}. If you're in a unit test you should not be depending on the deployed environment!`
|
||||
|
|
Загрузка…
Ссылка в новой задаче