-
-
Notifications
You must be signed in to change notification settings - Fork 162
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
Feat/save responses to output directory provided in new -srd flag and also print if in json if -json flag enabled fixes #128, #129, #130 #161
Open
kartikeysemwal
wants to merge
6
commits into
edoardottt:main
Choose a base branch
from
kartikeysemwal:feat/saveResponsesToOutputDir
base: main
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
6 commits
Select commit
Hold shift + click to select a range
7001edc
feat: responses saving in output folder (for -sr / -srd) and printing…
kartikeysemwal 6a6bfb4
refactoring the code changes
kartikeysemwal 3ad8778
fix: resolve linter and test case errors in workflow
kartikeysemwal 2bd3ae4
code review 1 changes
kartikeysemwal 0bfbd90
Add validation for output folder and enhance unit tests for edge cases
kartikeysemwal 34a15ff
linux OS build failure fixes
kartikeysemwal 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
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
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,55 @@ | ||
package input_test | ||
|
||
import ( | ||
"os" | ||
"path/filepath" | ||
"testing" | ||
|
||
"github.com/edoardottt/cariddi/pkg/input" | ||
) | ||
|
||
// TestCheckOutputPath tests the CheckOutputPath function for valid and invalid cases. | ||
func TestCheckOutputPath(t *testing.T) { | ||
// Create a temporary directory for testing | ||
tmpDir, err := os.MkdirTemp("", "testdir") | ||
defer os.RemoveAll(tmpDir) // Cleanup after test | ||
|
||
if err != nil { | ||
t.Fatalf("Failed to create temporary directory: %v", err) | ||
} | ||
|
||
// Valid case: Existing directory | ||
if !input.CheckOutputPath(tmpDir) { | ||
t.Errorf("CheckOutputPath(%s) = false; want true", tmpDir) | ||
} | ||
|
||
// Verify that the existing directory is still present after check | ||
_, err = os.Stat(tmpDir) | ||
if err != nil { | ||
t.Errorf("Existing directory %s should still be present after CheckOutputPath, but got error: %v", tmpDir, err) | ||
} | ||
|
||
// Cross-platform invalid cases | ||
invalidPaths := []string{ | ||
// Null character is invalid on all platforms | ||
filepath.Join(tmpDir, "invalid\000path"), | ||
} | ||
|
||
for _, invalidPath := range invalidPaths { | ||
if input.CheckOutputPath(invalidPath) { | ||
t.Errorf("CheckOutputPath(%s) = true; want false", invalidPath) | ||
} | ||
} | ||
|
||
// Valid case: New directory creation and cleanup | ||
newDir := filepath.Join(tmpDir, "newdir") | ||
if !input.CheckOutputPath(newDir) { | ||
t.Errorf("CheckOutputPath(%s) = false; want true", newDir) | ||
} | ||
|
||
// After check, the directory should be removed | ||
_, err = os.Stat(newDir) | ||
if err == nil || !os.IsNotExist(err) { | ||
t.Errorf("CheckOutputPath should remove the directory, but it still exists: %s", newDir) | ||
} | ||
} |
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should perform some tests. What if config.StoreResp is not specified?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With the two tags
-sr
and-srd
, there are four possible scenarios:Both
-sr
and-srd
are not set:OutputDir
will be set to its default value, and any other data that needs to be saved will be stored in this directory.Only
-sr
is set:OutputDir
, which will be the default directory.Only
-srd
is set:OutputDir
provided with the-srd
flag.Both
-sr
and-srd
are set:OutputDir
provided with the-srd
flag.In the config struct, I have used the
StoreResp
boolean as the key indicator of whether to store the response. Therefore, if the user provides only the-srd
flag, we will setStoreResp
totrue
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As far as I can understand point 3 and 4 are the same right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, just in point 3 we will set the StoreResp value to true