internal

package
v0.0.0-...-7b9a879 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2022 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ForgetAllFields

func ForgetAllFields(t *testing.T, originalMessage proto.Message) proto.Message

ForgetAllFields taks a proto message and turns all its fields into unknown fields.

It does this by marshalling the proto message and then parsing it as an empty message.

Types

type TestCase

type TestCase struct {
	// Protos is a list of protobuf messages that should have the same objecthash.
	Protos []proto.Message

	// EquivalentObject is a plain Go object that should have the same objecthash
	// as the messages under the `protos` field.
	EquivalentObject interface{}

	// EquivalentJSONString is a JSON object that should have the same objecthash
	// as the messages under the `protos` field.
	EquivalentJSONString string

	// ExpectedHashString is the expected objecthash for all the objects in the
	// test case.
	ExpectedHashString string
}

TestCase represents typical ObjectHash-Proto test cases.

func (TestCase) Check

func (tc TestCase) Check(t *testing.T, hasher oi.ProtoHasher)

Check tests the ObjectHashes for the protos in a TestCase's Protos field.

It does the following checks: - The ObjectHashes of the protos (stringified) are equal to the ExpectedHashString. - The ObjectHashes of the protos are equal to the ObjectHash of the EquivalentJSONString, if present. - The ObjectHashes of the protos are equal to the ObjectHash of the EquivalentObject, if present.

Jump to

Keyboard shortcuts

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