Skip to content

batches/executor: fix TestCreateChangesetSpecs

Warren Gifford requested to merge aharvey/fix-test-ccs into main

Created by: LawnGnome

The specWith() and taskWith() helpers inadvertently mutate defaultChangesetSpec and defaultTask fields, rather than isolating their changes to just the returned spec and task, respectively. Practically speaking, this means that all tests have the same spec and task based on the last element in the tests slice, which means that all the test cases end up testing the same, identical thing.

Instead, we must deep copy the spec and task before invoking the mutator function. I've chosen to pull in a third party package (specifically, copystructure) for this: naïvely using JSON to marshal and unmarshal doesn't work because most of the interesting task fields are excluded when marshalled to JSON.

Merge request reports

Loading