Skip to content
Open
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
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## Unreleased

### New features

- `udf` command to manage Cosmos DB for NoSQL user-defined functions on the current container: `list`, `show`, `exists` (returns a boolean usable in `if`/`while` conditions), `create` (from a JavaScript file or piped body, with `--force` to replace), and `delete`. ([#103](https://github.com/Azure/CosmosDBShell/issues/103))
- `trigger` command to manage Cosmos DB for NoSQL triggers on the current container: `list`, `show`, `exists` (returns a boolean usable in `if`/`while` conditions), `create` (from a JavaScript file or piped body, with `--type` for pre/post, `--operation` for the operation, and `--force` to replace), and `delete`. ([#103](https://github.com/Azure/CosmosDBShell/issues/103))

## 1.1.4-preview — 2026-05-21

First release on the 1.1 line. A pretty packed cycle. The headline change is **ARM-based control plane for database and container management**, but there’s also a fully reworked CLI, two new item commands, a much friendlier shell experience for newcomers, and a long list of paper-cut fixes.
Expand Down
66 changes: 66 additions & 0 deletions CosmosDBShell.Tests/CommandTests/TriggerCommandTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
// ------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
// ------------------------------------------------------------

namespace CosmosShell.Tests.CommandTests;

using Azure.Data.Cosmos.Shell.Commands;
using Azure.Data.Cosmos.Shell.Core;
using Microsoft.Azure.Cosmos.Scripts;

/// <summary>
/// Unit tests for the pure helpers on <see cref="TriggerCommand"/>: subcommand
/// normalization and trigger type/operation parsing.
/// </summary>
public class TriggerCommandTests
{
[Theory]
[InlineData("LIST", "list")]
[InlineData(" Show ", "show")]
[InlineData("Create", "create")]
[InlineData(null, "")]
[InlineData("", "")]
public void NormalizeSubcommand_TrimsAndLowercases(string? input, string expected)
{
Assert.Equal(expected, TriggerCommand.NormalizeSubcommand(input));
}

[Theory]
[InlineData("pre", TriggerType.Pre)]
[InlineData("PRE", TriggerType.Pre)]
[InlineData(" post ", TriggerType.Post)]
public void ParseTriggerType_ValidValues_AreParsed(string input, TriggerType expected)
{
Assert.Equal(expected, TriggerCommand.ParseTriggerType(input));
}

[Theory]
[InlineData(null)]
[InlineData("")]
[InlineData("middle")]
public void ParseTriggerType_InvalidValues_Throw(string? input)
{
Assert.Throws<CommandException>(() => TriggerCommand.ParseTriggerType(input));
}

[Theory]
[InlineData(null, TriggerOperation.All)]
[InlineData("", TriggerOperation.All)]
[InlineData("all", TriggerOperation.All)]
[InlineData("Create", TriggerOperation.Create)]
[InlineData("replace", TriggerOperation.Replace)]
[InlineData("DELETE", TriggerOperation.Delete)]
[InlineData(" update ", TriggerOperation.Update)]
public void ParseTriggerOperation_ValidValues_AreParsed(string? input, TriggerOperation expected)
{
Assert.Equal(expected, TriggerCommand.ParseTriggerOperation(input));
}

[Theory]
[InlineData("insert")]
[InlineData("bogus")]
public void ParseTriggerOperation_InvalidValues_Throw(string input)
{
Assert.Throws<CommandException>(() => TriggerCommand.ParseTriggerOperation(input));
}
}
24 changes: 24 additions & 0 deletions CosmosDBShell.Tests/CommandTests/UdfCommandTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// ------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
// ------------------------------------------------------------

namespace CosmosShell.Tests.CommandTests;

using Azure.Data.Cosmos.Shell.Commands;

/// <summary>
/// Unit tests for the pure helpers on <see cref="UdfCommand"/>.
/// </summary>
public class UdfCommandTests
{
[Theory]
[InlineData("LIST", "list")]
[InlineData(" Show ", "show")]
[InlineData("Create", "create")]
[InlineData(null, "")]
[InlineData("", "")]
public void NormalizeSubcommand_TrimsAndLowercases(string? input, string expected)
{
Assert.Equal(expected, UdfCommand.NormalizeSubcommand(input));
}
}
Loading
Loading