fixtures

package module
v0.0.0-...-88aac25 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2024 License: Apache-2.0 Imports: 5 Imported by: 1

README

bolt-fixtures

Test fixtures for BoltDB. Write tests against a real database.

Prepare test data

Example YAML fixture:

- bucket: abc
  pairs:
    - bucket: def
      pairs:
        - key: ghi
          value: jkl
- bucket: mno
  pairs:
    - key: pqr
      value: stu
    - key: vwx
      value:
        foo: abc
        bar: 123

Load into BoltDB

Example integration for your project:

func TestSomething(t *testing.T) {
	f, _ := ioutil.TempFile("", "TestSomething")
	defer os.Remove(f.Name())

	fixtureFiles := []string{"testdata/test.yaml"}
	l, _ := fixtures.New(f.Name(), fixtureFiles)
	defer l.Close()

	_ = l.Load()

	// do something
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Fixture

type Fixture struct {
	Bucket string      `yaml:"bucket"`
	Pairs  []Fixture   `yaml:"pairs"`
	Key    string      `yaml:"key"`
	Value  interface{} `yaml:"value"`
}

type Loader

type Loader struct {
	// contains filtered or unexported fields
}

Loader is the responsible to loading fixtures.

func New

func New(dbPath string, fixturesFiles []string) (*Loader, error)

func (Loader) Close

func (l Loader) Close() error

func (Loader) DB

func (l Loader) DB() *bolt.DB

func (Loader) Load

func (l Loader) Load() error

Jump to

Keyboard shortcuts

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