gproto

package module
v0.0.0-...-23e645a Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2021 License: Apache-2.0 Imports: 3 Imported by: 0

README

Gomega Matchers for Protobufs

gproto provides Gomega matchers to help write effective assertions against Protobufs.

Based on the EqualProto Matcher gomega issue, a Hyperledger Fabric review comment, and a equal_cmp_matcher.go Gist.

Installation

go get github.com/jt-nti/gproto

Usage

//...
import (
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
	"github.com/jt-nti/gproto"
	"google.golang.org/protobuf/types/known/timestamppb"
)
//...
Context("when something something protobuf", func() {
	It("should match when the messages are equal", func() {
		actual := &timestamppb.Timestamp{
			Seconds: 1234567890,
		}
		expected := &timestamppb.Timestamp{
			Seconds: 1234567890,
		}
		Expect(actual).To(gproto.Equal(expected))
	})

	It("should not match when the messages are not equal", func() {
		actual := &timestamppb.Timestamp{
			Seconds: 1234567890,
		}
		expected := &timestamppb.Timestamp{
			Seconds: 9876543210,
		}
		Expect(actual).ToNot(gproto.Equal(expected))
	})
})
//...

TODO

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Equal

func Equal(expected proto.Message) types.GomegaMatcher

Equal succeeds if actual is a Protobuf message that matches the expected message. The messages are compared via proto.Equal

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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