tests

package module
v0.0.0-...-236af4d Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2020 License: MIT Imports: 9 Imported by: 0

README

certmagic-storage-tests

Package tests implements a suite of tests for certmagic.Storage

Install

go get github.com/oyato/certmagic-storage-tests

Usage

This is package a for testing, so be sure to only import it inside your _test.go file.

package storage

import (
	tests "github.com/oyato/certmagic-storage-tests"
	"testing"
)

func TestStorage(t *testing.T) {
	// set up your storage
	storage := NewInstanceOfYourStorage()
	// then run the tests on it
	tests.NewTestSuite(storage).Run(t)
}

Note

At this time, it's an exported version of tests used for https://github.com/oyato/certmagic-storage-badger and might be incomplete or unsuitable for testing other storage implementations.

Documentation

Overview

Package tests implements a suite of tests for certmagic.Storage

Example Usage:

package storage

import (

tests "github.com/oyato/certmagic-storage-tests"
"testing"

)

func TestStorage(t *testing.T) {
    // set up your storage
    storage := NewInstanceOfYourStorage()
    // then run the tests on it
    tests.NewTestSuite(storage).Run(t)
}

Index

Constants

This section is empty.

Variables

View Source
var (
	// KeyPrefix is prepended to all tested keys.
	// If changed, it must not contain a forward slash (/)
	KeyPrefix = "__test__key__"
)

Functions

This section is empty.

Types

type Suite

type Suite struct {
	S   certmagic.Storage
	Rng interface{ Int() int }
	// contains filtered or unexported fields
}

Suite implements tests for certmagic.Storage.

Users should call Suite.Run() in their storage_test.go file.

func NewTestSuite

func NewTestSuite(s certmagic.Storage) *Suite

NewTestSuite returns a new Suite initalised with storage s and a `rand.New(rand.NewSource(0))` random number generator

func (*Suite) Run

func (ts *Suite) Run(t *testing.T)

Run tests the Storage

NOTE: t.Helper() is not called.

Test failure line numbers will be reported on files inside this package.

Jump to

Keyboard shortcuts

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