microsoft/hve-core

Public

mirrored from https://github.com/microsoft/hve-coreAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
ci/2086-enforce-powershell-coverage

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

scripts/tests/evals/fixtures/stub-moderation.ps1

41lines · modecode

1# Copyright (c) Microsoft Corporation.
2# SPDX-License-Identifier: MIT
3#
4# Test stub standing in for Invoke-ContentModeration.ps1. It mirrors the real
5# script's parameter surface and exit-code contract so VallyRunner moderation
6# classification can be exercised without invoking the moderation backend.
7#
8# Behavior is driven by environment variables:
9# STUB_MODERATION_EXIT - exit code to return (default 0).
10# STUB_MODERATION_COUNT - summary.flaggedCount to write (default 0).
11
12[CmdletBinding()]
13param(
14 [Parameter(Mandatory = $true)][object[]]$Records,
15 [Parameter(Mandatory = $true)][string]$Scope,
16 [double]$Threshold = 0.5,
17 [Parameter(Mandatory = $true)][string]$OutFile
18)
19
20$exitCode = 0
21if ($env:STUB_MODERATION_EXIT) { $exitCode = [int]$env:STUB_MODERATION_EXIT }
22
23$flaggedCount = 0
24if ($env:STUB_MODERATION_COUNT) { $flaggedCount = [int]$env:STUB_MODERATION_COUNT }
25
26$payload = [ordered]@{
27 scope = $Scope
28 records = @()
29 summary = [ordered]@{
30 total = $Records.Count
31 flaggedCount = $flaggedCount
32 }
33}
34
35$dir = Split-Path -Parent $OutFile
36if ($dir -and -not (Test-Path -LiteralPath $dir)) {
37 New-Item -ItemType Directory -Path $dir -Force | Out-Null
38}
39$payload | ConvertTo-Json -Depth 6 | Set-Content -LiteralPath $OutFile -Encoding utf8
40
41exit $exitCode
42