Skip to content

Improve SSE tests#1546

Merged
aibrahim-oai merged 4 commits intomainfrom
fqhl18-codex/implement-extensible-data-driven-tests
Jul 12, 2025
Merged

Improve SSE tests#1546
aibrahim-oai merged 4 commits intomainfrom
fqhl18-codex/implement-extensible-data-driven-tests

Conversation

@aibrahim-oai
Copy link
Copy Markdown
Collaborator

Summary

  • support fixture-based SSE data in tests
  • add helpers to load SSE JSON fixtures
  • add table-driven SSE unit tests
  • let integration tests use fixture loading
  • fix clippy errors from format! calls

Testing

  • cargo clippy --tests
  • cargo test --workspace --exclude codex-linux-sandbox

https://chatgpt.com/codex/tasks/task_i_68717468c3e48321b51c9ecac6ba0f09

@aibrahim-oai aibrahim-oai added the codex Label used by connector to tag PRs that have been reviewed by Codex label Jul 11, 2025 — with ChatGPT Codex Connector
@aibrahim-oai aibrahim-oai requested review from bolinfest and gpeal July 11, 2025 22:25
@bolinfest bolinfest added the code-review Issues relating to code reviews performed by codex label Jul 12, 2025
@github-actions github-actions Bot added codex-review-in-progress and removed code-review Issues relating to code reviews performed by codex labels Jul 12, 2025
@github-actions
Copy link
Copy Markdown
Contributor

PR Summary

Adds an extensible, data-driven test framework for codex-rs SSE handling—new JSON fixtures, helper utilities, and table-driven Rust tests—alongside a sizeable drop of the Codex CLI, dev-container, and CI/GitHub-Action configs.

Review

Solid improvement to test coverage and developer tooling! A few tidy-ups would make it even smoother:

  • Binary assets (.gif, large PNGs) inflate the repo—could they move to LFS or be linked externally?
  • New tests use mixed naming (table_driven_event_kinds vs. previous_response_id); consider consistent snake_case.
  • test_support.rs utilities look handy—export only what’s needed (pub(crate)), or hide behind a #[cfg(test)] to avoid accidental public surface.
  • CI config grows; double-check workflow runtime to keep build times reasonable.
  • README briefly mentions the new CLI—adding install/run steps would help first-time contributors.

Overall, great addition; just minor polish needed before merge.


View workflow run

Comment thread codex-rs/core/src/client.rs Outdated

#[tokio::test]
async fn table_driven_event_kinds() {
struct Case {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I don't know why this fields weird to me (maybe because case is a keyword in so many other languages), but I feel like TestCase is a better name.

}
});

let cases = vec![
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Admittedly I have not used this crate before, but https://crates.io/crates/test_case seems worth considering.

Alternatively, turn all of this into a helper function that takes a TestCase and then make one #[test] for each so that all of the test cases are always run independently so you can see if any permutation of them fail instead of the first one in the loop.

}

#[tokio::test]
async fn table_driven_event_kinds() {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

docstring?

struct Case {
name: &'static str,
event: serde_json::Value,
expect_first: fn(&ResponseEvent) -> bool,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

If you do the helper function thing described below, perhaps you want two structs for the function: one for the args to drive the test (name, event) and the other with the expected values (expect_first, expected_len)?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Also, you could make expect_first an enum that has an instance method fn(&ResponseEvent) -> bool or something like that.

Comment thread codex-rs/core/tests/test_support.rs Outdated
/// with only a `type` field results in an event with no `data:` section. This
/// makes it trivial to extend the fixtures as OpenAI adds new event kinds or
/// fields.
#[allow(dead_code)]
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This is no longer dead code, right?

Comment thread codex-rs/core/tests/test_support.rs Outdated
/// Like [`load_sse_fixture`] but substitutes the placeholder `__ID__` with the
/// provided identifier before parsing. Useful when the test needs unique
/// `response_id` values.
#[allow(dead_code)]
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

And this?

@aibrahim-oai aibrahim-oai merged commit c46bb67 into main Jul 12, 2025
4 of 11 checks passed
@aibrahim-oai aibrahim-oai deleted the fqhl18-codex/implement-extensible-data-driven-tests branch July 12, 2025 23:53
@github-actions github-actions Bot locked and limited conversation to collaborators Jul 12, 2025
@aibrahim-oai aibrahim-oai restored the fqhl18-codex/implement-extensible-data-driven-tests branch July 12, 2025 23:54
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

codex Label used by connector to tag PRs that have been reviewed by Codex

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants