assert

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2018 License: MIT Imports: 5 Imported by: 0

README

Build Status Coverage Status GoDoc

tag-assert

Checking tags of Golang structures

Install

go get github.com/arteev/tag-assert

Using


//example.go
package example
type ExampleStruct struct {
	Name string `xml:"Name" json:"name,omitempty"`
	ID   int    `xml:"ID" json:"rn"`
}


//example_test.go
package example
import (
	"testing"
	"github.com/arteev/tag-assert"
)
func TestExampleStructTagsValueSuccess(t *testing.T) {
	v := ExampleStruct{}
	assert.Expect(t, v).ExpectField("Name").
		Assert("xml", "Name").
		Assert("json", "name,omitempty")
}

func TestExampleStructTagsValueFailed(t *testing.T) {
	v := ExampleStruct{}
	assert.Expect(t, v).ExpectField("ID").
		Assert("xml", "ID").
		Assert("json", "id") // this error

	assert.Expect(t, v).ExpectField("SN").
		Assert("xml", "SN").
		Assert("json", "social_number")

}

Documentation

Overview

Package assert is a generated GoMock package.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotStruct     = errors.New("Must be struct")
	ErrUnxpectedNil  = errors.New("Unexpected nil")
	ErrFieldNotFound = errors.New("Field not found")
	ErrUnexported    = errors.New("Field unexported")
	ErrTagNotFound   = errors.New("Tag not found")
)

Errors

Functions

This section is empty.

Types

type Field

type Field struct {
	// contains filtered or unexported fields
}

Field contains methods for verifying the field

func (*Field) Assert

func (f *Field) Assert(name, value string) *Field

Assert checks the tag (name) with the specified value

func (*Field) ExpectTag

func (f *Field) ExpectTag(name string) *Tag

ExpectTag waiting for a tag with name to verify assert

func (*Field) HasTag

func (f *Field) HasTag(name string) *Field

HasTag checks the existence of a tag in the field

type MockTB

type MockTB struct {
	// contains filtered or unexported fields
}

MockTB is a mock of TB interface

func NewMockTB

func NewMockTB(ctrl *gomock.Controller) *MockTB

NewMockTB creates a new mock instance

func (*MockTB) EXPECT

func (m *MockTB) EXPECT() *MockTBMockRecorder

EXPECT returns an object that allows the caller to indicate expected use

func (*MockTB) Error

func (m *MockTB) Error(arg0 ...interface{})

Error mocks base method

func (*MockTB) Errorf

func (m *MockTB) Errorf(arg0 string, arg1 ...interface{})

Errorf mocks base method

func (*MockTB) Fail

func (m *MockTB) Fail()

Fail mocks base method

func (*MockTB) FailNow

func (m *MockTB) FailNow()

FailNow mocks base method

func (*MockTB) Failed

func (m *MockTB) Failed() bool

Failed mocks base method

func (*MockTB) Fatal

func (m *MockTB) Fatal(arg0 ...interface{})

Fatal mocks base method

func (*MockTB) Fatalf

func (m *MockTB) Fatalf(arg0 string, arg1 ...interface{})

Fatalf mocks base method

func (*MockTB) Helper

func (m *MockTB) Helper()

Helper mocks base method

func (*MockTB) Log

func (m *MockTB) Log(arg0 ...interface{})

Log mocks base method

func (*MockTB) Logf

func (m *MockTB) Logf(arg0 string, arg1 ...interface{})

Logf mocks base method

func (*MockTB) Name

func (m *MockTB) Name() string

Name mocks base method

func (*MockTB) Skip

func (m *MockTB) Skip(arg0 ...interface{})

Skip mocks base method

func (*MockTB) SkipNow

func (m *MockTB) SkipNow()

SkipNow mocks base method

func (*MockTB) Skipf

func (m *MockTB) Skipf(arg0 string, arg1 ...interface{})

Skipf mocks base method

func (*MockTB) Skipped

func (m *MockTB) Skipped() bool

Skipped mocks base method

type MockTBMockRecorder

type MockTBMockRecorder struct {
	// contains filtered or unexported fields
}

MockTBMockRecorder is the mock recorder for MockTB

func (*MockTBMockRecorder) Error

func (mr *MockTBMockRecorder) Error(arg0 ...interface{}) *gomock.Call

Error indicates an expected call of Error

func (*MockTBMockRecorder) Errorf

func (mr *MockTBMockRecorder) Errorf(arg0 interface{}, arg1 ...interface{}) *gomock.Call

Errorf indicates an expected call of Errorf

func (*MockTBMockRecorder) Fail

func (mr *MockTBMockRecorder) Fail() *gomock.Call

Fail indicates an expected call of Fail

func (*MockTBMockRecorder) FailNow

func (mr *MockTBMockRecorder) FailNow() *gomock.Call

FailNow indicates an expected call of FailNow

func (*MockTBMockRecorder) Failed

func (mr *MockTBMockRecorder) Failed() *gomock.Call

Failed indicates an expected call of Failed

func (*MockTBMockRecorder) Fatal

func (mr *MockTBMockRecorder) Fatal(arg0 ...interface{}) *gomock.Call

Fatal indicates an expected call of Fatal

func (*MockTBMockRecorder) Fatalf

func (mr *MockTBMockRecorder) Fatalf(arg0 interface{}, arg1 ...interface{}) *gomock.Call

Fatalf indicates an expected call of Fatalf

func (*MockTBMockRecorder) Helper

func (mr *MockTBMockRecorder) Helper() *gomock.Call

Helper indicates an expected call of Helper

func (*MockTBMockRecorder) Log

func (mr *MockTBMockRecorder) Log(arg0 ...interface{}) *gomock.Call

Log indicates an expected call of Log

func (*MockTBMockRecorder) Logf

func (mr *MockTBMockRecorder) Logf(arg0 interface{}, arg1 ...interface{}) *gomock.Call

Logf indicates an expected call of Logf

func (*MockTBMockRecorder) Name

func (mr *MockTBMockRecorder) Name() *gomock.Call

Name indicates an expected call of Name

func (*MockTBMockRecorder) Skip

func (mr *MockTBMockRecorder) Skip(arg0 ...interface{}) *gomock.Call

Skip indicates an expected call of Skip

func (*MockTBMockRecorder) SkipNow

func (mr *MockTBMockRecorder) SkipNow() *gomock.Call

SkipNow indicates an expected call of SkipNow

func (*MockTBMockRecorder) Skipf

func (mr *MockTBMockRecorder) Skipf(arg0 interface{}, arg1 ...interface{}) *gomock.Call

Skipf indicates an expected call of Skipf

func (*MockTBMockRecorder) Skipped

func (mr *MockTBMockRecorder) Skipped() *gomock.Call

Skipped indicates an expected call of Skipped

type StructAssert

type StructAssert struct {
	// contains filtered or unexported fields
}

StructAssert contains methods for verifying the structure

func Expect

func Expect(t tb, v interface{}) *StructAssert

Expect waiting for a structure to verify assert

func (*StructAssert) Expect

func (a *StructAssert) Expect(v interface{}) *StructAssert

Expect waiting for a structure to verify assert

func (*StructAssert) ExpectField

func (a *StructAssert) ExpectField(name string) *Field

ExpectField waiting for a field with name to verify assert

func (*StructAssert) HasField

func (a *StructAssert) HasField(name string) *StructAssert

HasField checks the existence of a field in the structure

type Tag

type Tag struct {
	Field *Field
	Name  string
	Value string
}

Tag of field

func (*Tag) HasValue

func (t *Tag) HasValue(value string) bool

HasValue checks the tag for the specified value

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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