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

refactor: unify how executor tests are written #2042

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

Conversation

pd93
Copy link
Member

@pd93 pd93 commented Feb 5, 2025

Currently we have a couple of different ways of writing tests in task_test.go. Some use the the fileContentTest template, some directly craft and run an Executor.

This is a draft PR for a new test type called TaskTest. The idea is that this is a "do everything" testing suite for the Executor. Instead of relying on handcrafted outputs written inside the go file or creating special taskfiles that output content to a file, it uses goldie to create test "golden files". The API uses functional options and post-processing functions to setup tests.

As there are a lot of tests in here, I wanted to gather some feedback on the approach before I continue. I'm also interested in splitting this file up as its currently at over 3400 lines long, but looking for some opinions on the best way to do this. I had considered renaming the existing testdata folder to tests and moving these tests there alongside their taskfiles, but this doesn't feel very "go-like"?

@pd93 pd93 force-pushed the task-tests branch 3 times, most recently from 21af7c7 to 0d962cd Compare February 8, 2025 16:42
@vmaerten
Copy link
Member

Hey @pd93
First of all thanks for doing this !! I had to write / modify some tests recently and it's painful

I'm also interested in splitting this file up as its currently at over 3400 lines long, but looking for some opinions on the best way to do this. I had considered renaming the existing testdata folder to tests and moving these tests there alongside their taskfiles, but this doesn't feel very "go-like"?

I totally agree with you about splitting this file. It may not be very "Go-like," but it makes everything more readable. Having everything in one place is convenient. Every time I work on tests, I find it somewhat difficult to switch between the test file and the testdata directory.

Also, having the golden file named this way makes it easy to identify.

Last but not least, the diff is amazing :
image

At work, we use cupaloy, which is also a great tool for handling snapshots.

I am totally in!

@andreynering andreynering self-requested a review February 11, 2025 20:43
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.

2 participants