Debian Codegraph @

v2/options.go

raw symbols SCIP
1 package goldie
2
3 import "os"
4
5 // WithFixtureDir sets the fixture directory.
6 //
7 // Defaults to `testdata`
8 func (g *Goldie) WithFixtureDir(dir string) error {
9 g.fixtureDir = dir
10 return nil
11 }
12
13 // WithNameSuffix sets the file suffix to be used for the golden file.
14 //
15 // Defaults to `.golden`
16 func (g *Goldie) WithNameSuffix(suffix string) error {
17 g.fileNameSuffix = suffix
18 return nil
19 }
20
21 // WithFilePerms sets the file permissions on the golden files that are
22 // created.
23 //
24 // Defaults to 0644.
25 func (g *Goldie) WithFilePerms(mode os.FileMode) error {
26 g.filePerms = mode
27 return nil
28 }
29
30 // WithDirPerms sets the directory permissions for the directories in which the
31 // golden files are created.
32 //
33 // Defaults to 0755.
34 func (g *Goldie) WithDirPerms(mode os.FileMode) error {
35 g.dirPerms = mode
36 return nil
37 }
38
39 // WithDiffEngine sets the `diff` engine that will be used to generate the
40 // `diff` text.
41 func (g *Goldie) WithDiffEngine(engine DiffEngine) error {
42 g.diffEngine = engine
43 return nil
44 }
45
46 // WithDiffFn sets the `diff` engine to be a function that implements the
47 // DiffFn signature. This allows for any customized diff logic you would like
48 // to create.
49 func (g *Goldie) WithDiffFn(fn DiffFn) error {
50 g.diffFn = fn
51 return nil
52 }
53
54 // WithIgnoreTemplateErrors allows template processing to ignore any variables
55 // in the template that do not have corresponding data values passed in.
56 //
57 // Default value is false.
58 func (g *Goldie) WithIgnoreTemplateErrors(ignoreErrors bool) error {
59 g.ignoreTemplateErrors = ignoreErrors
60 return nil
61 }
62
63 // WithTestNameForDir will create a directory with the test's name in the
64 // fixture directory to store all the golden files.
65 //
66 // Default value is false.
67 func (g *Goldie) WithTestNameForDir(use bool) error {
68 g.useTestNameForDir = use
69 return nil
70 }
71
72 // WithSubTestNameForDir will create a directory with the sub test's name to
73 // store all the golden files. If WithTestNameForDir is enabled, it will be in
74 // the test name's directory. Otherwise, it will be in the fixture directory.
75 //
76 // Default value is false.
77 func (g *Goldie) WithSubTestNameForDir(use bool) error {
78 g.useSubTestNameForDir = use
79 return nil
80 }