26 Commits

Author SHA1 Message Date
Jeff McCune
6a2a81e3fc compare: add not-backwards-compatible test case to verify spec 4 2025-05-17 23:04:32 -07:00
Jeff McCune
abb014ee48 compare: clarify doc comment and fix backwards compatibility test logic
- Replace 'a' with 'before' and 'b' with 'after' in BuildPlans doc comment for clarity
- Fix backwards compatibility test case by swapping before/after files:
  - before.yaml now correctly has fewer fields (older version)
  - after.yaml now correctly has more fields (newer version with enhancements)
- Update comparison logic to filter fields from after that don't exist in before
- This correctly implements spec 4: after may have fields missing from before when backwards compatible

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-05-17 22:42:31 -07:00
Jeff McCune
57789b48e5 compare: add test for backwards compatibility spec requirement
- Add test case BuildPlan_4 for BuildPlan spec 4: b may have fields missing from a if isBackwardsCompatible is true
- Implement backwards compatibility logic in comparison functions
  - Add filterToCommonFields() to filter fields based on what exists in both structures
  - Update compareDocumentLists() and compareStructures() to accept isBackwardsCompatible parameter
  - When backwards compatible mode is enabled, only compare fields that exist in both structures
- Update test framework to support isBackwardsCompatible field in test cases
- Test verifies that missing labels, annotations, and nested fields don't cause failure in backwards compatible mode

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-05-17 22:19:56 -07:00
Jeff McCune
2b89b45fc5 compare: add comprehensive BuildPlan spec test coverage
- Reference BuildPlan spec items in test names (BuildPlan_3.1, BuildPlanFile_1, etc.)
- Add missing test cases for BuildPlan spec requirements:
  - BuildPlanFile_2: each object matches exactly one unique object
  - BuildPlan_5: fields in 'a' must exist in 'b'
  - BuildPlan_6.1-6.3: null/empty/missing field equivalence
  - BuildPlanValid_1-2: duplicate objects and same metadata.name
- Implement null/empty/missing field equivalence (spec 6)
  - Add normalizeStructure() to handle spec 6 requirements
  - Ensure null, [], and missing fields are treated as equivalent
- Update test messages to clarify spec coverage intent

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-05-17 22:01:13 -07:00
Jeff McCune
a0f6776358 compare: align test cases with BuildPlans specification
Add comprehensive test cases to cover all specification requirements:
- File spec requirement 1: equal number of BuildPlans
- BuildPlan spec 1&2: all fields must be equivalent
- BuildPlan spec 3: nested objects must match recursively
- BuildPlan spec 4: exact field value matching with exceptions
- BuildPlan spec 4.1: unordered spec.artifacts list
- BuildPlan spec 4.2: key order irrelevance
- Toleration 1: multiple identical BuildPlans treated as unique
- Toleration 2: multiple BuildPlans with same metadata.name

Update existing test names and messages to clearly reference the specific specification requirements they validate.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-05-17 21:02:44 -07:00
Jeff McCune
b0d5fe0072 compare: add v1alpha6 compiler test case
This patch adds the output of the new stdio concurrenet compiler being
developed for v1alpha6 as after, which is semantically equivalent to the
v0.104.1 v1alpha5 holos show buildplans output.

Note the field orders and relative object order in the stream is quite
different.
2025-05-17 16:41:48 -07:00
Jeff McCune
bc8ad22492 compare: add test case for annotations 2025-05-17 14:47:50 -07:00
Jeff McCune
0e9b02f337 compare: add test case for same object dupliacted in after
When the objects in the before stream differ only by a deeply nested
field value, the second object in before should not match any object in
after.
2025-05-17 13:57:23 -07:00
Jeff McCune
04f1a21ee8 compare: add test case for two out of sequence objects 2025-05-17 13:36:53 -07:00
Jeff McCune
2f77b1c09f compare: implement labels test case with expectedErrors list support
- Refactor test infrastructure to support expectedErrors as a list instead of single expectedError
- Implement generic field difference extraction for any object additions
- Update extractTestErrors method to handle arbitrary field additions
- Migrate all test cases from expectedError to expectedErrors format
- Maintain backward compatibility with existing test expectations
- Add support for detecting and formatting any field additions in diff output
- Clean up go-cmp type annotations in error messages for better readability

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-05-17 13:11:05 -07:00
Jeff McCune
e2ea6deda2 compare: add test case for arbitrary labels 2025-05-17 12:59:15 -07:00
Jeff McCune
9702efca70 compare: add testcase when after is a superset of before 2025-05-17 12:36:11 -07:00
Jeff McCune
da7430e741 compare: fixup different labels test case name 2025-05-17 11:46:05 -07:00
Jeff McCune
48a40c808f compare: add testcase when labels are different 2025-05-17 11:41:08 -07:00
Jeff McCune
d83765e980 compare: add out of order artifacts test case 2025-05-17 11:30:45 -07:00
Jeff McCune
6ca6080a3f compare: add full buildplan test case 2025-05-17 11:27:08 -07:00
Jeff McCune
5c1689b52b compare: add duplicate name test case 2025-05-17 11:19:16 -07:00
Jeff McCune
cd33f7b1dc compare: add name field to all test cases
Implement the name field for all test cases to provide more descriptive
test names in the test output. This improves test readability and
maintenance.

- Add name field to testCase struct
- Update test logic to use name field when provided
- Add descriptive names to all test cases
- Maintain nested test structure with directory/name hierarchy

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-05-17 11:13:43 -07:00
Jeff McCune
80559b7ca6 compare: add test case name field example 2025-05-17 11:11:16 -07:00
Jeff McCune
de9b177c71 compare: add descriptive messages to test cases
Enhance test cases with descriptive messages that explain what each
test is verifying. These messages are displayed when tests fail,
improving debugging experience.

- Add msg field to testCase struct
- Update all testcase.json files with descriptive messages
- Use messages in test assertions for better failure output
- Ensure all tests continue to pass with new structure

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-05-17 11:06:09 -07:00
Jeff McCune
c9994a0851 compare: add out of order test case 2025-05-17 10:54:14 -07:00
Jeff McCune
46cb7f5d29 compare: add streams test case 2025-05-17 10:48:53 -07:00
Jeff McCune
19690d760a compare: add minimal equal test case 2025-05-17 10:11:28 -07:00
Jeff McCune
35ede4293b Rename empty-files test case to empty
Simplify test case directory name from empty-files to empty.

- Rename testdata/empty-files/ to testdata/empty/
- Test continues to pass with cleaner naming

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-05-17 09:59:58 -07:00
Jeff McCune
1b499b1ab6 Rename want.json to testcase.json in compare package
Rename test configuration files from want.json to testcase.json for
better clarity of purpose. Updated test code to match the new naming.

- Rename want.json to testcase.json in testdata
- Update variable names from wantData to testcaseData
- Update error messages to reference testcase.json

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-05-17 09:58:03 -07:00
Jeff McCune
6a3b8da7f2 Refactor compare buildplans tests to package level
Move compare functionality from CLI package to dedicated internal/compare
package for better separation of concerns. CLI now acts as a thin wrapper
calling the compare package implementation.

- Create internal/compare package with Comparer type
- Move tests from CLI to compare package
- Update test fixtures path to testdata directory
- Replace CLI error with errors.NotImplemented()
- Clean up redundant test files from CLI package

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-05-17 06:59:48 -07:00