-
Notifications
You must be signed in to change notification settings - Fork 10
feature: cli-config.yaml also has provider/org/repo info CF-1766 #166
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
Merged
Merged
Changes from all commits
Commits
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 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
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 |
|---|---|---|
|
|
@@ -2,7 +2,6 @@ package cmd | |
|
|
||
| import ( | ||
| "codacy/cli-v2/cmd/configsetup" | ||
| "codacy/cli-v2/config" | ||
| "codacy/cli-v2/constants" | ||
| "codacy/cli-v2/domain" | ||
| "os" | ||
|
|
@@ -182,77 +181,3 @@ func TestCleanConfigDirectory(t *testing.T) { | |
| assert.NoError(t, err) | ||
| assert.Equal(t, 0, len(files), "Expected 0 files after cleaning, got %d", len(files)) | ||
| } | ||
|
|
||
| func TestInitCommand_NoToken(t *testing.T) { | ||
| tempDir := t.TempDir() | ||
| originalWD, err := os.Getwd() | ||
| assert.NoError(t, err, "Failed to get current working directory") | ||
| defer os.Chdir(originalWD) | ||
|
|
||
| // Use the real plugins/tools/semgrep/rules.yaml file | ||
| rulesPath := filepath.Join("..", "plugins", "tools", "semgrep", "rules.yaml") | ||
| if _, err := os.Stat(rulesPath); os.IsNotExist(err) { | ||
| t.Skipf("plugins/tools/semgrep/rules.yaml not found at %s; skipping test", rulesPath) | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Line that made the tests skip always. |
||
| } | ||
|
|
||
| // Change to the temp directory to simulate a new project | ||
| err = os.Chdir(tempDir) | ||
| assert.NoError(t, err, "Failed to change working directory to tempDir") | ||
|
|
||
| // Simulate running init with no token | ||
| currentInitFlags := domain.InitFlags{ | ||
| ApiToken: "", | ||
| Provider: "", | ||
| Organization: "", | ||
| Repository: "", | ||
| } | ||
|
|
||
| // Call the Run logic from initCmd | ||
| if err := config.Config.CreateLocalCodacyDir(); err != nil { | ||
| t.Fatalf("Failed to create local codacy directory: %v", err) | ||
| } | ||
|
|
||
| toolsConfigDir := config.Config.ToolsConfigDirectory() | ||
| if err := os.MkdirAll(toolsConfigDir, constants.DefaultDirPerms); err != nil { | ||
| t.Fatalf("Failed to create tools-configs directory: %v", err) | ||
| } | ||
|
|
||
| cliLocalMode := len(currentInitFlags.ApiToken) == 0 | ||
| if cliLocalMode { | ||
| noTools := []domain.Tool{} | ||
| err := configsetup.CreateConfigurationFiles(noTools, cliLocalMode) | ||
| assert.NoError(t, err, "CreateConfigurationFiles should not return an error") | ||
| if err := configsetup.BuildDefaultConfigurationFiles(toolsConfigDir, currentInitFlags); err != nil { | ||
| t.Fatalf("Failed to build default configuration files: %v", err) | ||
| } | ||
| if err := configsetup.CreateLanguagesConfigFileLocal(toolsConfigDir); err != nil { | ||
| t.Fatalf("Failed to create languages config file: %v", err) | ||
| } | ||
| } | ||
|
|
||
| // Assert that the expected config files are created | ||
| codacyDir := config.Config.LocalCodacyDirectory() | ||
| expectedFiles := []string{ | ||
| filepath.Join("tools-configs", "eslint.config.mjs"), | ||
| filepath.Join("tools-configs", "trivy.yaml"), | ||
| filepath.Join("tools-configs", "ruleset.xml"), | ||
| filepath.Join("tools-configs", "pylint.rc"), | ||
| filepath.Join("tools-configs", "analysis_options.yaml"), | ||
| filepath.Join("tools-configs", "semgrep.yaml"), | ||
| filepath.Join("tools-configs", "lizard.yaml"), | ||
| "codacy.yaml", | ||
| "cli-config.yaml", | ||
| filepath.Join("tools-configs", "languages-config.yaml"), | ||
| ".gitignore", | ||
| } | ||
|
|
||
| for _, file := range expectedFiles { | ||
| filePath := filepath.Join(codacyDir, file) | ||
| if file == ".gitignore" { | ||
| filePath = filepath.Join(config.Config.LocalCodacyDirectory(), file) | ||
| } | ||
|
|
||
| _, err := os.Stat(filePath) | ||
| assert.NoError(t, err, "Expected config file %s to be created at %s", file, filePath) | ||
| } | ||
| } | ||
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 |
|---|---|---|
| @@ -1 +1,4 @@ | ||
| mode: remote | ||
| mode: remote | ||
| provider: gh | ||
| organization: troubleshoot-codacy-dev | ||
| repository: codacy-cli-test |
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.
Removing these tests, they are always being skipped. Integration tests cover these scenarios.