Skip to content
This repository was archived by the owner on Jan 18, 2022. It is now read-only.

Commit 4bc6b07

Browse files
author
Paul Balaji
authored
UTY-2126: deployment launcher window no longer accepts 33-chara… (#1202)
1 parent e8e93b4 commit 4bc6b07

22 files changed

+500
-2
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@
1616

1717
- Generated Worker ID's for local development are now smaller and easier to read for debugging. [#1197](https://github.com/spatialos/gdk-for-unity/pull/1197)
1818

19+
### Fixed
20+
21+
- Fixed a bug where the Deployment Launcher window would accept tags with 33 characters. [#1202](https://github.com/spatialos/gdk-for-unity/pull/1202)
22+
1923
### Internal
2024

2125
- Cleaned up Subscriptions and Callbacks. [#1200](https://github.com/spatialos/gdk-for-unity/pull/1200)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
using System.Runtime.CompilerServices;
2+
3+
[assembly: InternalsVisibleTo("Improbable.Gdk.DeploymentLauncher.EditmodeTests")]

workers/unity/Packages/io.improbable.gdk.deploymentlauncher/AssemblyInfo.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

workers/unity/Packages/io.improbable.gdk.deploymentlauncher/DeploymentConfigurations.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -409,9 +409,9 @@ private bool ValidateSnapshotPath(out string message)
409409

410410
private bool ValidateTag(string tag, out string message)
411411
{
412-
if (!Regex.IsMatch(tag, "^[A-Za-z0-9][A-Za-z0-9_]{2,32}$"))
412+
if (!Regex.IsMatch(tag, "^[A-Za-z0-9][A-Za-z0-9_]{2,31}$"))
413413
{
414-
message = $"Tag \"{tag}\" invalid. Must conform to the regex: ^[A-Za-z0-9][A-Za-z0-9_]{{2,32}}$";
414+
message = $"Tag \"{tag}\" invalid. Must conform to the regex: ^[A-Za-z0-9][A-Za-z0-9_]{{2,31}}$";
415415
return false;
416416
}
417417

workers/unity/Packages/io.improbable.gdk.deploymentlauncher/Tests.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

workers/unity/Packages/io.improbable.gdk.deploymentlauncher/Tests/Editmode.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

workers/unity/Packages/io.improbable.gdk.deploymentlauncher/Tests/Editmode/DeploymentConfig.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
using Improbable.Gdk.DeploymentLauncher.EditmodeTests.Utils;
2+
using NUnit.Framework;
3+
4+
namespace Improbable.Gdk.DeploymentLauncher.EditmodeTests
5+
{
6+
[TestFixture]
7+
public class AssemblyConfigTests
8+
{
9+
private AssemblyConfig GetValidConfig()
10+
{
11+
return new AssemblyConfig
12+
{
13+
ProjectName = DeploymentConfigTestUtils.ValidProjectName,
14+
AssemblyName = DeploymentConfigTestUtils.ValidAssemblyName
15+
};
16+
}
17+
18+
[Test]
19+
public void AssemblyConfig_does_not_throw_error_when_valid()
20+
{
21+
Assert.IsNull(GetValidConfig().GetError());
22+
}
23+
24+
[TestCase(null, DeploymentConfigErrorTypes.NullOrEmpty)]
25+
[TestCase("", DeploymentConfigErrorTypes.NullOrEmpty)]
26+
[TestCase("gdk", DeploymentConfigErrorTypes.Invalid)]
27+
[TestCase("siebenhundertsiebenundsiebzigtausendsiebenhundertsiebenundsiebzig", DeploymentConfigErrorTypes.Invalid)]
28+
public void AssemblyConfig_throws_error_for_invalid_assembly_name(string assemblyName, string errorType)
29+
{
30+
var config = GetValidConfig();
31+
config.AssemblyName = assemblyName;
32+
var error = config.GetError();
33+
34+
Assert.IsNotNull(error);
35+
Assert.IsTrue(error.Contains("Assembly Name"));
36+
Assert.IsTrue(error.Contains(errorType));
37+
}
38+
}
39+
}

workers/unity/Packages/io.improbable.gdk.deploymentlauncher/Tests/Editmode/DeploymentConfig/AssemblyConfigTests.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
using System.Linq;
2+
using Improbable.Gdk.DeploymentLauncher.EditmodeTests.Utils;
3+
using NUnit.Framework;
4+
5+
namespace Improbable.Gdk.DeploymentLauncher.EditmodeTests
6+
{
7+
[TestFixture]
8+
public class BaseDeploymentConfigTests
9+
{
10+
[Test]
11+
public void BaseDeploymentConfig_does_not_throw_error_when_valid()
12+
{
13+
Assert.IsEmpty(DeploymentConfigTestUtils.GetValidBaseConfig().GetErrors());
14+
}
15+
16+
[TestCase("demo_dpl_final")]
17+
[TestCase("demo_dpl_final2")]
18+
public void BaseDeploymentConfig_does_not_throw_error_for_valid_deployment_name(string deploymentName)
19+
{
20+
var config = DeploymentConfigTestUtils.GetValidBaseConfig();
21+
config.Name = deploymentName;
22+
23+
Assert.IsEmpty(config.GetErrors());
24+
}
25+
26+
[TestCase(null, DeploymentConfigErrorTypes.NullOrEmpty)]
27+
[TestCase("", DeploymentConfigErrorTypes.NullOrEmpty)]
28+
[TestCase("#badname!", DeploymentConfigErrorTypes.Invalid)]
29+
public void BaseDeploymentConfig_throws_error_for_invalid_deployment_name(string invalidName, string errorType)
30+
{
31+
var config = DeploymentConfigTestUtils.GetValidBaseConfig();
32+
config.Name = invalidName;
33+
var errors = config.GetErrors().ToArray();
34+
35+
Assert.AreEqual(errors.Length, 1, "Failed: did not throw exactly one error.");
36+
Assert.IsTrue(errors[0].Contains("Deployment Name"));
37+
Assert.IsTrue(errors[0].Contains(errorType));
38+
}
39+
40+
[TestCase("default_launch.json")]
41+
[TestCase("cloud_launch.json")]
42+
public void BaseDeploymentConfig_does_not_throw_error_for_valid_launch_json_path(string launchJson)
43+
{
44+
var config = DeploymentConfigTestUtils.GetValidBaseConfig();
45+
config.LaunchJson = launchJson;
46+
47+
Assert.IsEmpty(config.GetErrors());
48+
}
49+
50+
[TestCase(null, DeploymentConfigErrorTypes.NullOrEmpty)]
51+
[TestCase("", DeploymentConfigErrorTypes.NullOrEmpty)]
52+
[TestCase("this/launch/config/does/not/exist.json", DeploymentConfigErrorTypes.NotFound)]
53+
public void BaseDeploymentConfig_throws_error_for_invalid_launch_json_path(string launchJson, string errorType)
54+
{
55+
var config = DeploymentConfigTestUtils.GetValidBaseConfig();
56+
config.LaunchJson = launchJson;
57+
var errors = config.GetErrors().ToArray();
58+
59+
Assert.AreEqual(errors.Length, 1, "Failed: did not throw exactly one error.");
60+
Assert.IsTrue(errors[0].Contains("Launch Config"));
61+
Assert.IsTrue(errors[0].Contains(errorType));
62+
}
63+
64+
[TestCase(null)]
65+
[TestCase("")]
66+
[TestCase("snapshots/default.snapshot")]
67+
public void BaseDeploymentConfig_does_not_throw_error_for_valid_snapshot_path(string snapshotPath)
68+
{
69+
var config = DeploymentConfigTestUtils.GetValidBaseConfig();
70+
config.SnapshotPath = snapshotPath;
71+
72+
Assert.IsEmpty(config.GetErrors());
73+
}
74+
75+
[TestCase("this/snapshot/path/does/not/exist.snapshot")]
76+
public void BaseDeploymentConfig_throws_error_for_invalid_snapshot_path(string snapshotPath)
77+
{
78+
var config = DeploymentConfigTestUtils.GetValidBaseConfig();
79+
config.SnapshotPath = snapshotPath;
80+
var errors = config.GetErrors().ToArray();
81+
82+
Assert.AreEqual(errors.Length, 1, "Failed: did not throw exactly one error.");
83+
Assert.IsTrue(errors[0].Contains("Snapshot"));
84+
Assert.IsTrue(errors[0].Contains(DeploymentConfigErrorTypes.NotFound));
85+
}
86+
87+
[TestCase("dev_login")]
88+
[TestCase("quinquagintaquadringentillionths")]
89+
public void BaseDeploymentConfig_does_not_throw_error_for_valid_tag(string validTag)
90+
{
91+
var config = DeploymentConfigTestUtils.GetValidBaseConfig();
92+
config.Tags.Add(validTag);
93+
94+
Assert.IsEmpty(config.GetErrors());
95+
}
96+
97+
[TestCase("_invalidtag")]
98+
[TestCase("f")]
99+
[TestCase("gg")]
100+
[TestCase("quinquagintaquadringentillionthss")]
101+
[TestCase("supercalifragilisticexpialidocious")]
102+
public void BaseDeploymentConfig_throws_error_for_invalid_tag(string invalidTag)
103+
{
104+
var config = DeploymentConfigTestUtils.GetValidBaseConfig();
105+
config.Tags.Add(invalidTag);
106+
var errors = config.GetErrors().ToArray();
107+
108+
Assert.AreEqual(errors.Length, 1, "Failed: did not throw exactly one error.");
109+
Assert.IsTrue(errors[0].Contains("Tag"));
110+
Assert.IsTrue(errors[0].Contains(DeploymentConfigErrorTypes.Invalid));
111+
}
112+
113+
[Test]
114+
public void BaseDeploymentConfig_throws_N_errors_for_N_invalid_tags()
115+
{
116+
var config = DeploymentConfigTestUtils.GetValidBaseConfig();
117+
118+
//5 invalid tags
119+
config.Tags.AddRange(new[]
120+
{
121+
"_invalidtag",
122+
"f",
123+
"gg",
124+
"quinquagintaquadringentillionthss",
125+
"supercalifragilisticexpialidocious"
126+
});
127+
128+
var errors = config.GetErrors().ToArray();
129+
130+
Assert.AreEqual(errors.Length, 5, "Failed: did not throw exactly five errors.");
131+
132+
foreach (var error in errors)
133+
{
134+
Assert.IsTrue(error.Contains("Tag"));
135+
Assert.IsTrue(error.Contains("invalid"));
136+
}
137+
}
138+
}
139+
}

0 commit comments

Comments
 (0)