ocket8888 commented on code in PR #7480:
URL: https://github.com/apache/trafficcontrol/pull/7480#discussion_r1204460394
##########
experimental/traffic-portal/src/app/api/testing/profile.service.ts:
##########
@@ -220,4 +220,67 @@ export class ProfileService {
return this.profiles.splice(index, 1)[0];
}
+ private lastParamID = 20;
+ private readonly parameters: ResponseParameter[] = [
+ {
+ configFile: "cfg.txt",
+ id: 1,
+ lastUpdated: new Date(),
+ name: "param1",
+ profiles: [],
+ secure: false,
+ value: "10"
+ }
+ ];
+
+ public async getParameters(id: number): Promise<ResponseParameter>;
+ public async getParameters(): Promise<Array<ResponseParameter>>;
+ /**
+ * Gets one or all Parameters from Traffic Ops
+ *
+ * @param id The integral, unique identifier (number) of a single
parameter to be returned.
+ * @returns The requested parameter(s).
+ */
+ public async getParameters(id?: number): Promise<ResponseParameter |
Array<ResponseParameter>> {
+ if (id !== undefined) {
+ const parameter = this.parameters.filter(t=>t.id ===
id)[0];
+ if (!parameter) {
+ throw new Error(`no such Parameter: ${id}`);
+ }
+ return parameter;
+ }
+ return this.parameters;
+ }
+
+ /**
+ * Deletes an existing parameter.
+ *
+ * @param id Id of the parameter to delete.
+ * @returns The deleted parameter.
+ */
+ public async deleteParameter(id: number): Promise<ResponseParameter> {
Review Comment:
This call signature is incompatible with the concrete implementation's call
signature. The concrete service is `public async deleteParameter(typeOrId:
number | ResponseParameter): Promise<void>` while the testing service uses
`public async deleteParameter(id: number): Promise<ResponseParameter>`.
##########
experimental/traffic-portal/src/app/api/profile.service.ts:
##########
@@ -71,6 +71,27 @@ export class ProfileService extends APIService {
return this.get<Array<ResponseProfile>>(path).toPromise();
}
+ /**
+ * Retrieves Profiles associated with a Parameter from the API.
+ *
+ * @param p Either a {@link ResponseParameter} or an integral, unique
identifier of a Parameter, for which the
+ * Profiles are to be retrieved.
+ * @returns The requested Profile(s).
+ */
+ public async getProfilesByParam(p: number| ResponseParameter):
Promise<Array<ResponseProfile>> {
+ let id: number;
+ if (typeof p === "number") {
+ id = p;
Review Comment:
this line isn't covered; tests don't cover the case where an ID is passed.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]