Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[App Config] Separate app config tests into public and internal to enable min-max tests #12694

Merged
merged 19 commits into from
Dec 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import {
transformKeyValue,
transformKeyValueResponseWithStatusCode,
transformKeyValueResponse
} from "../src/internal/helpers";
} from "../../src/internal/helpers";
import * as assert from "assert";
import { ConfigurationSetting, HttpResponseField, HttpResponseFields } from "../src";
import { ConfigurationSetting, HttpResponseField, HttpResponseFields } from "../../src";
import { HttpHeaders } from "@azure/core-http";

describe("helper methods", () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,17 @@ import { parseSyncToken, SyncTokens } from "../../src/internal/synctokenpolicy";
import * as assert from "assert";
import { AppConfigurationClient } from "../../src";
import nock from "nock";
import { getUserAgentPrefix, packageVersion } from "../../src/appConfigurationClient";
import {
getUserAgentPrefix,
InternalAppConfigurationClientOptions,
packageVersion
} from "../../src/appConfigurationClient";
import {
createAppConfigurationClientForTests,
assertThrowsRestError,
startRecorder
} from "../testHelpers";
} from "../public/utils/testHelpers";

import * as chai from "chai";
import { Recorder } from "@azure/test-utils-recorder";

Expand Down Expand Up @@ -146,7 +151,7 @@ describe("http request related tests", function() {
syncTokens = new SyncTokens();

client =
createAppConfigurationClientForTests({
createAppConfigurationClientForTests<InternalAppConfigurationClientOptions>({
syncTokens: syncTokens
}) || this.skip();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { join } from "path";
import * as assert from "assert";
import { isNode } from "@azure/core-http";

import { packageVersion } from "../src/appConfigurationClient";
import { packageVersion } from "../../src/appConfigurationClient";

describe("packagejson related tests", () => {
// if this test is failing you need to update the contant `packageVersion` referenced above
Expand All @@ -18,7 +18,7 @@ describe("packagejson related tests", () => {

try {
// For integration tests
const packageJsonFilePath = join(__dirname, "../../package.json");
const packageJsonFilePath = join(__dirname, "../../../package.json");
packageJsonContents = require(packageJsonFilePath);
} catch (e) {
// For unit tests
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
RestError
} from "@azure/core-http";
import { ThrottlingRetryPolicy, getDelayInMs } from "../../src/policies/throttlingRetryPolicy";
import { assertThrowsRestError } from "../testHelpers";
import { assertThrowsRestError } from "../public/utils/testHelpers";

describe("ThrottlingRetryPolicy", () => {
class PassThroughPolicy {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

import { Spanner } from "../src/internal/tracingHelpers";
import { Spanner } from "../../src/internal/tracingHelpers";
import { RestError } from "@azure/core-http";
import { getTracer } from "@azure/core-tracing";
import { SpanKind, CanonicalCode } from "@opentelemetry/api";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

import { AppConfigurationClient } from "../src";
import { startRecorder, getTokenAuthenticationCredential, CredsAndEndpoint } from "./testHelpers";
import { AppConfigurationClient } from "../../src";
import {
startRecorder,
getTokenAuthenticationCredential,
CredsAndEndpoint
} from "./utils/testHelpers";
import * as assert from "assert";
import { Recorder, isPlaybackMode } from "@azure/test-utils-recorder";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

import { AppConfigurationClient } from "../src";
import { AppConfigurationClient } from "../../src";
import {
startRecorder,
createAppConfigurationClientForTests,
deleteKeyCompletely,
assertThrowsRestError
} from "./testHelpers";
} from "./utils/testHelpers";
import * as assert from "assert";
import { Recorder } from "@azure/test-utils-recorder";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import {
deleteKeyCompletely,
assertThrowsAbortError,
startRecorder
} from "./testHelpers";
import { AppConfigurationClient } from "../src";
} from "./utils/testHelpers";
import { AppConfigurationClient } from "../../src";
import * as assert from "assert";
import { Recorder } from "@azure/test-utils-recorder";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import {
assertThrowsRestError,
assertThrowsAbortError,
startRecorder
} from "./testHelpers";
import { AppConfigurationClient, ConfigurationSetting } from "../src";
} from "./utils/testHelpers";
import { AppConfigurationClient, ConfigurationSetting } from "../../src";
import { delay } from "@azure/core-http";
import { Recorder } from "@azure/test-utils-recorder";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { AppConfigurationClient, ConfigurationSetting } from "../src";
import { AppConfigurationClient, ConfigurationSetting } from "../../src";
import {
createAppConfigurationClientForTests,
deleteKeyCompletely,
assertThrowsRestError,
startRecorder
} from "./testHelpers";
} from "./utils/testHelpers";
import * as assert from "assert";
import { Recorder } from "@azure/test-utils-recorder";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

import { AppConfigurationClient } from "../src";
import { AppConfigurationClient, AppConfigurationClientOptions } from "../../../src";
import { PagedAsyncIterableIterator } from "@azure/core-paging";
import { ConfigurationSetting, ListConfigurationSettingPage, ListRevisionsPage } from "../src";
import {
ConfigurationSetting,
ListConfigurationSettingPage,
ListRevisionsPage
} from "../../../src";
import { env, isPlaybackMode, RecorderEnvironmentSetup, record } from "@azure/test-utils-recorder";
import * as assert from "assert";

// allow loading from a .env file as an alternative to defining the variable
// in the environment
import * as dotenv from "dotenv";
import { RestError } from "@azure/core-http";

import { DefaultAzureCredential, TokenCredential } from "@azure/identity";
import { InternalAppConfigurationClientOptions } from "../src/appConfigurationClient";
dotenv.config();

let connectionStringNotPresentWarning = false;
Expand Down Expand Up @@ -70,9 +73,9 @@ export function getTokenAuthenticationCredential(): CredsAndEndpoint | undefined
};
}

export function createAppConfigurationClientForTests(
options?: InternalAppConfigurationClientOptions
): AppConfigurationClient | undefined {
export function createAppConfigurationClientForTests<
Options extends AppConfigurationClientOptions = AppConfigurationClientOptions
>(options?: Options): AppConfigurationClient | undefined {
const connectionString = env["APPCONFIG_CONNECTION_STRING"];

if (connectionString == null) {
Expand Down Expand Up @@ -158,7 +161,7 @@ export async function assertThrowsRestError(
await testFunction();
assert.fail(`${message}: No error thrown`);
} catch (err) {
if (err instanceof RestError) {
if (err.name === "RestError") {
assert.equal(expectedStatusCode, err.statusCode, message);
return err;
}
Expand Down
1 change: 1 addition & 0 deletions sdk/appconfiguration/app-configuration/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ extends:
ResourceServiceDirectory: appconfiguration
TestBrowser: true
TestSamples: false
TestMinMax: true
EnvVars:
AZURE_CLIENT_ID: $(aad-azure-sdk-test-client-id)
AZURE_TENANT_ID: $(aad-azure-sdk-test-tenant-id)
Expand Down