8000 Add missing fields to SpecReport JSON marshalling, and add unit test by danwinship · Pull Request #1687 · onsi/ginkgo · GitHub
[go: up one dir, main page]

Skip to content

Add missing fields to SpecReport JSON marshalling, and add unit test - #1687

Merged
onsi merged 1 commit into
onsi:masterfrom
danwinship:specreport-json
Oct 9, 2026
Merged

onsi merged 1 commit into
onsi:masterfrom
danwinship:specreport-json

Conversation

@danwinship
Copy link
Copy Markdown
Contributor

Trying to do something with kubernetes's e2e.test --spec-dump and discovered that it wasn't dumping LeafNodeComponentSemVerConstraints. It was an easy fix, but then when I updated the unit test to try to make sure we didn't miss out on any other fields in the future, I discovered that we were already missing a bunch of other fields...

If the goal is just "don't output an empty Failure" there's probably a better way to write this... but for now, this at least adds all the missing fields, and makes sure we don't miss any more in the future.

@pohly pohly left a comment
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.

Looks good to me, cc @onsi

Comment thread types/types_test.go
Comment on lines +390 to +392
for i := range reportType.NumField() {
if reportVal.Field(i).IsZero() {
missingFields = append(missingFields, reportType.Field(i).Name)
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.

Nit:

Suggested change
for i := range reportType.NumField() {
if reportVal.Field(i).IsZero() {
missingFields = append(missingFields, reportType.Field(i).Name)
for field := range reportType.Fields() {
if field.IsZero() {
missingFields = append(missingFields, field.Name)

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.

No, that's trying to call a reflect.Value method on a reflect.Type. As far as I could tell, if you want both .Name and .IsZero(), you need to iterate both objects together.

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.

Ah, I see now - I missed the part about needing info from both.

@onsi
onsi merged commit 6c652a2 into onsi:master Oct 9, 2026
3 checks passed
@onsi
onsi commented Oct 9, 2026
Copy link
Copy Markdown
Owner

looks great thanks!

@danwinship
danwinship deleted the specreport-json branch October 9, 2026 12:36
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.

3 participants

0