approvaltest

package
v0.0.0-...-07f4370 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package approvaltest contains helper functions to compare and assert the received content of a test vs the accepted.

Index

Constants

View Source
const (
	// ApprovedSuffix signals a file has been reviewed and approved.
	ApprovedSuffix = ".approved.json"

	// ReceivedSuffix signals a file has changed and not yet been approved.
	ReceivedSuffix = ".received.json"
)

Variables

This section is empty.

Functions

func ApproveEvents

func ApproveEvents(t testing.TB, name string, hits []espoll.SearchHit, dynamic ...string)

ApproveEvents compares the _source of the search hits with the contents of the file in "approvals/<name>.approved.json".

Dynamic fields (@timestamp, observer.id, etc.) are replaced with a static string for comparison. Integration tests elsewhere use canned data to test fields that we do not cover here.

If the events differ, then the test will fail.

func ApproveFields

func ApproveFields(t testing.TB, name string, hits []espoll.SearchHit, dynamic ...string)

ApproveFields compares the fields of the search hits with the contents of the file in "approvals/<name>.approved.json".

Dynamic fields (@timestamp, observer.id, etc.) are replaced with a static string for comparison. Integration tests elsewhere use canned data to test fields that we do not cover here.

TODO(axw) eventually remove ApproveEvents when we have updated all calls to use ApproveFields. ApproveFields should be used since it includes runtime fields, whereas ApproveEvents only looks at _source.

Types

This section is empty.

Jump to

Keyboard shortcuts

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