Skip to content

Commit

Permalink
feat: ignore IMMUTABLE fields in update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
radhus committed Sep 19, 2022
1 parent aaa6187 commit 6c097c1
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 76 deletions.
7 changes: 7 additions & 0 deletions internal/aiptest/update/required_fields.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ import (
"github.com/einride/protoc-gen-go-aip-test/internal/onlyif"
"github.com/einride/protoc-gen-go-aip-test/internal/suite"
"github.com/einride/protoc-gen-go-aip-test/internal/util"
"go.einride.tech/aip/fieldbehavior"
"go.einride.tech/aip/reflect/aipreflect"
"google.golang.org/genproto/googleapis/api/annotations"
"google.golang.org/grpc/codes"
"google.golang.org/protobuf/compiler/protogen"
"google.golang.org/protobuf/reflect/protopath"
Expand All @@ -29,6 +31,11 @@ var requiredFields = suite.Test{
Generate: func(f *protogen.GeneratedFile, scope suite.Scope) error {
updateMethod, _ := util.StandardMethod(scope.Service, scope.Resource, aipreflect.MethodTypeUpdate)
util.RangeRequiredFields(scope.Message.Desc, func(p protopath.Path, field protoreflect.FieldDescriptor) {
if fieldbehavior.Has(field, annotations.FieldBehavior_IMMUTABLE) {
// ignore IMMUTABLE fields
return
}

// strip root step
p = p[1:]
containerPath := p[:len(p)-1]
Expand Down
19 changes: 0 additions & 19 deletions proto/gen/einride/example/freight/v1/freight_service_aiptest.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 6c097c1

Please sign in to comment.