Skip to content

Make sure --filedeployment is counted as a valid operation #317

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

Merged
merged 2 commits into from
Feb 24, 2025
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
51 changes: 51 additions & 0 deletions nanoFirmwareFlasher.Tests/FileDeploymentTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System;
using System.Collections.Generic;
using System.IO;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using nanoFirmwareFlasher.Tests.Helpers;
using nanoFramework.Tools.FirmwareFlasher;

namespace nanoFirmwareFlasher.Tests
{
/// <summary>
/// Verify that the options to nanoff are passed correctly to the low-level classes.
/// This cannot be done for the update of firmware, at least not for ESP32, as that
/// requires a connection to a real device.
/// </summary>
[TestClass]
[TestCategory("File deployment")]
[DoNotParallelize] // because of static variables in the programs
public sealed class FileDeploymentTests
{
public TestContext TestContext { get; set; } = null!;

[TestMethod]
public void FileDeployment_Recognizes_ValidOperation()
{
#region Setup
using var output = new OutputWriterHelper();
string testDirectory = TestDirectoryHelper.GetTestDirectory(TestContext);
string deployJsonPath = Path.Combine(testDirectory, "deploy.json");

File.WriteAllText(deployJsonPath, @"{
""serialport"":""COM3"",
""files"": [{
""DestinationFilePath"": ""I:\\deploy.json"",
""SourceFilePath"": """ + deployJsonPath.Replace("\\", "\\\\") + @"""
}]
}");
#endregion

#region Deploy content files
int actual = Program.Main(["--filedeployment", deployJsonPath])
.GetAwaiter().GetResult();

Assert.IsFalse(output.Output.Contains("No operation was performed with the options supplied."));

#endregion
}
}
}
1 change: 1 addition & 0 deletions nanoFirmwareFlasher.Tool/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -764,6 +764,7 @@ static async Task RunOptionsAndReturnExitCodeAsync(Options o)
try
{
_exitCode = await deploy.DeployAsync();
operationPerformed = true;
}
catch (Exception ex)
{
Expand Down