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

## [v1.2.0](https://github.com/contentstack/contentstack-management-dotnet/tree/v1.2.0)(2026-10-28)
## [v1.2.0](https://github.com/contentstack/contentstack-management-dotnet/tree/v1.2.0)(2026-11-12)

- **New**
- **Branch create: optional environment list**: `BranchModel.PublishConfig` (`BranchPublishConfigModel`, with `Environments` as a list of environment names, not UIDs) lets `Branch.Create` / `CreateAsync` clone only the listed environments. `[]` clones none; leaving `PublishConfig` unset clones all environments, as before. The list is sent unchanged; an unknown name or a mix rejects with the API's 422 error (`ContentstackErrorException`, message, error code and errors unchanged) and no branch is created.
- **Branch fetch**: a fetched `BranchModel` carries `PublishConfig.Environments` as the API returns it; it is `null` when the API omits it.
- **Test**
- Unit tests for the branch create body with two names, `[]` and unset (through `Create` and `CreateAsync`), a mocked 422 rejection, and fetched branch deserialization.
- Integration tests for create with two names, `[]`, an unknown name and a mix (written; not run in this change).
- Integration tests for create with two names, `[]`, an unknown name and a mix. The test class now creates two uniquely named environments on the stack and deletes them afterwards, because the `development` and `staging` names it used before do not exist on the stack the suite creates, so the two-name case failed with a 422. Run live against the NA prod API, the four environment-list cases pass.

## [v1.1.1](https://github.com/contentstack/contentstack-management-dotnet/tree/v1.1.1)(2026-07-30)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@ public class Contentstack005_BranchTest

// publish_config.environments: names (not UIDs) that must exist on the test stack.
// Set these to two real environment names on the stack before running the live suite.
private const string EnvironmentOne = "development";
private const string EnvironmentTwo = "staging";
private static readonly string EnvironmentOne = "dotnet_brenv_" + Guid.NewGuid().ToString("N").Substring(0,6);
private static string _envOneUid;
private static readonly string EnvironmentTwo = "dotnet_brenv_" + Guid.NewGuid().ToString("N").Substring(0,6);
private static string _envTwoUid;
private const string UnknownEnvironment = "dotnet_no_env_99999";
private const string EnvTwoBranchUid = "dotnet_env_two"; // max 15 chars, alphanumeric+underscore
private const string EnvNoneBranchUid = "dotnet_env_none"; // max 15 chars, alphanumeric+underscore
Expand All @@ -44,6 +46,9 @@ public static void ClassInitialize(TestContext context)
StackResponse response = StackResponse.getStack(_client.serializer);
_stack = _client.Stack(response.Stack.APIKey);

_envOneUid = CreateTestEnvironment(EnvironmentOne);
_envTwoUid = CreateTestEnvironment(EnvironmentTwo);

// Best-effort cleanup of any branches left over from a previous test run
TryDeleteBranch(TestBranchUid);
TryDeleteBranch(TestBranchUidAsync);
Expand All @@ -63,10 +68,24 @@ public static void ClassCleanup()
TryDeleteBranch(EnvUnknownBranchUid);
TryDeleteBranch(EnvMixBranchUid);

try { if (_envOneUid != null) _stack.Environment(_envOneUid).Delete(); } catch { }
try { if (_envTwoUid != null) _stack.Environment(_envTwoUid).Delete(); } catch { }

try { _client?.Logout(); } catch { }
_client = null;
}

private static string CreateTestEnvironment(string name)
{
var model = new EnvironmentModel
{
Name = name,
Urls = new List<LocalesUrl> { new LocalesUrl { Locale = "en-us", Url = "https://example.com" } }
};
ContentstackResponse r = _stack.Environment().Create(model);
return r.IsSuccessStatusCode ? r.OpenJsonObjectResponse()["environment"]?["uid"]?.ToString() : null;
}

private static void TryDeleteBranch(string uid)
{
if (string.IsNullOrEmpty(uid)) return;
Expand Down
Loading