fix: include configured false booleans on organization_settings create#3570
fix: include configured false booleans on organization_settings create#3570somaz94 wants to merge 2 commits into
Conversation
|
👋 Hi, and thank you for this contribution! This repo is maintained by GitHub and community members on a best-effort basis. We'll get to this as soon as we can. You can help us prioritize by joining the discussion on open issues and PRs, sharing details on the changes you need, and reviewing other contributions. 🤖 This is an automated message. |
deiga
left a comment
There was a problem hiding this comment.
Nice work!
Could you refactor the unit tests to use a single testing function with a table for test cases?
There was a problem hiding this comment.
Please don't create a separate unit test file. Add the unit tests to the existing test file instead
| // attribute explicitly configured as false is included in the create payload. | ||
| // Regression test for the create path dropping false booleans (only fixed by a | ||
| // second apply through the update/HasChange path). | ||
| func TestBuildOrganizationSettingsCreateIncludesFalseBool(t *testing.T) { |
There was a problem hiding this comment.
Please use an underscore to separate function under test and the testcase in the name
20e8bf1 to
8cead3a
Compare
|
@deiga Thanks for the review — all three points addressed in
I also verified the table still has teeth: temporarily reverting the Rebased on latest |
Resolves #3493
Before the change?
On create,
github_organization_settingsdropped any boolean attributeexplicitly set to
false.buildOrganizationSettingsgated every fieldthrough
shouldInclude, which on the create path usedd.GetOk(name).GetOkreturnsok=falsefor aTypeBoolwhose value isfalse, so itcannot tell an explicit
falsefrom an unset field. The attribute was omittedfrom the create PATCH and GitHub applied its own default. A second
applyfixed it because the update path uses
d.HasChange.After the change?
On create,
shouldIncludenow always includesschema.TypeBoolattributes.Every bool in this resource declares a schema
Default, so it always has adefinite value (there is no meaningful "unset"), and
d.Get(name).(bool)(already used by the bool setters) sends the configured value correctly,
including
false. Non-boolean fields are unchanged (still included only whenconfigured), and the update path is untouched.
Note: since these bools declare a schema default, an unconfigured bool now also
sends its default explicitly on create. That value equals the schema default,
so the resulting state is identical, just made explicit.
Pull request checklist
github/resource_github_organization_settings_unit_test.gowith 5 unittests (create includes false/true bool, unset string still omitted,
enterprise-only bool gating, update path still gates on
HasChange). Runsunder
make testwith no org credentials. The false-bool test fails oncurrent
mainand passes with this fix.user-facing schema/docs change; the
buildOrganizationSettingsdoccomment was updated to match the new behavior).
Does this introduce a breaking change?