util

package
v0.0.0-...-5c8b67e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 22, 2022 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ConfigFile = "config.properties"

ConfigFile is the name of the config file used for testing.

Functions

func BuildIndex

func BuildIndex(config index.Config, existingIdx *index.Index) (*index.Index, error)

BuildIndex creates an Index by walking the file system from Config.Root(). If an existing Index is passed in, only new & updated files will be scanned. Other files will use the existing Index's Entries.

func BuildTestIndex

func BuildTestIndex(t *testing.T, config index.Config) *index.Index

BuildTestIndex creates a file layout and builds the Index from those files.

func Compare

func Compare(one *index.Index, two *index.Index, ignoreMissing bool) bool

Compare examines the Entries in the given Indexes and returns true if they are all the same.

func GetIndexFile

func GetIndexFile(config index.Config, ext string) string

GetIndexFile returns the filename that will be used by StoreIndex(). It outputs Config.SavePath() + "/" + Config.BaseName() + ext.

func LoadConfig

func LoadConfig(configFile string) (index.Config, error)

LoadConfig loads the Config defined by the given file.

func LoadIndex

func LoadIndex(config index.Config, ext string) (idx *index.Index, err error)

LoadIndex loads the index defined by the given Config plus an (optional) identifier extension (e.g. _current, _known, etc).

func LoadTestConfig

func LoadTestConfig(t *testing.T) (index.Config, func())

LoadTestConfig sets up a fake config file for use in tests. It links the index file system into Viper, saves 'config.properties' from the given string and then loads that file into a Config. The unction returned should is for test teardown and should be called via defer.

func MakeFile

func MakeFile(t *testing.T, path string, data string, perm os.FileMode) os.FileInfo

MakeFile creates a file with the given data.

func StoreIndex

func StoreIndex(idx *index.Index, config index.Config, ext string) error

StoreIndex stores the given index using Config.SavePath(), Config.BaseName() and an (optional) identifier extension (e.g. _current, _known, etc) as the file name.

Types

type HashFn

type HashFn func(index.Entry, index.Entry)

HashFn is called when Entries do not have the same hash (i.e. they have changed).

var OnHashChange HashFn

OnHashChange is the HashFn that will be called.

type MissingFn

type MissingFn func(index.Entry, *index.Index)

MissingFn is the called when an Entry is missing from the index.

var OnMissing MissingFn

OnMissing is the MissingFn that will be called.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL