Skip to content

Commit

Permalink
[Schema Registry] Enable min/max testing (Azure#17854)
Browse files Browse the repository at this point in the history
* [Schema Registry] Enable min/max testing

* address feedback

* add integration tests scripts

* remove index

* remove the import of OperationOptions
  • Loading branch information
deyaaeldeen authored Sep 27, 2021
1 parent fed1cb1 commit 5cca66b
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 24 deletions.
6 changes: 3 additions & 3 deletions sdk/schemaregistry/schema-registry/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@
"execute:samples": "dev-tool samples run samples-dev",
"extract-api": "tsc -p . && api-extractor run --local",
"format": "prettier --write --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"samples-dev/**/*.ts\" \"*.{js,json}\"",
"integration-test:browser": "echo skipped",
"integration-test:node": "echo skipped",
"integration-test:browser": "karma start --single-run",
"integration-test:node": "nyc mocha -r esm --require source-map-support/register --reporter ../../../common/tools/mocha-multi-reporter.js --timeout 5000000 --full-trace \"dist-esm/test/{,!(browser)/**/}*.spec.js\"",
"integration-test": "npm run integration-test:node && npm run integration-test:browser",
"lint:fix": "eslint package.json api-extractor.json src test --ext .ts --fix --fix-type [problem,suggestion]",
"lint": "eslint package.json api-extractor.json src test --ext .ts",
"pack": "npm pack 2>&1",
"test:browser": "npm run build:test && npm run integration-test:browser",
"test:node": "npm run build:test && npm run integration-test:node",
"test": "npm run build:test && npm run unit-test && npm run integration-test",
"test": "npm run build:test && npm run unit-test",
"unit-test:browser": "karma start --single-run",
"unit-test:node": "mocha -r esm -r ts-node/register --timeout 50000 --reporter ../../../common/tools/mocha-multi-reporter.js --colors --exclude \"test/**/*.browser.ts\" \"test/**/*.ts\"",
"unit-test": "npm run unit-test:node && npm run unit-test:browser",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

import { createRecordedClient, testEnv } from "./utils/recordedClient";
import { createRecordedClient } from "./utils/recordedClient";
import { Context } from "mocha";
import { Recorder } from "@azure-tools/test-recorder";
import { Recorder, env } from "@azure-tools/test-recorder";
import { assert, use as chaiUse } from "chai";
import chaiPromises from "chai-as-promised";
chaiUse(chaiPromises);
import { ClientSecretCredential } from "@azure/identity";

import { SchemaRegistryClient, SchemaDescription, SchemaProperties } from "../src/index";
import { FullOperationResponse, OperationOptions } from "@azure/core-client";
import { SchemaRegistryClient, SchemaDescription, SchemaProperties } from "../../src";

const options: OperationOptions = {
onResponse: (rawResponse: FullOperationResponse) => {
const options = {
onResponse: (rawResponse: { status: number }) => {
assert.equal(rawResponse.status, 200);
}
};
Expand Down Expand Up @@ -46,7 +45,7 @@ describe("SchemaRegistryClient", function() {
({ client, recorder } = createRecordedClient(this));
schema = {
name: "azsdk_js_test",
groupName: testEnv.SCHEMA_REGISTRY_GROUP,
groupName: env.SCHEMA_REGISTRY_GROUP,
format: "avro",
definition: JSON.stringify({
type: "record",
Expand Down Expand Up @@ -136,7 +135,7 @@ describe("SchemaRegistryClient", function() {
it("schema with whitespace", async () => {
const schema2: SchemaDescription = {
name: "azsdk_js_test2",
groupName: testEnv.SCHEMA_REGISTRY_GROUP,
groupName: env.SCHEMA_REGISTRY_GROUP,
format: "avro",
definition:
"{\n" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { Context } from "mocha";
import { env, Recorder, record, RecorderEnvironmentSetup } from "@azure-tools/test-recorder";
import { ClientSecretCredential } from "@azure/identity";

import { SchemaRegistryClient } from "../../src/index";
import { SchemaRegistryClient } from "../../../src";

export interface RecordedClient {
client: SchemaRegistryClient;
Expand All @@ -21,12 +21,6 @@ const replaceableVariables: { [k: string]: string } = {
SCHEMA_REGISTRY_GROUP: "group-1"
};

export const testEnv = new Proxy(replaceableVariables, {
get: (target, key: string) => {
return env[key] || target[key];
}
});

const environmentSetup: RecorderEnvironmentSetup = {
replaceableVariables,
customizationsOnRecordings: [
Expand All @@ -47,10 +41,10 @@ const environmentSetup: RecorderEnvironmentSetup = {
export function createRecordedClient(context: Context): RecordedClient {
const recorder = record(context, environmentSetup);
const credential = new ClientSecretCredential(
testEnv.AZURE_TENANT_ID,
testEnv.AZURE_CLIENT_ID,
testEnv.AZURE_CLIENT_SECRET
env.AZURE_TENANT_ID,
env.AZURE_CLIENT_ID,
env.AZURE_CLIENT_SECRET
);
const client = new SchemaRegistryClient(testEnv.SCHEMA_REGISTRY_ENDPOINT, credential);
const client = new SchemaRegistryClient(env.SCHEMA_REGISTRY_ENDPOINT, credential);
return { client, recorder };
}
2 changes: 0 additions & 2 deletions sdk/schemaregistry/schema-registry/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ stages:
parameters:
PackageName: "@azure/schema-registry"
ServiceDirectory: schemaregistry
MatrixFilters:
- DependencyVersion=^$
EnvVars:
AZURE_CLIENT_ID: $(aad-azure-sdk-test-client-id)
AZURE_CLIENT_SECRET: $(aad-azure-sdk-test-client-secret)
Expand Down

0 comments on commit 5cca66b

Please sign in to comment.