Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions src/errors/GRPCNotSupportedError.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
Copyright 2023 The Dapr Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

export class GRPCNotSupportedError extends Error {
readonly name = "GRPCNotSupportedError";
constructor() {
super("GRPC is currently not supported.");
}
}
19 changes: 19 additions & 0 deletions src/errors/HTTPNotSupportedError.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
Copyright 2023 The Dapr Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

export class HTTPNotSupportedError extends Error {
readonly name = "HTTPNotSupportedError";
constructor() {
super("HTTP is currently not supported.");
}
}
9 changes: 5 additions & 4 deletions src/implementation/Client/HTTPClient/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { GetConfigurationResponse as GetConfigurationResponseResult } from "../.
import HTTPClient from "./HTTPClient";
import { SubscribeConfigurationCallback } from "../../../types/configuration/SubscribeConfigurationCallback";
import { SubscribeConfigurationStream } from "../../../types/configuration/SubscribeConfigurationStream";
import { HTTPNotSupportedError } from "../../../errors/HTTPNotSupportedError";

export default class HTTPClientConfiguration implements IClientConfiguration {
client: HTTPClient;
Expand All @@ -26,15 +27,15 @@ export default class HTTPClientConfiguration implements IClientConfiguration {
}

async subscribe(_storeName: string, _cb: SubscribeConfigurationCallback): Promise<SubscribeConfigurationStream> {
throw new Error("HTTP is currently not supported.");
throw new HTTPNotSupportedError();
}

async subscribeWithKeys(
_storeName: string,
_keys: string[],
_cb: SubscribeConfigurationCallback,
): Promise<SubscribeConfigurationStream> {
throw new Error("HTTP is currently not supported.");
throw new HTTPNotSupportedError();
}

async subscribeWithMetadata(
Expand All @@ -43,10 +44,10 @@ export default class HTTPClientConfiguration implements IClientConfiguration {
_metadata: KeyValueType,
_cb: SubscribeConfigurationCallback,
): Promise<SubscribeConfigurationStream> {
throw new Error("HTTP is currently not supported.");
throw new HTTPNotSupportedError();
}

async get(_storeName: string, _keys: string[], _metadata?: KeyValueType): Promise<GetConfigurationResponseResult> {
throw new Error("HTTP is currently not supported.");
throw new HTTPNotSupportedError();
}
}
3 changes: 2 additions & 1 deletion src/implementation/Client/HTTPClient/proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import * as grpc from "@grpc/grpc-js";
import Class from "../../../types/Class";
import IClientProxy from "../../../interfaces/Client/IClientProxy";
import HTTPClient from "./HTTPClient";
import { HTTPNotSupportedError } from "../../../errors/HTTPNotSupportedError";

export default class HTTPClientProxy implements IClientProxy {
client: HTTPClient;
Expand All @@ -24,6 +25,6 @@ export default class HTTPClientProxy implements IClientProxy {
}

async create<T>(_cls: Class<T>, _clientOptions?: Partial<grpc.ClientOptions> | undefined): Promise<T> {
throw new Error("HTTP is currently not supported.");
throw new HTTPNotSupportedError();
}
}
9 changes: 5 additions & 4 deletions src/implementation/Server/GRPCServer/actor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import GRPCServer from "./GRPCServer";
import IServerActor from "../../../interfaces/Server/IServerActor";
import AbstractActor from "../../../actors/runtime/AbstractActor";
import Class from "../../../types/Class";
import { GRPCNotSupportedError } from "../../../errors/GRPCNotSupportedError";

// https://docs.dapr.io/reference/api/bindings_api/
export default class GRPCServerActor implements IServerActor {
Expand All @@ -25,18 +26,18 @@ export default class GRPCServerActor implements IServerActor {
}

deactivateActor(_actorType: string, _actorId: string): Promise<void> {
throw new Error("GRPC is currently not supported.");
throw new GRPCNotSupportedError();
}

init(): Promise<void> {
throw new Error("GRPC is currently not supported.");
throw new GRPCNotSupportedError();
}

getRegisteredActors(): Promise<string[]> {
throw new Error("GRPC is currently not supported.");
throw new GRPCNotSupportedError();
}

registerActor<T extends AbstractActor>(_cls: Class<T>): Promise<void> {
throw new Error("GRPC is currently not supported.");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There might be more such errors now introduced in some PRs like #485

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've searched the repo and there doesn't seem to be anymore files with those errors or similar errors

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay, I have found and updated it.
Quick question0- Do i create a new folder errors in the test directory to place the unit test files or do i just add them to an existing folder in the same test directory

Copy link
Member

@shubham1172 shubham1172 Jun 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They should be a part of https://github.com/dapr/js-sdk/tree/main/test/unit/<an-existing-folder> to test if components return the correct error, and also in https://github.com/dapr/js-sdk/tree/main/test/unit/errors to test the error itself.

throw new GRPCNotSupportedError();
}
}
18 changes: 18 additions & 0 deletions src/version.ts
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file has appeared again, I wonder is your IDE doing some magic 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shubham1172 I think it is doing some magic lol 😅, I suspect it does this when i run npm run pretty-fix command, but I'll be on the lookout next time. Could you please 🙏 give me a few pointers on how to resolve the code coverage issue, how do i test that each component returns the right error.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shubham1172 still waiting on your response sir 😇

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @jriffs, sorry this got lost in my GitHub notifications, thanks for pinging. For code coverage, I think it is okay to skip testing "GRPCNotSupportedError" or "HTTPNotSupportedError" since we usually do not write tests for unimplemented code anyway.

For PropertyRequiredError, we can create unit tests under test/unit/http, for e.g. workflow.ts and with a similar pattern like HttpServerImpl.test.ts, we can expect methods to throw a certain error.

Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
Copyright 2022 The Dapr Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

// This file is auto-generated by the prebuild script from package.json.
// It is not checked in to the git repository.

export const SDK_VERSION = "3.0.0";
export const SDK_PACKAGE_NAME = "@dapr/dapr";