Documentation
¶
Overview ¶
Package fixture provides loading and parsing of SVGO test fixture files.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type PluginCase ¶
type PluginCase struct {
// PluginName is the plugin identifier, e.g. "removeComments".
PluginName string
// Index is the numeric index from the filename, e.g. 1 for "removeComments.01.svg.txt".
Index int
// Description is the optional text before the "===" separator.
Description string
// Input is the original SVG content (before optimization).
Input string
// Expected is the expected SVG output (after optimization).
Expected string
// Params is the optional JSON parameters for the plugin.
// nil means no parameters (use plugin defaults).
Params json.RawMessage
// FilePath is the absolute path to the source fixture file.
FilePath string
}
PluginCase represents a single plugin test case loaded from a *.svg.txt file.
The fixture format (from SVGO) is:
[Optional description] === [Input SVG] @@@ [Expected output SVG] @@@ [Optional JSON params]
func LoadPluginFixture ¶
func LoadPluginFixture(filePath string) (*PluginCase, error)
LoadPluginFixture loads and parses a single SVGO fixture file.
The file name must match the pattern "{pluginName}.{index}.svg.txt". Returns an error if the file cannot be read or parsed.
func LoadPluginFixtures ¶
func LoadPluginFixtures(dir string) ([]*PluginCase, error)
LoadPluginFixtures loads all fixture files from a directory.
It scans for files matching "{pluginName}.{index}.svg.txt" and returns all successfully parsed test cases. Files that don't match the pattern are silently skipped.
func LoadPluginFixturesByName ¶
func LoadPluginFixturesByName(dir, pluginName string) ([]*PluginCase, error)
LoadPluginFixturesByName loads all fixture files for a specific plugin.
func (*PluginCase) HasParams ¶
func (tc *PluginCase) HasParams() bool
HasParams returns true if this test case has plugin parameters.
func (*PluginCase) IsIdempotenceExcluded ¶
func (tc *PluginCase) IsIdempotenceExcluded() bool
IsIdempotenceExcluded returns true if this plugin is excluded from idempotence testing (should only run 1 pass instead of 2).
From SVGO: const exclude = ['addAttributesToSVGElement', 'convertTransform'];
func (*PluginCase) MultipassCount ¶
func (tc *PluginCase) MultipassCount() int
MultipassCount returns how many passes to run for idempotence testing. Returns 1 for excluded plugins, 2 for all others.