This repository has been archived by the owner on Jan 18, 2022. It is now read-only.
/
SpatialdManagerTests.cs
117 lines (102 loc) · 3.93 KB
/
SpatialdManagerTests.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#if !UNITY_EDITOR_OSX
using System;
using System.Linq;
using Improbable.Gdk.Tools;
using NUnit.Framework;
namespace Improbable.Gdk.TestUtils.Editor.Tests
{
[TestFixture]
public class SpatialdManagerTests
{
[Test]
public void Spatiald_is_running_after_Start()
{
using (SpatialdManager.Start().Result)
{
var result = RedirectedProcess.Spatial("service", "status")
.InDirectory(Common.SpatialProjectRootDir)
.RedirectOutputOptions(OutputRedirectBehaviour.None)
.RunAsync()
.Result;
Assert.IsTrue(result.Stdout.Any(line => line.Contains("Local API service is running")));
}
}
[Test]
public void Spatiald_is_not_running_after_Dispose()
{
using (SpatialdManager.Start().Result)
{
}
var result = RedirectedProcess.Spatial("service", "status")
.InDirectory(Common.SpatialProjectRootDir)
.RedirectOutputOptions(OutputRedirectBehaviour.None)
.RunAsync()
.Result;
Assert.IsTrue(result.Stdout.Any(line => line.Contains("Local API service is not running")));
}
[Test]
public void StartLocalDeployment_throws_if_invalid_launch_config_path()
{
using (var manager = SpatialdManager.Start().Result)
{
var aggregateException = Assert.Throws<AggregateException>(() =>
{
var deployment = manager.StartLocalDeployment("test", "doesnt_exist.json").Result;
// Shouldn't get here, but just in case ;)
deployment.Dispose();
});
Assert.IsInstanceOf<ArgumentException>(aggregateException.InnerExceptions[0]);
}
}
[Test]
public void StartLocalDeployment_throws_if_invalid_snapshot_name()
{
using (var manager = SpatialdManager.Start().Result)
{
var aggregateException = Assert.Throws<AggregateException>(() =>
{
var deployment = manager.StartLocalDeployment("test", "default_launch.json", "doesnt_exist.snapshot").Result;
// Shouldn't get here, but just in case ;)
deployment.Dispose();
});
Assert.IsInstanceOf<ArgumentException>(aggregateException.InnerExceptions[0]);
}
}
[Test]
public void StartLocalDeployment_starts_a_deployment()
{
using (var manager = SpatialdManager.Start().Result)
using (manager.StartLocalDeployment("test", "default_launch.json").Result)
{
Assert.IsNotEmpty(manager.GetRunningDeployments().Result);
}
}
[Test]
public void LocalDeployment_closes_deployment_on_dispose()
{
using (var manager = SpatialdManager.Start().Result)
{
using (manager.StartLocalDeployment("test", "default_launch.json").Result)
{
}
Assert.IsEmpty(manager.GetRunningDeployments().Result);
}
}
[Test]
public void LocalDeployment_can_add_dev_login_tag()
{
using (var manager = SpatialdManager.Start().Result)
{
using (var depl = manager.StartLocalDeployment("test", "default_launch.json").Result)
{
Assert.DoesNotThrow(() => depl.AddDevLoginTag().Wait());
var deployments = manager.GetRunningDeployments().Result;
var myDeployment = deployments[0];
Assert.Contains("dev_login", myDeployment.Tags);
Assert.Contains("dev_login", depl.Tags);
}
}
}
}
}
#endif