fakes

package
v0.0.23 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2022 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Rendered for js/wasm

Overview

Package fakes implements fake implementations of Chrome's extension APIs to ease unit testing.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Errs

type Errs struct {
	// Get is the error that should be returned by Get().
	Get error
	// Set is the error that should be returned by Set().
	Set error
	// Delete is the error that should be returned by Delete().
	Delete error
}

Errs contains errors that should be returned by the fake implementation.

type Mem

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

Mem is an in-memory implementation of the storage.Area interface.

func NewMem

func NewMem() *Mem

NewMem returns a fake implementation of Chrome's storage API.

func (*Mem) Delete

func (m *Mem) Delete(ctx jsutil.AsyncContext, keys []string) error

Delete implements Area.Delete().

func (*Mem) Get

func (m *Mem) Get(ctx jsutil.AsyncContext) (map[string]js.Value, error)

Get implements Area.Get().

func (*Mem) Set

func (m *Mem) Set(ctx jsutil.AsyncContext, data map[string]js.Value) error

Set implements Area.Set().

func (*Mem) SetError

func (m *Mem) SetError(err Errs)

SetError specifies the errors that should be returned from various operations. Forcing the fake implementation to return errors is useful to test error conditions in unit tests.

Jump to

Keyboard shortcuts

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