testutils

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2020 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseProto3String

func ParseProto3String(t *testing.T, src string) *desc.FileDescriptor

ParseProto3String parses a string representing a proto file, and returns a FileDescriptor.

It adds the `syntax = "proto3";` line to the beginning of the file and chooses a filename, and then calls ParseProtoStrings.

func ParseProto3Tmpl

func ParseProto3Tmpl(t *testing.T, src string, data interface{}) *desc.FileDescriptor

ParseProto3Tmpl parses a template string representing a proto file, and returns a FileDescriptor.

It parses the template using Go's text/template Parse function, and then calls ParseProto3String.

func ParseProtoStrings

func ParseProtoStrings(t *testing.T, src map[string]string) map[string]*desc.FileDescriptor

ParseProtoStrings parses a map representing a proto files, and returns a slice of FileDescriptors.

It dedents the string before parsing.

Types

type Problems

type Problems []lint.Problem

Problems is a slice of individual Problem objects.

func (Problems) Diff

func (problems Problems) Diff(other []lint.Problem) string

Diff determines whether a Problem is sufficiently similar to another to be considered equivalent, and returns a diff otherwise.

This is intended for unit tests and is intentially generous on what constitutes equality.

func (Problems) SetDescriptor

func (problems Problems) SetDescriptor(d desc.Descriptor) Problems

SetDescriptor sets the given descriptor to every Problem in the slice and returns the slice back.

This is intended primarily for use in unit tests.

Jump to

Keyboard shortcuts

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