mirror of
https://github.com/tgstation/tgstation-server.git
synced 2026-08-26 06:27:19 +01:00
Merge pull request #243 from Cyberboss/RemoteBranchForTestmerges
Ability to publish testmerge commits to remote
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
@@ -14,3 +15,6 @@ using System.Runtime.InteropServices;
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("9ad1f086-a83e-4d14-a844-58a9471106b6")]
|
||||
|
||||
//allow the unit tester to peek inside us
|
||||
[assembly: InternalsVisibleTo("TGServiceTests", AllInternalsVisible = true)]
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace TGCommandLine
|
||||
public RepoCommand()
|
||||
{
|
||||
Keyword = "repo";
|
||||
Children = new Command[] { new RepoSetupCommand(), new RepoUpdateCommand(), new RepoGenChangelogCommand(), new RepoPushChangelogCommand(), new RepoSetEmailCommand(), new RepoSetNameCommand(), new RepoMergePRCommand(), new RepoListPRsCommand(), new RepoStatusCommand(), new RepoListBackupsCommand(), new RepoCheckoutCommand(), new RepoResetCommand(), new RepoUpdateJsonCommand() };
|
||||
Children = new Command[] { new RepoSetupCommand(), new RepoUpdateCommand(), new RepoGenChangelogCommand(), new RepoPushChangelogCommand(), new RepoSetEmailCommand(), new RepoSetNameCommand(), new RepoMergePRCommand(), new RepoListPRsCommand(), new RepoStatusCommand(), new RepoListBackupsCommand(), new RepoCheckoutCommand(), new RepoResetCommand(), new RepoUpdateJsonCommand(), new RepoSetPushTestmergeCommitsCommand() };
|
||||
}
|
||||
public override string GetHelpText()
|
||||
{
|
||||
@@ -18,6 +18,41 @@ namespace TGCommandLine
|
||||
}
|
||||
}
|
||||
|
||||
class RepoSetPushTestmergeCommitsCommand : ConsoleCommand
|
||||
{
|
||||
public RepoSetPushTestmergeCommitsCommand()
|
||||
{
|
||||
Keyword = "push-testmerges";
|
||||
RequiredParameters = 1;
|
||||
}
|
||||
public override string GetHelpText()
|
||||
{
|
||||
return "Set if a temporary branch is to the remote when we make testmerge commits and then delete it";
|
||||
}
|
||||
|
||||
public override string GetArgumentString()
|
||||
{
|
||||
return "<on|off>";
|
||||
}
|
||||
|
||||
protected override ExitCode Run(IList<string> parameters)
|
||||
{
|
||||
switch (parameters[0].ToLower())
|
||||
{
|
||||
case "on":
|
||||
Interface.GetComponent<ITGRepository>().SetPushTestmergeCommits(true);
|
||||
break;
|
||||
case "off":
|
||||
Interface.GetComponent<ITGRepository>().SetPushTestmergeCommits(false);
|
||||
break;
|
||||
default:
|
||||
OutputProc("Invalid option!");
|
||||
return ExitCode.BadCommand;
|
||||
}
|
||||
return ExitCode.Normal;
|
||||
}
|
||||
}
|
||||
|
||||
class RepoUpdateJsonCommand : ConsoleCommand
|
||||
{
|
||||
public RepoUpdateJsonCommand()
|
||||
@@ -98,6 +133,7 @@ namespace TGCommandLine
|
||||
OutputProc("Remote: " + remote + " (" + remotehead + ")");
|
||||
OutputProc("Branch: " + branch);
|
||||
OutputProc("HEAD: " + head);
|
||||
OutputProc("Push testmerge commits: " + (Repo.PushTestmergeCommits() ? "ON" : "OFF"));
|
||||
OutputProc(String.Format("Committer Identity: {0} ({1})", Repo.GetCommitterName(), Repo.GetCommitterEmail()));
|
||||
}
|
||||
else
|
||||
|
||||
@@ -156,6 +156,7 @@
|
||||
this.StaticFileCreateButton = new System.Windows.Forms.Button();
|
||||
this.label6 = new System.Windows.Forms.Label();
|
||||
this.StaticFileListBox = new System.Windows.Forms.ListBox();
|
||||
this.SyncCommitsCheckBox = new System.Windows.Forms.CheckBox();
|
||||
this.ChatPanel.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.ChatPortSelector)).BeginInit();
|
||||
this.ChatProviderSelectorPanel.SuspendLayout();
|
||||
@@ -1308,6 +1309,7 @@
|
||||
// RepoPanel
|
||||
//
|
||||
this.RepoPanel.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(39)))), ((int)(((byte)(40)))), ((int)(((byte)(34)))));
|
||||
this.RepoPanel.Controls.Add(this.SyncCommitsCheckBox);
|
||||
this.RepoPanel.Controls.Add(this.TGSJsonUpdate);
|
||||
this.RepoPanel.Controls.Add(this.RepoRefreshButton);
|
||||
this.RepoPanel.Controls.Add(this.BackupTagsList);
|
||||
@@ -1765,6 +1767,20 @@
|
||||
this.StaticFileListBox.TabIndex = 0;
|
||||
this.StaticFileListBox.SelectedIndexChanged += new System.EventHandler(this.StaticFileListBox_SelectedIndexChanged);
|
||||
//
|
||||
// SyncCommitsCheckBox
|
||||
//
|
||||
this.SyncCommitsCheckBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.SyncCommitsCheckBox.AutoSize = true;
|
||||
this.SyncCommitsCheckBox.Font = new System.Drawing.Font("Verdana", 12F);
|
||||
this.SyncCommitsCheckBox.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(248)))), ((int)(((byte)(248)))), ((int)(((byte)(242)))));
|
||||
this.SyncCommitsCheckBox.Location = new System.Drawing.Point(574, 16);
|
||||
this.SyncCommitsCheckBox.Name = "SyncCommitsCheckBox";
|
||||
this.SyncCommitsCheckBox.Size = new System.Drawing.Size(142, 22);
|
||||
this.SyncCommitsCheckBox.TabIndex = 46;
|
||||
this.SyncCommitsCheckBox.Text = "Sync Commits";
|
||||
this.SyncCommitsCheckBox.UseVisualStyleBackColor = true;
|
||||
this.SyncCommitsCheckBox.Visible = false;
|
||||
//
|
||||
// Main
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
@@ -1929,5 +1945,6 @@
|
||||
private System.Windows.Forms.CheckBox AutoUpdateCheckbox;
|
||||
private System.Windows.Forms.Label AutoUpdateMLabel;
|
||||
private System.Windows.Forms.TextBox projectNameText;
|
||||
private System.Windows.Forms.CheckBox SyncCommitsCheckBox;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,6 +86,8 @@ namespace TGControlPanel
|
||||
BranchNameTitle.Visible = true;
|
||||
RepoBranchTextBox.Visible = true;
|
||||
RepoRefreshButton.Visible = true;
|
||||
SyncCommitsCheckBox.Visible = true;
|
||||
SyncCommitsCheckBox.Checked = Repo.PushTestmergeCommits();
|
||||
|
||||
if (!Repo.Exists())
|
||||
{
|
||||
@@ -233,6 +235,7 @@ namespace TGControlPanel
|
||||
if (RepoBGW.IsBusy || (ra != RepoAction.Wait && RepoBusyCheck()))
|
||||
return;
|
||||
|
||||
SyncCommitsCheckBox.Visible = false;
|
||||
CurrentRevisionLabel.Visible = false;
|
||||
CurrentRevisionTitle.Visible = false;
|
||||
TestMergeListLabel.Visible = false;
|
||||
@@ -292,6 +295,7 @@ namespace TGControlPanel
|
||||
|
||||
if (!Reclone)
|
||||
{
|
||||
Repo.SetPushTestmergeCommits(SyncCommitsCheckBox.Checked);
|
||||
var branch = Repo.GetBranch(out error);
|
||||
if(branch == null)
|
||||
{
|
||||
|
||||
@@ -93,6 +93,7 @@ namespace TGControlPanel
|
||||
WorldAnnounceField.Visible = RepoExists;
|
||||
WorldAnnounceButton.Visible = RepoExists;
|
||||
WorldAnnounceLabel.Visible = RepoExists;
|
||||
SyncCommitsCheckBox.Visible = RepoExists;
|
||||
|
||||
if (updatingFields)
|
||||
return;
|
||||
|
||||
@@ -326,5 +326,10 @@ namespace TGServerService
|
||||
/// Info: When an instance's logging ID is first assigned
|
||||
/// </summary>
|
||||
InstanceIDAssigned = 7600,
|
||||
/// <summary>
|
||||
/// Info: When a testmerge commit is published
|
||||
/// Warning: When a testmerge commit failed to be published
|
||||
/// </summary>
|
||||
ReferencePush = 7700,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace TGServerService
|
||||
/// <summary>
|
||||
/// Configuration settings for a <see cref="ServerInstance"/>
|
||||
/// </summary>
|
||||
interface IInstanceConfig
|
||||
public interface IInstanceConfig
|
||||
{
|
||||
/// <summary>
|
||||
/// The <see cref="ServerInstance"/> directory this <see cref="IInstanceConfig"/> is for
|
||||
@@ -107,6 +107,12 @@ namespace TGServerService
|
||||
/// The auto update interval for the <see cref="ServerInstance"/>
|
||||
/// </summary>
|
||||
ulong AutoUpdateInterval { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Whether or not testmerge commits are published to a temporary remote branch
|
||||
/// </summary>
|
||||
bool PushTestmergeCommits { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Saves the <see cref="IInstanceConfig"/> to it's <see cref="ServerInstance"/> <see cref="Directory"/>
|
||||
/// </summary>
|
||||
@@ -189,6 +195,9 @@ namespace TGServerService
|
||||
/// <inheritdoc />
|
||||
public ulong AutoUpdateInterval { get; set; } = 0;
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool PushTestmergeCommits { get; set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// Construct a <see cref="InstanceConfig"/> for a <see cref="ServerInstance"/> at <paramref name="path"/>
|
||||
/// </summary>
|
||||
|
||||
@@ -19,6 +19,10 @@ namespace TGServerService
|
||||
/// </summary>
|
||||
const string RepoPath = "Repository";
|
||||
/// <summary>
|
||||
/// The branch name used for publishing testmerge commits
|
||||
/// </summary>
|
||||
const string RemoteTempBranchName = "___TGS3TempBranch";
|
||||
/// <summary>
|
||||
/// The path to the Repository's <see cref="RepoConfig"/> json
|
||||
/// </summary>
|
||||
const string RepoTGS3SettingsPath = RepoPath + "/TGS3.json";
|
||||
@@ -542,14 +546,21 @@ namespace TGServerService
|
||||
/// Merges given <paramref name="committish"/> into the current branch
|
||||
/// </summary>
|
||||
/// <param name="committish">The sha/branch/tag to merge</param>
|
||||
/// <param name="mergeMessage">The commit message for the merge commit</param>
|
||||
/// <returns><see langword="null"/> on success, error message on failure</returns>
|
||||
string MergeBranch(string committish)
|
||||
string MergeBranch(string committish, string mergeMessage)
|
||||
{
|
||||
var mo = new MergeOptions()
|
||||
{
|
||||
OnCheckoutProgress = HandleCheckoutProgress
|
||||
};
|
||||
var Result = Repo.Merge(committish, MakeSig());
|
||||
if (mergeMessage != null)
|
||||
{
|
||||
mo.CommitOnSuccess = false;
|
||||
mo.FastForwardStrategy = FastForwardStrategy.NoFastForward;
|
||||
}
|
||||
var sig = MakeSig();
|
||||
var Result = Repo.Merge(committish, sig, mo);
|
||||
currentProgress = -1;
|
||||
switch (Result.Status)
|
||||
{
|
||||
@@ -560,9 +571,58 @@ namespace TGServerService
|
||||
case MergeStatus.UpToDate:
|
||||
return RepoErrorUpToDate;
|
||||
}
|
||||
if(mergeMessage != null)
|
||||
Repo.Commit(mergeMessage, sig, sig);
|
||||
return null;
|
||||
}
|
||||
|
||||
void PushTestmergeCommit()
|
||||
{
|
||||
if (Config.PushTestmergeCommits && SSHAuth())
|
||||
{
|
||||
string NewB = null;
|
||||
var targetRemote = Repo.Network.Remotes[SSHPushRemote];
|
||||
var options = new PushOptions()
|
||||
{
|
||||
CredentialsProvider = GenerateGitCredentials
|
||||
};
|
||||
try
|
||||
{
|
||||
//now try and push the commit to the remote so they can be referenced
|
||||
NewB = Repo.CreateBranch(RemoteTempBranchName).CanonicalName;
|
||||
Repo.Network.Push(targetRemote, NewB, options); //push the branch
|
||||
Repo.Branches.Remove(NewB);
|
||||
var removalString = String.Format(":{0}", NewB);
|
||||
NewB = null;
|
||||
//we need to delay the second operation a LOT otherwise we get ssh errors
|
||||
Thread.Sleep(10000);
|
||||
Repo.Network.Push(targetRemote, removalString, options); //delete the branch
|
||||
WriteInfo("Pushed reference commit: " + Repo.Head.Tip.Sha, EventID.ReferencePush);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
WriteWarning(String.Format("Failed to push reference commit: {0}. Error: {1}", Repo.Head.Tip.Sha, e.ToString()), EventID.ReferencePush);
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (NewB != null)
|
||||
{
|
||||
//Try to delete the branches regardless
|
||||
try
|
||||
{
|
||||
Repo.Branches.Remove(NewB);
|
||||
}
|
||||
catch { }
|
||||
try
|
||||
{
|
||||
Repo.Network.Push(targetRemote, String.Format(":{0}", NewB), options);
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public string Update(bool reset)
|
||||
{
|
||||
@@ -607,7 +667,9 @@ namespace TGServerService
|
||||
WriteInfo("Repo hard updated to " + originBranch.Tip.Sha, EventID.RepoHardUpdate);
|
||||
return error;
|
||||
}
|
||||
res = MergeBranch(originBranch.FriendlyName);
|
||||
res = MergeBranch(originBranch.FriendlyName, "Merge origin into current testmerge");
|
||||
if (!LocalIsRemote()) //might be fast forward
|
||||
PushTestmergeCommit();
|
||||
if (res != null)
|
||||
throw new Exception(res);
|
||||
UpdateSubmodules();
|
||||
@@ -844,7 +906,7 @@ namespace TGServerService
|
||||
}
|
||||
|
||||
//so we'll know if this fails
|
||||
var Result = MergeBranch(LocalBranchName);
|
||||
var Result = MergeBranch(LocalBranchName, String.Format("Testmerge commit for pull request #{0}", PRNumber));
|
||||
|
||||
if (Result == null)
|
||||
try
|
||||
@@ -894,6 +956,8 @@ namespace TGServerService
|
||||
WriteError("Failed to update PR list", EventID.RepoPRListError);
|
||||
return "PR Merged, JSON update failed: " + e.ToString();
|
||||
}
|
||||
|
||||
PushTestmergeCommit();
|
||||
}
|
||||
return Result;
|
||||
}
|
||||
@@ -1314,5 +1378,17 @@ namespace TGServerService
|
||||
var B = Repo.Branches[LiveTrackingBranch];
|
||||
return B != null ? B.Tip.Sha : "UNKNOWN";
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool PushTestmergeCommits()
|
||||
{
|
||||
return Config.PushTestmergeCommits;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void SetPushTestmergeCommits(bool newValue)
|
||||
{
|
||||
Config.PushTestmergeCommits = newValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -175,5 +175,19 @@ namespace TGServiceInterface.Components
|
||||
/// <returns>The current auto update interval or 0 if it's disabled</returns>
|
||||
[OperationContract]
|
||||
ulong AutoUpdateInterval();
|
||||
|
||||
/// <summary>
|
||||
/// Check if we push a temporary branch to the remote when we make testmerge commits
|
||||
/// </summary>
|
||||
/// <returns><see langword="true"/> if we publish testmerge commits to the remote, <see langword="false"/> otherwise</returns>
|
||||
[OperationContract]
|
||||
bool PushTestmergeCommits();
|
||||
|
||||
/// <summary>
|
||||
/// Set if we push a temporary branch to the remote when we make testmerge commits
|
||||
/// </summary>
|
||||
/// <param name="newValue"><see langword="true"/> if we testmerge commits should be published to the remote, <see langword="false"/> otherwise</param>
|
||||
[OperationContract]
|
||||
void SetPushTestmergeCommits(bool newValue);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
using Moq;
|
||||
using TGServiceInterface;
|
||||
using TGServiceInterface.Components;
|
||||
using TGServiceTests;
|
||||
|
||||
namespace TGCommandLine.Commands.Repository.Tests
|
||||
{
|
||||
public abstract class RepositoryCommandTest : OutputProcOverriderTest
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a mock <see cref="IInterface"/> that returns a specific <see cref="ITGRepository"/> when that component is requested
|
||||
/// </summary>
|
||||
/// <param name="repo">The <see cref="ITGRepository"/> the resulting <see cref="IInterface.GetComponent{T}"/> should return</param>
|
||||
/// <returns>A mock <see cref="IInterface"/></returns>
|
||||
protected IInterface MockInterfaceToRepo(ITGRepository repo)
|
||||
{
|
||||
var mock = new Mock<IInterface>();
|
||||
mock.Setup(foo => foo.GetComponent<ITGRepository>()).Returns(repo);
|
||||
return mock.Object;
|
||||
}
|
||||
}
|
||||
}
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
using System.Collections.Generic;
|
||||
using TGServiceInterface;
|
||||
using TGServiceInterface.Components;
|
||||
|
||||
namespace TGCommandLine.Commands.Repository.Tests
|
||||
{
|
||||
/// <summary>
|
||||
/// Tests for <see cref="RepoSetPushTestmergeCommitsCommand"/>
|
||||
/// </summary>
|
||||
[TestClass]
|
||||
public class TestRepoSetPushTestmergeCommitsCommand : RepositoryCommandTest
|
||||
{
|
||||
/// <summary>
|
||||
/// Ensure it can be turned on
|
||||
/// </summary>
|
||||
[TestMethod]
|
||||
public void TestTurnOn()
|
||||
{
|
||||
var ran = false;
|
||||
var repo = new Mock<ITGRepository>();
|
||||
repo.Setup(foo => foo.SetPushTestmergeCommits(true)).Callback(() => { ran = true; });
|
||||
ConsoleCommand.Interface = MockInterfaceToRepo(repo.Object);
|
||||
Assert.AreEqual(new RepoSetPushTestmergeCommitsCommand().DoRun(new List<string> { "on" }), Command.ExitCode.Normal);
|
||||
Assert.IsTrue(ran);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ensure that it can be turned off
|
||||
/// </summary>
|
||||
[TestMethod]
|
||||
public void TestTurnOff()
|
||||
{
|
||||
|
||||
var ran = false;
|
||||
var repo = new Mock<ITGRepository>();
|
||||
repo.Setup(foo => foo.SetPushTestmergeCommits(false)).Callback(() => { ran = true; });
|
||||
ConsoleCommand.Interface = MockInterfaceToRepo(repo.Object);
|
||||
Assert.AreEqual(new RepoSetPushTestmergeCommitsCommand().DoRun(new List<string> { "off" }), Command.ExitCode.Normal);
|
||||
Assert.IsTrue(ran);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ensure that <see cref="Command.ExitCode.BadCommand"/> is returned for gibberish parameters
|
||||
/// </summary>
|
||||
[TestMethod]
|
||||
public void TestGibberishParam()
|
||||
{
|
||||
Assert.AreEqual(new RepoSetPushTestmergeCommitsCommand().DoRun(new List<string> { "gibberish" }), Command.ExitCode.BadCommand);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
using System.Collections.Generic;
|
||||
using TGServiceInterface;
|
||||
using TGServiceInterface.Components;
|
||||
|
||||
namespace TGCommandLine.Commands.Repository.Tests
|
||||
{
|
||||
/// <summary>
|
||||
/// Tests for <see cref="RepoStatusCommand"/>
|
||||
/// </summary>
|
||||
[TestClass]
|
||||
public class TestRepoStatusCommand : RepositoryCommandTest
|
||||
{
|
||||
/// <summary>
|
||||
/// Set the default returns for the mock <see cref="ITGRepository"/> to be <see langword="null"/>
|
||||
/// </summary>
|
||||
/// <returns>A <see cref="Mock{T}"/> of <see cref="ITGRepository"/> with default <see langword="null"/> return values</returns>
|
||||
Mock<ITGRepository> GetDefaultMock()
|
||||
{
|
||||
var mock = new Mock<ITGRepository>();
|
||||
mock.SetReturnsDefault<string>(null);
|
||||
return mock;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tests the results of <see cref="ITGRepository.PushTestmergeCommits"/>
|
||||
/// </summary>
|
||||
[TestMethod]
|
||||
public void TestPushTestmergeCommits()
|
||||
{
|
||||
var ran = false;
|
||||
var mock = GetDefaultMock();
|
||||
mock.Setup(foo => foo.PushTestmergeCommits()).Returns(false).Callback(() => ran = true);
|
||||
ConsoleCommand.Interface = MockInterfaceToRepo(mock.Object);
|
||||
Assert.AreEqual(new RepoStatusCommand().DoRun(new List<string> { }), Command.ExitCode.Normal);
|
||||
Assert.IsTrue(ran);
|
||||
|
||||
ran = false;
|
||||
mock.Setup(foo => foo.PushTestmergeCommits()).Returns(true).Callback(() => ran = true);
|
||||
ConsoleCommand.Interface = MockInterfaceToRepo(mock.Object);
|
||||
Assert.AreEqual(new RepoStatusCommand().DoRun(new List<string> { }), Command.ExitCode.Normal);
|
||||
Assert.IsTrue(ran);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using TGServiceInterface;
|
||||
|
||||
namespace TGServiceTests
|
||||
{
|
||||
/// <summary>
|
||||
/// For tests that need to override <see cref="Command.OutputProcVar"/>
|
||||
/// </summary>
|
||||
public abstract class OutputProcOverriderTest
|
||||
{
|
||||
/// <summary>
|
||||
/// Set <see cref="Command.OutputProcVar"/> to <see cref="OutputProc(string)"/>
|
||||
/// </summary>
|
||||
[TestInitialize]
|
||||
public void Setup()
|
||||
{
|
||||
Command.OutputProcVar.Value = OutputProc;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Whe
|
||||
/// </summary>
|
||||
/// <param name="message"></param>
|
||||
protected virtual void OutputProc(string message) { }
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Moq;
|
||||
using TGServiceTests;
|
||||
|
||||
namespace TGServerService.Tests
|
||||
@@ -17,5 +18,33 @@ namespace TGServerService.Tests
|
||||
{
|
||||
new ServerInstance(new InstanceConfig(TempPath), 1).Dispose();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test the return value of <see cref="ServerInstance.PushTestmergeCommits"/>
|
||||
/// </summary>
|
||||
[TestMethod]
|
||||
public void TestPushTestMergeCommits()
|
||||
{
|
||||
var ic = new InstanceConfig(TempPath) { PushTestmergeCommits = false };
|
||||
using (var si = new ServerInstance(ic, 1))
|
||||
{
|
||||
Assert.IsFalse(si.PushTestmergeCommits());
|
||||
ic.PushTestmergeCommits = true;
|
||||
Assert.IsTrue(si.PushTestmergeCommits());
|
||||
}
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestSetPushTestMergeCommits()
|
||||
{
|
||||
var ic = new InstanceConfig(TempPath) { PushTestmergeCommits = false };
|
||||
using (var si = new ServerInstance(ic, 1))
|
||||
{
|
||||
si.SetPushTestmergeCommits(true);
|
||||
Assert.IsTrue(ic.PushTestmergeCommits);
|
||||
si.SetPushTestmergeCommits(false);
|
||||
Assert.IsFalse(ic.PushTestmergeCommits);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,19 +38,30 @@
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Castle.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Castle.Core.4.2.1\lib\net45\Castle.Core.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.VisualStudio.TestPlatform.TestFramework, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\MSTest.TestFramework.1.1.18\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\MSTest.TestFramework.1.1.18\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Moq, Version=4.7.145.0, Culture=neutral, PublicKeyToken=69f491c39445e920, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Moq.4.7.145\lib\net45\Moq.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Configuration" />
|
||||
<Reference Include="System.ServiceModel" />
|
||||
<Reference Include="System.ServiceProcess" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="CommandLine\Commands\Repository\RepositoryCommandTest.cs" />
|
||||
<Compile Include="CommandLine\Commands\Repository\TestRepoSetPushTestmergeCommitsCommand.cs" />
|
||||
<Compile Include="CommandLine\Commands\Repository\TestRepoStatusCommand.cs" />
|
||||
<Compile Include="Interface\TestHelpers.cs" />
|
||||
<Compile Include="Interface\TestInterface.cs" />
|
||||
<Compile Include="OutputProcOverriderTest.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Service\ServiceAccessor.cs">
|
||||
<SubType>Component</SubType>
|
||||
@@ -65,6 +76,10 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\TGCommandLine\TGCommandLine.csproj">
|
||||
<Project>{89191f69-b18e-4b59-b72e-e12f9b6811a0}</Project>
|
||||
<Name>TGCommandLine</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\TGServerService\TGServerService.csproj">
|
||||
<Project>{f32eda25-0855-411c-af5e-f0d042917e2d}</Project>
|
||||
<Name>TGServerService</Name>
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace TGServiceTests
|
||||
/// To be the parent of test classes that required a temporary directory
|
||||
/// </summary>
|
||||
[TestClass]
|
||||
public class TempDirectoryRequiredTest
|
||||
public abstract class TempDirectoryRequiredTest
|
||||
{
|
||||
/// <summary>
|
||||
/// The path to the temporary directory
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Castle.Core" version="4.2.1" targetFramework="net461" />
|
||||
<package id="Moq" version="4.7.145" targetFramework="net461" />
|
||||
<package id="MSTest.TestAdapter" version="1.1.18" targetFramework="net461" />
|
||||
<package id="MSTest.TestFramework" version="1.1.18" targetFramework="net461" />
|
||||
</packages>
|
||||
Reference in New Issue
Block a user