Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't construct webhook objects using literals #170

Open
mattdee123 opened this issue Jan 8, 2024 · 1 comment
Open

Can't construct webhook objects using literals #170

mattdee123 opened this issue Jan 8, 2024 · 1 comment

Comments

@mattdee123
Copy link

Describe the bug
In order to write a test for a webhook handler, I would like to create sample webhook events, but cannot do so with a struct literal expression.

To Reproduce
Try to construct the following object:

&buildkite.JobFinishedEvent{Pipeline: &buildkite.Pipeline{}}

This gives a compiler error. However,

event := &buildkite.JobFinishedEvent{}
event.Pipeline = &buildkite.Pipeline{}

Expected behavior
It would be nice if the above pattern, or something similar, could be used to construct test objects.

Additional context

This happens because the type is

type JobFinishedEvent struct {
	jobEvent
}

and the embedded unexported field means we can't use a struct literal to create it, which is slightly annoying when writing tests.

@mattdee123 mattdee123 added the bug label Jan 8, 2024
@jradtilbrook
Copy link
Contributor

Hi @mattdee123 thanks for raising this usability improvement. I'm wondering if we should do away with the embedding and just us a type alias. I'm unsure the reasoning why embedding was used in the first place.

We'll investigate some options here, but I don't think this is a bug and there is a simple workaround for it at the moment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants