Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions common/commands/configfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,8 @@ func handleInteractiveConfigCreation(configFile *ConfigFile, confType project.Pr
return configFile.setResolver(false)
case project.Npm:
return configFile.setDeployerResolver()
case project.Pnpm:
return configFile.setDeployerResolver()
case project.Nuget, project.Dotnet:
return configFile.configDotnet()
case project.Maven:
Expand Down
15 changes: 15 additions & 0 deletions common/commands/configfile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,21 @@ func TestNpmConfigFile(t *testing.T) {
assert.Equal(t, "repo-local", config.GetString("deployer.repo"))
}

func TestPnpmConfigFile(t *testing.T) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All 4 flags are set in this test, so isInteractive() returns falsehandleInteractiveConfigCreation exits at line 156 before reaching case project.Pnpm:. The new branch is not exercised by this test.

Suggested change
func TestPnpmConfigFile(t *testing.T) {
func TestPnpmConfigFile(t *testing.T) {
// Non-interactive path: all 4 flags set → Interactive=false → handleInteractiveConfigCreation bypassed.
// Set JFROG_CLI_HOME_DIR environment variable
tempDirPath := createTempEnv(t)

Review generated by xray-pr-review

tempDirPath := createTempEnv(t)
defer testsutils.RemoveAllAndAssert(t, tempDirPath)

context := createContext(t, resolutionServerId+"=relServer", resolutionRepo+"=repo", deploymentServerId+"=depServer", deploymentRepo+"=repo-local")
err := CreateBuildConfig(context, project.Pnpm)
assert.NoError(t, err)

config := checkCommonAndGetConfiguration(t, project.Pnpm.String(), tempDirPath)
assert.Equal(t, "relServer", config.GetString("resolver.serverId"))
assert.Equal(t, "repo", config.GetString("resolver.repo"))
assert.Equal(t, "depServer", config.GetString("deployer.serverId"))
assert.Equal(t, "repo-local", config.GetString("deployer.repo"))
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The file already has 4 near-identical WithDefaultServerId functions (Go:47, Pip:85, Pipenv:125, Npm:196) — adding a 5th extends a Hard Rule 5 #1 violation (3+ near-identical → table-driven). Consider collapsing all five into a single table-driven test and adding pnpm as a row:

func TestConfigFileWithDefaultServerId(t *testing.T) {
    types := []project.ProjectType{
        project.Go, project.Pip, project.Pipenv, project.Npm, project.Pnpm,
    }
    for _, confType := range types {
        t.Run(confType.String(), func(t *testing.T) {
            cleanUp, err := tests.ConfigTestServer(t)
            assert.NoError(t, err)
            defer cleanUp()

            context := createContext(t, resolutionRepo+"=repo", deploymentRepo+"=repo-local")
            err = CreateBuildConfig(context, confType)
            assert.NoError(t, err)

            config := checkCommonAndGetConfiguration(t, confType.String(), os.Getenv(coreutils.HomeDir))
            assert.Equal(t, "test", config.GetString("resolver.serverId"))
            assert.Equal(t, "repo", config.GetString("resolver.repo"))
            assert.Equal(t, "test", config.GetString("deployer.serverId"))
            assert.Equal(t, "repo-local", config.GetString("deployer.repo"))
        })
    }
}

Is this PR the right scope for the refactor, or should it be a follow-up?


Review generated by xray-pr-review


func TestRubyConfigFile(t *testing.T) {
// Set JFROG_CLI_HOME_DIR environment variable
tempDirPath := createTempEnv(t)
Expand Down
Loading