-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ensure the default deployment name is a valid name. (#959)
* Ensure the default deployment name is a valid name.
- Loading branch information
Jim Przybylinski
authored
May 17, 2018
1 parent
c0100a4
commit 453a41b
Showing
9 changed files
with
178 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
GoogleCloudExtension/GoogleCloudExtensionUnitTests/Utils/GcpPublishStepsUtilsTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// Copyright 2018 Google Inc. All Rights Reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
using GoogleCloudExtension.Utils; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using System.Linq; | ||
|
||
namespace GoogleCloudExtensionUnitTests.Utils | ||
{ | ||
[TestClass] | ||
public class GcpPublishStepsUtilsTests | ||
{ | ||
[TestMethod] | ||
[DataRow(null)] | ||
[DataRow("")] | ||
[DataRow("already-kebob-case")] | ||
[DataRow("end-with-dash-")] | ||
public void TestToValid_NameUnchanged(string unchangingName) | ||
{ | ||
string result = GcpPublishStepsUtils.ToValidName(unchangingName); | ||
|
||
Assert.AreEqual(unchangingName, result); | ||
} | ||
|
||
[TestMethod] | ||
[DataRow("UpperCamelCase", "upper-camel-case")] | ||
[DataRow("many.(*)symbols!@$", "many----symbols---")] | ||
[DataRow("-start-with-dash", "start-with-dash")] | ||
[DataRow("@start-with-symbol", "start-with-symbol")] | ||
public void TestToValid_NameChange(string invalidName, string expectedResult) | ||
{ | ||
string result = GcpPublishStepsUtils.ToValidName(invalidName); | ||
|
||
Assert.AreEqual(expectedResult, result); | ||
} | ||
|
||
[TestMethod] | ||
public void TestToValid_NameTruncatesAt100Characters() | ||
{ | ||
string longString = string.Join("", Enumerable.Range(1, 200)); | ||
|
||
string result = GcpPublishStepsUtils.ToValidName(longString); | ||
|
||
Assert.IsTrue(result.Length == 100); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters