Skip to content

Commit d04bd29

Browse files
Fix failing PowerShell module test to use actual gitignore content
Co-authored-by: surgupta-msft <[email protected]>
1 parent 738651f commit d04bd29

File tree

1 file changed

+6
-123
lines changed

1 file changed

+6
-123
lines changed

test/Cli/Func.UnitTests/ParserTests/GitIgnoreParserTests.cs

Lines changed: 6 additions & 123 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Copyright (c) .NET Foundation. All rights reserved.
22
// Licensed under the MIT License. See LICENSE in the project root for license information.
33

4+
using Azure.Functions.Cli;
45
using Azure.Functions.Cli.Common;
56
using FluentAssertions;
67
using Xunit;
@@ -149,140 +150,22 @@ public void DeniesShouldNotDenyNestedUnignoredFilesInIgnoredDirectories()
149150
}
150151

151152
[Fact]
152-
public void PowerShellModuleBinFoldersShouldBeHandledCorrectly()
153+
public async void PowerShellModuleBinFoldersShouldBeHandledCorrectly()
153154
{
154155
// Test the current gitignore content from the actual static resource
155-
var currentGitIgnore = @"bin
156-
obj
157-
csx
158-
.vs
159-
edge
160-
Publish
161-
162-
*.user
163-
*.suo
164-
*.cscfg
165-
*.Cache
166-
project.lock.json
167-
168-
/packages
169-
/TestResults
170-
171-
/tools/NuGet.exe
172-
/App_Data
173-
/secrets
174-
/data
175-
.secrets
176-
appsettings.json
177-
local.settings.json
178-
179-
node_modules
180-
dist
181-
182-
# Local python packages
183-
.python_packages/
184-
185-
# Python Environments
186-
.env
187-
.venv
188-
env/
189-
venv/
190-
ENV/
191-
env.bak/
192-
venv.bak/
193-
194-
# Byte-compiled / optimized / DLL files
195-
__pycache__/
196-
*.py[cod]
197-
*$py.class
198-
199-
# Azurite artifacts
200-
__blobstorage__
201-
__queuestorage__
202-
__azurite_db*__.json";
156+
var currentGitIgnore = await StaticResources.GitIgnore;
203157

204158
var currentParser = new GitIgnoreParser(currentGitIgnore);
205159

206160
// These paths should be ignored (regular bin folders)
207161
currentParser.Denies("bin/somefile.dll").Should().BeTrue();
208162
currentParser.Denies("src/bin/output.dll").Should().BeTrue();
209163

210-
// These PowerShell module paths are currently being ignored but shouldn't be
211-
// This demonstrates the current problem
212-
currentParser.Denies("Modules/Az.Storage/8.1.0/Storage.Autorest/bin/Az.Storage.private.dll").Should().BeTrue("Current implementation incorrectly ignores PowerShell module bin files");
213-
currentParser.Denies("Modules/SomeModule/1.0.0/bin/Module.dll").Should().BeTrue("Current implementation incorrectly ignores PowerShell module bin files");
164+
// These PowerShell module paths should NOT be ignored with the updated gitignore
165+
currentParser.Denies("Modules/Az.Storage/8.1.0/Storage.Autorest/bin/Az.Storage.private.dll").Should().BeFalse("PowerShell module bin files should not be ignored");
166+
currentParser.Denies("Modules/SomeModule/1.0.0/bin/Module.dll").Should().BeFalse("PowerShell module bin files should not be ignored");
214167

215168
// Non-bin files in modules should not be ignored
216169
currentParser.Denies("Modules/Az.Accounts/2.0.0/lib/netstandard2.0/Microsoft.Azure.dll").Should().BeFalse();
217-
}
218-
219-
[Fact]
220-
public void PowerShellModuleBinFoldersShouldNotBeIgnoredWithUpdatedGitIgnore()
221-
{
222-
// Test the proposed fix
223-
var updatedGitIgnore = @"bin/
224-
**/bin/
225-
!Modules/**
226-
obj
227-
csx
228-
.vs
229-
edge
230-
Publish
231-
232-
*.user
233-
*.suo
234-
*.cscfg
235-
*.Cache
236-
project.lock.json
237-
238-
/packages
239-
/TestResults
240-
241-
/tools/NuGet.exe
242-
/App_Data
243-
/secrets
244-
/data
245-
.secrets
246-
appsettings.json
247-
local.settings.json
248-
249-
node_modules
250-
dist
251-
252-
# Local python packages
253-
.python_packages/
254-
255-
# Python Environments
256-
.env
257-
.venv
258-
env/
259-
venv/
260-
ENV/
261-
env.bak/
262-
venv.bak/
263-
264-
# Byte-compiled / optimized / DLL files
265-
__pycache__/
266-
*.py[cod]
267-
*$py.class
268-
269-
# Azurite artifacts
270-
__blobstorage__
271-
__queuestorage__
272-
__azurite_db*__.json";
273-
274-
var updatedParser = new GitIgnoreParser(updatedGitIgnore);
275-
276-
// Regular bin folders should still be ignored
277-
updatedParser.Denies("bin/somefile.dll").Should().BeTrue();
278-
updatedParser.Denies("src/bin/output.dll").Should().BeTrue();
279-
280-
// PowerShell module bin folders should NOT be ignored (this is the fix)
281-
updatedParser.Denies("Modules/Az.Storage/8.1.0/Storage.Autorest/bin/Az.Storage.private.dll").Should().BeFalse("PowerShell module bin files should not be ignored");
282-
updatedParser.Denies("Modules/SomeModule/1.0.0/bin/Module.dll").Should().BeFalse("PowerShell module bin files should not be ignored");
283-
284-
// Non-bin files in modules should still not be ignored
285-
updatedParser.Denies("Modules/Az.Accounts/2.0.0/lib/netstandard2.0/Microsoft.Azure.dll").Should().BeFalse();
286-
}
287170
}
288171
}

0 commit comments

Comments
 (0)