Skip to content

test sf cli#86

Merged
joroscoSF merged 8 commits intomainfrom
jo/test_sfcli
Apr 13, 2026
Merged

test sf cli#86
joroscoSF merged 8 commits intomainfrom
jo/test_sfcli

Conversation

@joroscoSF
Copy link
Copy Markdown
Contributor

No description provided.

(sfdx_dir / "alias.json").write_text(json.dumps(alias_data))

print("Fake SF CLI org auth written to ~/.sfdx/dev1@example.com.json")
PYEOF
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

For this command and all that follow- is there any reason to do them inline like this, as opposed to putting all of these into a python script or something and calling that from here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Migrating these commands to native Typescript will likely happen one at a time. Spelling them out this way allows for easy removal of the init commands as an example once that Typescript has been implemented leaving the other tests in place until they get migrated. Lastly if a particular test fails it's pretty easy to track down the where and why.

Probably some of the fake token logic and auth logic could be extracted for portability, interesting day after thought as I was pondering your questions.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It there a way to run all these tests locally, via act maybe?

with runner.isolated_filesystem():
os.makedirs(os.path.join("mydir", "payload"), exist_ok=True)
result = runner.invoke(init, ["--code-type", "script", "mydir"])
assert result.exit_code != 2, result.output
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Any reason not to result.exit_code == 2 on these?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Exit code 2 is Click's specific "bad usage" code, see here for reference.

Copy link
Copy Markdown
Contributor

@markdlv-sf markdlv-sf Apr 10, 2026

Choose a reason for hiding this comment

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

I guess what I'm thinking is, we could be hitting a different error "earlier" than we'd hit exit_code 2, potentially giving a false sense of confidence from these checks if some of them are returning different exit codes.

assert result.exit_code != 2, result.output
# Document the incompatibility: SF CLI passes a single "dep1,dep2" string,
# but run_entrypoint receives ("dep1,dep2",) — not ("dep1", "dep2").
assert mock_run.call_args[0][2] == ("dep1,dep2",)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is this expected / working?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It's important to note that this is a static test derived from reading the typescript code. In doing so I realized that I had messed up the --dependency flag in Typescript such that python wants multiple depenedency flags are required per dependency. Typescript allows for a single dependency flag with comma separated values. It's more of a reminder to me to go fix that but not super critical as it'll be a while before that replaces this in our environments.

# ── Mock Salesforce server + fake org auth ────────────────────────────────

- name: Start mock Salesforce server
run: python scripts/mock_sf_server.py &
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Will the & process be dangling if a test fails? Might want to add something to cleanup at the end, like:

  - name: Stop mock server
    if: always()
    run: kill $(cat /tmp/mock_server.pid) 2>/dev/null || true

@joroscoSF joroscoSF merged commit 884a9e0 into main Apr 13, 2026
3 checks passed
@joroscoSF joroscoSF deleted the jo/test_sfcli branch April 13, 2026 15:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants