-
Notifications
You must be signed in to change notification settings - Fork 68
fix: [CI-19828] Throw error instead of warning in case of directory u… #200
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ebtasam-faridy
wants to merge
4
commits into
drone-plugins:master
Choose a base branch
from
ebtasam-faridy:CI-19828
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
ca134c7
fix: [CI-19828] Throw error instead of warning in case of directory u…
ebtasam-faridy 29e146c
fix: [CI-19828] Throw error instead of warning in case of directory u…
ebtasam-faridy 9f24313
fix: [CI-19828] Pr comments skip in case of file not exist or failure…
ebtasam-faridy 7d966ed
fix: [CI-19828] adding test cases
ebtasam-faridy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,91 @@ | ||
| package main | ||
|
|
||
| import ( | ||
| "os" | ||
| "path/filepath" | ||
| "strings" | ||
| "testing" | ||
| ) | ||
|
|
||
| func TestIsDir(t *testing.T) { | ||
| // Create temporary directory for testing | ||
| tmpDir := t.TempDir() | ||
| testDir := filepath.Join(tmpDir, "testdir") | ||
| testFile := filepath.Join(tmpDir, "testfile.txt") | ||
|
|
||
| // Create a test directory | ||
| err := os.Mkdir(testDir, 0755) | ||
| if err != nil { | ||
| t.Fatalf("Failed to create test directory: %v", err) | ||
| } | ||
|
|
||
| // Create a test file | ||
| file, err := os.Create(testFile) | ||
| if err != nil { | ||
| t.Fatalf("Failed to create test file: %v", err) | ||
| } | ||
| file.Close() | ||
|
|
||
| tests := []struct { | ||
| name string | ||
| source string | ||
| matches []string | ||
| expectError bool | ||
| expectSkip bool | ||
| errorContains string | ||
| }{ | ||
| { | ||
| name: "file should not error", | ||
| source: testFile, | ||
| matches: []string{testFile}, | ||
| expectError: false, | ||
| expectSkip: false, | ||
| }, | ||
| { | ||
| name: "directory without glob should error", | ||
| source: testDir, | ||
| matches: []string{testDir}, | ||
| expectError: true, | ||
| expectSkip: false, | ||
| errorContains: "specified without glob pattern", | ||
| }, | ||
| { | ||
| name: "directory with glob pattern should skip", | ||
| source: testDir, | ||
| matches: []string{testDir + "/file1.txt", testDir + "/file2.txt"}, | ||
| expectError: false, | ||
| expectSkip: true, | ||
| }, | ||
| { | ||
| name: "non-existent path should skip", | ||
| source: "/non/existent/path", | ||
| matches: []string{}, | ||
| expectError: false, | ||
| expectSkip: true, | ||
| }, | ||
| } | ||
|
|
||
| for _, tc := range tests { | ||
| t.Run(tc.name, func(t *testing.T) { | ||
| err := isDir(tc.source, tc.matches) | ||
|
|
||
| if tc.expectError { | ||
| if err == nil { | ||
| t.Errorf("Expected error but got none") | ||
| } else if err == errSkip { | ||
| t.Errorf("Expected fatal error but got skip error") | ||
| } else if tc.errorContains != "" && !strings.Contains(err.Error(), tc.errorContains) { | ||
| t.Errorf("Expected error to contain '%s', but got: %v", tc.errorContains, err) | ||
| } | ||
| } else if tc.expectSkip { | ||
| if err != errSkip { | ||
| t.Errorf("Expected skip error but got: %v", err) | ||
| } | ||
| } else { | ||
| if err != nil { | ||
| t.Errorf("Expected no error but got: %v", err) | ||
| } | ||
| } | ||
| }) | ||
| } | ||
| } |
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -128,3 +128,4 @@ func TestResolveSource(t *testing.T) { | |
| } | ||
| } | ||
| } | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.