Skip to content

chore(coderd/database/gen): improve generated fake stub #8088

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

Merged
merged 2 commits into from
Jun 19, 2023

Conversation

mafredri
Copy link
Member

@mafredri mafredri commented Jun 19, 2023

This PR improves the generated stub for dbfake with automatically added input validation for structs.

Before:

func (q *fakeQuerier) UpdateUserStatus(ctx context.Context, arg database.UpdateUserStatusParams) (database.User, error) {
	panic("Not implemented")
}

Now:

func (q *fakeQuerier) UpdateUserStatus(ctx context.Context, arg database.UpdateUserStatusParams) (database.User, error) {
	err := validateDatabaseType(arg)
	if err != nil {
		return database.User{}, err
	}

	panic("Not implemented")
}

There was probably a 100x smarter way to do this, but I wasn't smart. (Thought about using goreturns but didn't want to add another cli tool dependency that may conflict with goimports.)

@mafredri mafredri self-assigned this Jun 19, 2023
@mafredri mafredri requested a review from kylecarbs June 19, 2023 20:37
@mafredri mafredri changed the title chore(coderd/database/gen): Improve generated fake stub chore(coderd/database/gen): improve generated fake stub Jun 19, 2023
@mafredri mafredri merged commit af45e64 into main Jun 19, 2023
@mafredri mafredri deleted the mafredri/feat-improve-db-gen-fake branch June 19, 2023 21:05
@github-actions github-actions bot locked and limited conversation to collaborators Jun 19, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants