Skip to content

Commit

Permalink
Merge branch 'master' into robjs-coverage-adjust
Browse files Browse the repository at this point in the history
  • Loading branch information
robshakir committed Oct 3, 2017
2 parents 3d4ae1b + 52f610f commit d51ade1
Show file tree
Hide file tree
Showing 18 changed files with 507 additions and 55 deletions.
7 changes: 7 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,12 @@ before_install:
install:
- go get -u github.com/golang/protobuf/protoc-gen-go
- make install
script:
- go tool vet -composites=false ./ygot
- go tool vet ./ygen
- go tool vet ./ytypes
- diff -u <(echo -n) <(gofmt -d -s ./ygot)
- diff -u <(echo -n) <(gofmt -d -s ./ygen)
- diff -u <(echo -n) <(gofmt -d -s ./ytypes)
after_success:
- ./scripts/coverage.sh
2 changes: 1 addition & 1 deletion demo/getting_started/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ import (
"fmt"

oc "github.com/openconfig/ygot/demo/getting_started/pkg/ocdemo"
"github.com/openconfig/ygot/ygot"
"github.com/openconfig/ygot/util"
"github.com/openconfig/ygot/ygot"
)

// The following generation rule uses the generator binary to create the
Expand Down
2 changes: 1 addition & 1 deletion experimental/ygotutils/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import (

log "github.com/golang/glog"

gpb "github.com/openconfig/gnmi/proto/gnmi"
scpb "google.golang.org/genproto/googleapis/rpc/code"
spb "google.golang.org/genproto/googleapis/rpc/status"
gpb "github.com/openconfig/gnmi/proto/gnmi"
)

var (
Expand Down
6 changes: 3 additions & 3 deletions util/errs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func TestAppendErr(t *testing.T) {
if got, want := errs.String(), "err1"; got != want {
t.Errorf("got: %s, want: %s", got, want)
}

errs = AppendErr(errs, nil)
errs = AppendErr(errs, fmt.Errorf("err2"))
if got, want := errs.String(), "err1, err2"; got != want {
Expand Down Expand Up @@ -89,15 +89,15 @@ func TestAppendErrsInFunction(t *testing.T) {
if got, want := myAppendErrFunc().String(), wantStr; got != want {
t.Errorf("got: %s, want: %s", got, want)
}

myAppendErrsFunc := func() (errs Errors) {
errs = AppendErrs(errs, testErrs)
return
}
if got, want := myAppendErrsFunc().String(), wantStr; got != want {
t.Errorf("got: %s, want: %s", got, want)
}

myErrorSliceFunc := func() (errs []error) {
errs = AppendErrs(errs, testErrs)
return
Expand Down
5 changes: 2 additions & 3 deletions util/reflect_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,8 @@ func areEqualWithWildcards(s, pattern string) bool {

// to ptr conversion utility functions
func toStringPtr(s string) *string { return &s }
func toInt8Ptr(i int8) *int8 { return &i }
func toInt32Ptr(i int32) *int32 { return &i }

func toInt8Ptr(i int8) *int8 { return &i }
func toInt32Ptr(i int32) *int32 { return &i }

func TestUpdateField(t *testing.T) {
type BasicStruct struct {
Expand Down
4 changes: 2 additions & 2 deletions ygen/goelements_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ func TestFindChildren(t *testing.T) {
"case": {
Kind: yang.CaseEntry,
Dir: map[string]*yang.Entry{
"string": &yang.Entry{
"string": {
Name: "string",
},
},
Expand Down Expand Up @@ -268,7 +268,7 @@ func TestFindChildren(t *testing.T) {
"case": {
Kind: yang.CaseEntry,
Dir: map[string]*yang.Entry{
"string": &yang.Entry{
"string": {
Name: "string",
},
},
Expand Down
6 changes: 3 additions & 3 deletions ygen/gogen_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -725,7 +725,7 @@ func (t *Tstruct) ΛEnumTypeMap() map[string][]reflect.Type { return ΛEnumTypes
path: []string{"", "root-module", "tstruct"},
},
inMappableEntities: map[string]*yangDirectory{
"/root-module/tstruct/listWithKey": &yangDirectory{},
"/root-module/tstruct/listWithKey": {},
},
wantCompressed: wantGoStructOut{wantErr: true},
wantUncompressed: wantGoStructOut{wantErr: true},
Expand All @@ -734,7 +734,7 @@ func (t *Tstruct) ΛEnumTypeMap() map[string][]reflect.Type { return ΛEnumTypes
inStructToMap: &yangDirectory{
name: "AStruct",
fields: map[string]*yang.Entry{
"anydata": &yang.Entry{
"anydata": {
Name: "anydata",
Kind: yang.AnyDataEntry,
},
Expand All @@ -747,7 +747,7 @@ func (t *Tstruct) ΛEnumTypeMap() map[string][]reflect.Type { return ΛEnumTypes
inStructToMap: &yangDirectory{
name: "AStruct",
fields: map[string]*yang.Entry{
"idd": &yang.Entry{
"idd": {
Name: "idd",
Type: &yang.YangType{Kind: yang.Yidentityref},
Parent: &yang.Entry{
Expand Down
28 changes: 14 additions & 14 deletions ygen/protogen_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ func TestGenProto3Msg(t *testing.T) {
"/a-message-with-a-list/list": "List",
},
inMsgs: map[string]*yangDirectory{
"/a-message-with-a-list/list": &yangDirectory{
"/a-message-with-a-list/list": {
name: "List",
entry: &yang.Entry{
Name: "list",
Expand All @@ -374,7 +374,7 @@ func TestGenProto3Msg(t *testing.T) {
},
},
wantMsgs: map[string]protoMsg{
"AMessageWithAList": protoMsg{
"AMessageWithAList": {
Name: "AMessageWithAList",
YANGPath: "/a-message-with-a-list/list",
Fields: []*protoMsgField{{
Expand All @@ -384,7 +384,7 @@ func TestGenProto3Msg(t *testing.T) {
IsRepeated: true,
}},
},
"ListKey": protoMsg{
"ListKey": {
Name: "ListKey",
YANGPath: "/a-message-with-a-list/list",
Fields: []*protoMsgField{{
Expand Down Expand Up @@ -514,7 +514,7 @@ func TestGenProto3Msg(t *testing.T) {
inEnumPackage: "enums",
inAnnotateSchemaPaths: true,
wantMsgs: map[string]protoMsg{
"MessageWithAnnotations": protoMsg{
"MessageWithAnnotations": {
Name: "MessageWithAnnotations",
YANGPath: "/one/two",
Fields: []*protoMsgField{{
Expand Down Expand Up @@ -641,7 +641,7 @@ func TestWriteProtoMsg(t *testing.T) {
Node: &yang.Container{Name: "message-name"},
},
fields: map[string]*yang.Entry{
"field-one": &yang.Entry{
"field-one": {
Name: "field-one",
Type: &yang.YangType{Kind: yang.Ystring},
},
Expand Down Expand Up @@ -681,7 +681,7 @@ message MessageName {
},
},
fields: map[string]*yang.Entry{
"child": &yang.Entry{
"child": {
Name: "child",
Kind: yang.DirectoryEntry,
Dir: map[string]*yang.Entry{},
Expand All @@ -698,7 +698,7 @@ message MessageName {
path: []string{"", "module", "message-name"},
},
inMsgs: map[string]*yangDirectory{
"/module/message-name/child": &yangDirectory{
"/module/message-name/child": {
name: "Child",
entry: &yang.Entry{
Name: "child",
Expand Down Expand Up @@ -747,7 +747,7 @@ message MessageName {
},
},
fields: map[string]*yang.Entry{
"enum": &yang.Entry{
"enum": {
Name: "enum",
Kind: yang.LeafEntry,
Parent: &yang.Entry{
Expand Down Expand Up @@ -808,7 +808,7 @@ message MessageName {
},
},
fields: map[string]*yang.Entry{
"list": &yang.Entry{
"list": {
Name: "list",
Kind: yang.DirectoryEntry,
Parent: &yang.Entry{
Expand Down Expand Up @@ -911,7 +911,7 @@ message MessageName {
},
},
fields: map[string]*yang.Entry{
"identityref": &yang.Entry{
"identityref": {
Name: "identityref",
Kind: yang.LeafEntry,
Parent: &yang.Entry{
Expand Down Expand Up @@ -1204,7 +1204,7 @@ func TestWriteProtoEnums(t *testing.T) {
}{{
name: "skipped enumeration type",
inEnums: map[string]*yangEnum{
"e": &yangEnum{
"e": {
name: "e",
entry: &yang.Entry{
Name: "e",
Expand Down Expand Up @@ -1247,7 +1247,7 @@ enum EnumeratedValue {
}, {
name: "enum for typedef enumeration",
inEnums: map[string]*yangEnum{
"e": &yangEnum{
"e": {
name: "EnumName",
entry: &yang.Entry{
Name: "e",
Expand All @@ -1261,7 +1261,7 @@ enum EnumeratedValue {
},
},
},
"f": &yangEnum{
"f": {
name: "SecondEnum",
entry: &yang.Entry{
Name: "f",
Expand Down Expand Up @@ -1425,7 +1425,7 @@ func TestUnionFieldToOneOf(t *testing.T) {
Type: "string",
}},
wantEnums: map[string]*protoMsgEnum{
"FieldName": &protoMsgEnum{
"FieldName": {
Values: map[int64]string{
0: "UNSET",
1: "SPEED_2_5G",
Expand Down
2 changes: 1 addition & 1 deletion ygot/render.go
Original file line number Diff line number Diff line change
Expand Up @@ -1176,7 +1176,7 @@ func constructJSONSlice(field reflect.Value, parentMod string, args jsonOutputCo
for i := 0; i < field.Len(); i++ {
gs, ok := field.Index(i).Interface().(GoStruct)
if !ok {
return nil, fmt.Errorf("invalid member of a slice, %s was not a valid GoStruct", c.Name)
return nil, fmt.Errorf("invalid member of a slice, %s was not a valid GoStruct", c.Name())
}
j, err := constructJSON(gs, parentMod, args)
if err != nil {
Expand Down
22 changes: 11 additions & 11 deletions ygot/render_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ func TestGNMIPathOps(t *testing.T) {
}

if err == nil && !reflect.DeepEqual(gotLast, tt.wantLastPathElem) {
t.Errorf("%s: %v.LastPathElem(), did not get expected last element, got: %v, want: %V", tt.name, tt.inPath, gotLast, tt.wantLastPathElem)
t.Errorf("%s: %v.LastPathElem(), did not get expected last element, got: %v, want: %v", tt.name, tt.inPath, gotLast, tt.wantLastPathElem)
}

np := tt.inPath.Copy()
Expand Down Expand Up @@ -558,14 +558,14 @@ func TestAppendGNMIPathElemKey(t *testing.T) {
}),
inPath: &gnmiPath{
pathElemPath: []*gnmipb.PathElem{
&gnmipb.PathElem{Name: "foo"},
&gnmipb.PathElem{Name: "bar"},
{Name: "foo"},
{Name: "bar"},
},
},
wantPath: &gnmiPath{
pathElemPath: []*gnmipb.PathElem{
&gnmipb.PathElem{Name: "foo"},
&gnmipb.PathElem{Name: "bar", Key: map[string]string{"val": "foo"}},
{Name: "foo"},
{Name: "bar", Key: map[string]string{"val": "foo"}},
},
},
}, {
Expand All @@ -578,12 +578,12 @@ func TestAppendGNMIPathElemKey(t *testing.T) {
}),
inPath: &gnmiPath{
pathElemPath: []*gnmipb.PathElem{
&gnmipb.PathElem{Name: "foo"},
{Name: "foo"},
},
},
wantPath: &gnmiPath{
pathElemPath: []*gnmipb.PathElem{
&gnmipb.PathElem{
{
Name: "foo",
Key: map[string]string{
"i": "-42",
Expand All @@ -599,7 +599,7 @@ func TestAppendGNMIPathElemKey(t *testing.T) {
inValue: reflect.ValueOf(&pathElemMultiKey{}),
inPath: &gnmiPath{
pathElemPath: []*gnmipb.PathElem{
&gnmipb.PathElem{Name: "foo"},
{Name: "foo"},
},
},
wantErr: true,
Expand All @@ -617,7 +617,7 @@ func TestAppendGNMIPathElemKey(t *testing.T) {
inValue: reflect.ValueOf(nil),
inPath: &gnmiPath{
pathElemPath: []*gnmipb.PathElem{
&gnmipb.PathElem{Name: "foo"},
{Name: "foo"},
},
},
wantErr: true,
Expand Down Expand Up @@ -1237,7 +1237,7 @@ func TestTogNMINotifications(t *testing.T) {
inTimestamp: 42,
inStruct: &pathElemExample{
MKey: map[pathElemExampleMultiKeyChildKey]*pathElemExampleMultiKeyChild{
pathElemExampleMultiKeyChildKey{Foo: "foo", Bar: 16}: {Foo: String("foo"), Bar: Uint16(16)},
{Foo: "foo", Bar: 16}: {Foo: String("foo"), Bar: Uint16(16)},
},
},
inConfig: GNMINotificationsConfig{UsePathElem: true},
Expand Down Expand Up @@ -1528,7 +1528,7 @@ func (*diffModAtRoot) IsYANGGoStruct() {}
type diffModAtRootChild struct {
ValueOne *string `path:"/foo/value-one" module:"m2"`
ValueTwo *string `path:"/foo/value-two" module:"m3"`
ValueThree *string `path:"/foo/value-three" module"m1"`
ValueThree *string `path:"/foo/value-three" module:"m1"`
}

func (*diffModAtRootChild) IsYANGGoStruct() {}
Expand Down
10 changes: 5 additions & 5 deletions ytypes/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ var (
// values.
testErrOutput = false
globalEnumMap = map[string]map[int64]ygot.EnumDefinition{
"EnumType": map[int64]ygot.EnumDefinition{
"EnumType": {
42: {Name: "E_VALUE_FORTY_TWO"},
},
"EnumType2": map[int64]ygot.EnumDefinition{
"EnumType2": {
43: {Name: "E_VALUE_FORTY_THREE"},
},
}
Expand Down Expand Up @@ -296,7 +296,7 @@ func TestForEachSchemaNode(t *testing.T) {
Kind: yang.CaseEntry,
Name: "case1",
Dir: map[string]*yang.Entry{
"case1-leaf1": &yang.Entry{
"case1-leaf1": {
Kind: yang.LeafEntry,
Name: "Case1Leaf1",
Type: &yang.YangType{Kind: yang.Ystring},
Expand All @@ -307,15 +307,15 @@ func TestForEachSchemaNode(t *testing.T) {
Kind: yang.CaseEntry,
Name: "case2",
Dir: map[string]*yang.Entry{
"case2_choice1": &yang.Entry{
"case2_choice1": {
Kind: yang.ChoiceEntry,
Name: "case2_choice1",
Dir: map[string]*yang.Entry{
"case21": {
Kind: yang.CaseEntry,
Name: "case21",
Dir: map[string]*yang.Entry{
"case21-leaf": &yang.Entry{
"case21-leaf": {
Kind: yang.LeafEntry,
Name: "case21-leaf",
Type: &yang.YangType{Kind: yang.Ystring},
Expand Down
4 changes: 2 additions & 2 deletions ytypes/leaf_list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,13 @@ func TestUnmarshalLeafList(t *testing.T) {
Name: "container",
Kind: yang.DirectoryEntry,
Dir: map[string]*yang.Entry{
"int32-leaf-list": &yang.Entry{
"int32-leaf-list": {
Name: "int32-leaf-list",
Kind: yang.LeafEntry,
ListAttr: &yang.ListAttr{MinElements: &yang.Value{Name: "0"}},
Type: &yang.YangType{Kind: yang.Yint32},
},
"enum-leaf-list": &yang.Entry{
"enum-leaf-list": {
Name: "enum-leaf-list",
Kind: yang.LeafEntry,
ListAttr: &yang.ListAttr{MinElements: &yang.Value{Name: "0"}},
Expand Down
2 changes: 1 addition & 1 deletion ytypes/leaf_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -828,7 +828,7 @@ func (*UnionLeafType_EnumType2) ΛMap() map[string]map[int64]ygot.EnumDefinition

func (*LeafContainerStruct) ΛEnumTypeMap() map[string][]reflect.Type {
return map[string][]reflect.Type{
"/container-schema/union-leaf": []reflect.Type{reflect.TypeOf(EnumType(0)), reflect.TypeOf(EnumType2(0))},
"/container-schema/union-leaf": {reflect.TypeOf(EnumType(0)), reflect.TypeOf(EnumType2(0))},
}
}

Expand Down

0 comments on commit d51ade1

Please sign in to comment.