-
Notifications
You must be signed in to change notification settings - Fork 881
fix: list templates returns non-deprecated templates by default #17747
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
base: main
Are you sure you want to change the base?
Conversation
All contributors have signed the CLA ✍️ ✅ |
I have read the CLA Document and I hereby sign the CLA |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some style/organization comments, but I'm not sure about all the details of the preferred style for Go and tests here so curious what others have to say.
@@ -13021,7 +13021,7 @@ func (q *FakeQuerier) GetAuthorizedTemplates(ctx context.Context, arg database.G | |||
if arg.ExactName != "" && !strings.EqualFold(template.Name, arg.ExactName) { | |||
continue | |||
} | |||
if arg.Deprecated.Valid && arg.Deprecated.Bool == (template.Deprecated != "") { | |||
if arg.Deprecated.Valid && arg.Deprecated.Bool != (template.Deprecated != "") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think a comment here might be useful as well. Initially I wanted to suggest renaming arg.Deprecated
but I imagine that's a bigger change to roll out here. It's just not very nice to read this as something like
if arg.Deprecated.Valid && arg.IgnoreDeprecated && template.IsDeprecated
potentially the template struct could be refactored to have IsDeprecated
and DeprecatedMessage
as opposed to just having Deprecated
message whose value being "some string"
means the template is deprecated. Alternatively, the template could have a function IsDeprecated
?
@@ -873,6 +873,241 @@ func TestTemplates(t *testing.T) { | |||
require.Equal(t, tmpl.OrganizationName, org2.Name, "organization name on template") | |||
} | |||
}) | |||
|
|||
t.Run("ListEmpty", func(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can this new set of tests be table driven?
Description
Modifies the behaviour of the "list templates" API endpoints to return non-deprecated templates by default. Users can still query for deprecated templates by specifying the
deprecated=true
query parameter.Note: The deprecation feature is an enterprise-level feature
Affected Endpoints
Fixes #17565