Skip to content

Commit

Permalink
FunctionalTests: update and enable ServiceVerbTests
Browse files Browse the repository at this point in the history
Update the ServiceVerbTests for the new behavior of 'scalar service':

- Only option is --list-registered
- Supported on Mac
- Tests cannot assume they are running in isolation, other repos on
  the machine may be registered
  • Loading branch information
wilbaker committed Nov 6, 2019
1 parent 9c086a2 commit da2f66b
Showing 1 changed file with 4 additions and 59 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,11 @@
namespace Scalar.FunctionalTests.Tests.MultiEnlistmentTests
{
[TestFixture]
[NonParallelizable]
[Category(Categories.ExtraCoverage)]
[Category(Categories.MacTODO.NeedsServiceVerb)]
[Category(Categories.NeedsUpdatesForNonVirtualizedMode)]
public class ServiceVerbTests : TestsWithMultiEnlistment
{
private static readonly string[] EmptyRepoList = new string[] { };

[TestCase]
public void ServiceCommandsWithNoRepos()
{
this.RunServiceCommandAndCheckOutput("--unmount-all", EmptyRepoList);
this.RunServiceCommandAndCheckOutput("--mount-all", EmptyRepoList);
this.RunServiceCommandAndCheckOutput("--list-mounted", EmptyRepoList);
}

[TestCase]
public void ServiceCommandsWithMultipleRepos()
public void ServiceListRegistered()
{
ScalarFunctionalTestEnlistment enlistment1 = this.CreateNewEnlistment();
ScalarFunctionalTestEnlistment enlistment2 = this.CreateNewEnlistment();
Expand All @@ -39,51 +26,9 @@ public void ServiceCommandsWithMultipleRepos()
enlistment2.EnlistmentRoot,
enlistment2.LocalCacheRoot);

this.RunServiceCommandAndCheckOutput("--list-mounted", expectedRepoRoots: repoRootList);
this.RunServiceCommandAndCheckOutput("--unmount-all", expectedRepoRoots: repoRootList);

// Check both are unmounted
scalarProcess1.IsEnlistmentMounted().ShouldEqual(false);
scalarProcess2.IsEnlistmentMounted().ShouldEqual(false);

this.RunServiceCommandAndCheckOutput("--list-mounted", EmptyRepoList);
this.RunServiceCommandAndCheckOutput("--unmount-all", EmptyRepoList);
this.RunServiceCommandAndCheckOutput("--mount-all", expectedRepoRoots: repoRootList);

// Check both are mounted
scalarProcess1.IsEnlistmentMounted().ShouldEqual(true);
scalarProcess2.IsEnlistmentMounted().ShouldEqual(true);

this.RunServiceCommandAndCheckOutput("--list-mounted", expectedRepoRoots: repoRootList);
}

[TestCase]
public void ServiceCommandsWithMountAndUnmount()
{
ScalarFunctionalTestEnlistment enlistment1 = this.CreateNewEnlistment();

string[] repoRootList = new string[] { enlistment1.EnlistmentRoot };

ScalarProcess scalarProcess1 = new ScalarProcess(
ScalarTestConfig.PathToScalar,
enlistment1.EnlistmentRoot,
enlistment1.LocalCacheRoot);

this.RunServiceCommandAndCheckOutput("--list-mounted", expectedRepoRoots: repoRootList);

scalarProcess1.Unmount();

this.RunServiceCommandAndCheckOutput("--list-mounted", EmptyRepoList, unexpectedRepoRoots: repoRootList);
this.RunServiceCommandAndCheckOutput("--unmount-all", EmptyRepoList, unexpectedRepoRoots: repoRootList);
this.RunServiceCommandAndCheckOutput("--mount-all", EmptyRepoList, unexpectedRepoRoots: repoRootList);

// Check that it is still unmounted
scalarProcess1.IsEnlistmentMounted().ShouldEqual(false);

scalarProcess1.Mount();

this.RunServiceCommandAndCheckOutput("--unmount-all", expectedRepoRoots: repoRootList);
this.RunServiceCommandAndCheckOutput("--mount-all", expectedRepoRoots: repoRootList);
// Do not check for unexpected repos, as other repos on the machine may be registered while
// this test is running
this.RunServiceCommandAndCheckOutput("--list-registered", expectedRepoRoots: repoRootList);
}

private void RunServiceCommandAndCheckOutput(string argument, string[] expectedRepoRoots, string[] unexpectedRepoRoots = null)
Expand Down

0 comments on commit da2f66b

Please sign in to comment.