-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into update-functionAppConfig
- Loading branch information
Showing
535 changed files
with
97,291 additions
and
2,351 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
130 changes: 130 additions & 0 deletions
130
eng/tools/typespec-validation/test/linter-ruleset.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
import { describe, it } from "vitest"; | ||
import { join } from "path"; | ||
import { LinterRulesetRule } from "../src/rules/linter-ruleset.js"; | ||
import { TsvTestHost } from "./tsv-test-host.js"; | ||
import { strict as assert } from "node:assert"; | ||
|
||
describe("linter-ruleset", function () { | ||
it("succeeds with default config", async function () { | ||
const host = new TsvTestHost(); | ||
const result = await new LinterRulesetRule().execute(host, TsvTestHost.folder); | ||
assert(result.success); | ||
}); | ||
|
||
it("succeeds with resource-manager/resource-manager", async function () { | ||
const host = new TsvTestHost(); | ||
host.readTspConfig = async (_folder: string) => ` | ||
options: | ||
"@azure-tools/typespec-autorest": | ||
azure-resource-provider-folder: "resource-manager" | ||
linter: | ||
extends: | ||
- "@azure-tools/typespec-azure-rulesets/resource-manager" | ||
`; | ||
const result = await new LinterRulesetRule().execute(host, TsvTestHost.folder); | ||
assert(result.success); | ||
}); | ||
|
||
it("succeeds with data-plane/data-plane", async function () { | ||
const host = new TsvTestHost(); | ||
host.readTspConfig = async (_folder: string) => ` | ||
options: | ||
"@azure-tools/typespec-autorest": | ||
azure-resource-provider-folder: "data-plane" | ||
linter: | ||
extends: | ||
- "@azure-tools/typespec-azure-rulesets/data-plane" | ||
`; | ||
const result = await new LinterRulesetRule().execute(host, TsvTestHost.folder); | ||
assert(result.success); | ||
}); | ||
|
||
it("succeeds with client.tsp/data-plane", async function () { | ||
const host = new TsvTestHost(); | ||
host.checkFileExists = async (file: string) => file === join(TsvTestHost.folder, "client.tsp"); | ||
host.readTspConfig = async (_folder: string) => ` | ||
linter: | ||
extends: | ||
- "@azure-tools/typespec-azure-rulesets/data-plane" | ||
`; | ||
const result = await new LinterRulesetRule().execute(host, TsvTestHost.folder); | ||
assert(result.success); | ||
}); | ||
|
||
it("fails with no-config", async function () { | ||
const host = new TsvTestHost(); | ||
host.readTspConfig = async (_folder: string) => ""; | ||
const result = await new LinterRulesetRule().execute(host, TsvTestHost.folder); | ||
assert(!result.success); | ||
}); | ||
|
||
it("fails with resource-manager/no-linter", async function () { | ||
const host = new TsvTestHost(); | ||
host.readTspConfig = async (_folder: string) => ` | ||
options: | ||
"@azure-tools/typespec-autorest": | ||
azure-resource-provider-folder: "resource-manager" | ||
`; | ||
const result = await new LinterRulesetRule().execute(host, TsvTestHost.folder); | ||
assert(!result.success); | ||
}); | ||
|
||
it("fails with resource-manager/data-plane", async function () { | ||
const host = new TsvTestHost(); | ||
host.readTspConfig = async (_folder: string) => ` | ||
options: | ||
"@azure-tools/typespec-autorest": | ||
azure-resource-provider-folder: "resource-manager" | ||
linter: | ||
extends: | ||
- "@azure-tools/typespec-azure-rulesets/data-plane" | ||
`; | ||
const result = await new LinterRulesetRule().execute(host, TsvTestHost.folder); | ||
assert(!result.success); | ||
}); | ||
|
||
it("fails with data-plane/resource-manager", async function () { | ||
const host = new TsvTestHost(); | ||
host.readTspConfig = async (_folder: string) => ` | ||
options: | ||
"@azure-tools/typespec-autorest": | ||
azure-resource-provider-folder: "data-plane" | ||
linter: | ||
extends: | ||
- "@azure-tools/typespec-azure-rulesets/resource-manager" | ||
`; | ||
const result = await new LinterRulesetRule().execute(host, TsvTestHost.folder); | ||
assert(!result.success); | ||
}); | ||
|
||
it("fails with data-plane/old-and-new", async function () { | ||
const host = new TsvTestHost(); | ||
host.readTspConfig = async (_folder: string) => ` | ||
options: | ||
"@azure-tools/typespec-autorest": | ||
azure-resource-provider-folder: "data-plane" | ||
linter: | ||
extends: | ||
- "@azure-tools/typespec-azure-core/all" | ||
- "@azure-tools/typespec-azure-rulesets/data-plane" | ||
`; | ||
const result = await new LinterRulesetRule().execute(host, TsvTestHost.folder); | ||
assert(!result.success); | ||
}); | ||
|
||
it("fails with resource-manager/old-and-new", async function () { | ||
const host = new TsvTestHost(); | ||
host.readTspConfig = async (_folder: string) => ` | ||
options: | ||
"@azure-tools/typespec-autorest": | ||
azure-resource-provider-folder: "resource-manager" | ||
linter: | ||
extends: | ||
- "@azure-tools/typespec-azure-resource-manager/all" | ||
- "@azure-tools/typespec-azure-rulesets/resource-manager" | ||
`; | ||
const result = await new LinterRulesetRule().execute(host, TsvTestHost.folder); | ||
|
||
assert(!result.success); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.