fabric8-services / fabric8-wit

wit stands for Work Item Tracker
http://devdoc.almighty.io/
Apache License 2.0
45 stars 86 forks source link

Cleanup golden files comparison and generation by introducing compareOptions #2354

Closed kwk closed 5 years ago

kwk commented 5 years ago

Before we used to have a list of booleans in order to configure the comparison and generation of golden files. Now we have a defined set of comparison options:

// compareOptions define how the comparison and golden file generation will take
// place
type compareOptions struct {
    // Whether or not to ignore UUIDs when comparing or writing the golden file
    // to disk
    UUIDAgnostic bool
    // Whether or not to ignore date/times when comparing or writing the golden
    // file to disk
    DateTimeAgnostic bool
    // Whether or not to call JSON marshall on the actual object before
    // comparing it against the content of the golden file or writing to the
    // golden file. If this is false, then we will treat the actual object as a
    // []byte or string.
    MarshalInputAsJSON bool
}

And a new compare function:

// compareWithGoldenOpts compares the actual object against the one from a
// golden file and let's you specify the options to be used for comparison and
// golden file production by hand. If the -update flag is given, that golden
// file is overwritten with the current actual object. When adding new tests you
// first must run them with the -update flag in order to create an initial
// golden version.
func compareWithGoldenOpts(t *testing.T, goldenFile string, actualObj interface{}, opts compareOptions) {
    require.NoError(t, testableCompareWithGolden(*updateGoldenFiles, goldenFile, actualObj, opts))
}

The changes being made to the rest of the code are just to there to keep the old compare functions in tact.

codecov[bot] commented 5 years ago

Codecov Report

Merging #2354 into master will decrease coverage by <.01%. The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2354      +/-   ##
==========================================
- Coverage   70.24%   70.24%   -0.01%     
==========================================
  Files         171      171              
  Lines       16625    16625              
==========================================
- Hits        11679    11678       -1     
  Misses       3821     3821              
- Partials     1125     1126       +1
Impacted Files Coverage Δ
controller/workitem.go 81.18% <0%> (-0.56%) :arrow_down:
workitem/workitem_repository.go 68.02% <0%> (+0.22%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 539f671...973c9c7. Read the comment docs.