-
Notifications
You must be signed in to change notification settings - Fork 219
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4540 from microsoft/feat/go_escape_special_filenames
Escape all special suffixes in go file names
- Loading branch information
Showing
4 changed files
with
117 additions
and
2 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
42 changes: 42 additions & 0 deletions
42
tests/Kiota.Builder.Tests/PathSegmenters/GoPathSegmenterTests.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,42 @@ | ||
using Kiota.Builder.CodeDOM; | ||
using Kiota.Builder.PathSegmenters; | ||
using Xunit; | ||
|
||
namespace Kiota.Builder.Tests.PathSegmenters; | ||
|
||
public class GoPathSegmenterTests | ||
{ | ||
private readonly GoPathSegmenter segmenter; | ||
public GoPathSegmenterTests() | ||
{ | ||
segmenter = new GoPathSegmenter("D:\\source\\repos\\kiota-sample", "client"); | ||
} | ||
|
||
[Fact] | ||
public void GoPathSegmenterGeneratesCorrectFileName() | ||
{ | ||
var fileName = segmenter.NormalizeFileName(new CodeClass | ||
{ | ||
Name = "testClass" | ||
}); | ||
Assert.Equal("test_class", fileName); // file name should be snake case | ||
} | ||
|
||
[Fact] | ||
public void GoPathSegmenterGeneratesEscapedSpecialClassName() | ||
{ | ||
var fileName = segmenter.NormalizeFileName(new CodeClass | ||
{ | ||
Name = "adminWindows" | ||
}); | ||
Assert.Equal("admin_windows_escaped", fileName); // file name should be snake case and escaped | ||
} | ||
|
||
[Fact] | ||
public void GoPathSegmenterGeneratesNamespaceFolderName() | ||
{ | ||
var namespaceName = "Microsoft.Graph"; | ||
var normalizedNamespace = segmenter.NormalizeNamespaceSegment(namespaceName); | ||
Assert.Equal("microsoft.graph", normalizedNamespace);// the file name should be lower case | ||
} | ||
} |