-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added Nil Check for Package in File Descriptor #3223
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -189,6 +189,28 @@ func TestResolveFileDescriptors(t *testing.T) { | |||||
services: []string{}, | ||||||
expectedDescriptors: 0, | ||||||
}, | ||||||
{ | ||||||
name: "NoPackage", | ||||||
services: []string{"Service1", "Service2"}, | ||||||
expectedDescriptors: 2, | ||||||
}, | ||||||
{ | ||||||
name: "NoPackageDeduplicateServices", | ||||||
services: []string{"Service1", "Service2", "Service1"}, | ||||||
expectedDescriptors: 2, | ||||||
}, | ||||||
{ | ||||||
name: "MixPackage", | ||||||
pkgs: []string{"mypkg1"}, | ||||||
services: []string{"Service1", "Service2"}, | ||||||
expectedDescriptors: 2, | ||||||
}, | ||||||
{ | ||||||
name: "MixPackageDeduplicateServices", | ||||||
pkgs: []string{"mypkg1"}, | ||||||
services: []string{"Service1", "Service2", "Service1"}, | ||||||
expectedDescriptors: 2, | ||||||
}, | ||||||
} | ||||||
|
||||||
for _, tt := range tests { | ||||||
|
@@ -199,10 +221,16 @@ func TestResolveFileDescriptors(t *testing.T) { | |||||
lsr = &reflectpb.ListServiceResponse{} | ||||||
mock = &getServiceFileDescriptorMock{} | ||||||
) | ||||||
|
||||||
var pkg string | ||||||
if len(tt.pkgs) == 1 { | ||||||
pkg = tt.pkgs[0] | ||||||
} | ||||||
|
||||||
Comment on lines
+225
to
+229
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm for completely removing this, every service should have an equivalent package defined (empty or non-empty), in this way we can remove any eventual confusion. |
||||||
for i, service := range tt.services { | ||||||
// if only one package is defined then | ||||||
// the package is the same for every service | ||||||
Comment on lines
231
to
232
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
pkg := tt.pkgs[0] | ||||||
|
||||||
if len(tt.pkgs) > 1 { | ||||||
pkg = tt.pkgs[i] | ||||||
} | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it is clear enough in this way because we already use undefined when we want to reuse for all of them. We could use an empty string for defining a no package.