riverqueue / river

Fast and reliable background jobs in Go
https://riverqueue.com
Mozilla Public License 2.0
3.22k stars 86 forks source link

Mistake in testing docs? #349

Closed assembly-winston closed 3 months ago

assembly-winston commented 3 months ago

In the last section under Test Helpers, it looks like there is a typo.

Workers in River are plain old Go structs, and no special testing utilities are provided for them. They're testable by initializing a work, invoking its Work function, and checking against the results:

func (w *SortWorker) Work(ctx context.Context, job *river.Job[SortArgs]) error {
    sort.Strings(job.Args.Strings)
    fmt.Printf("Sorted strings: %+v\n", job.Args.Strings)
    return nil
}

func TestSortWorker(t *testing.T) {
    err := (&SortWorker{}).Run(ctx, &river.Job{Args: JobArgs{
    //                     ^ shouldn't this say *Work*, not *Run*
        Strings: []string{
          "whale", "tiger", "bear",
        },
    }
    if err != nil {
        // handle error
    }
}
bgentry commented 3 months ago

Thank you, fixed and will be deployed shortly 🙏🏻