test(pkg/envoy): add a unit test for `ParseEnvoyServiceNodeID`
adds a test for `ParseEnvoyServiceNodeID` in pkg/envoy/xdsutil_test.go
which checks whether it handles when `serviceNodeID` yields less than
5 chunks on splitting
@@ -396,5 +396,12 @@ var _ = Describe("Test Envoy tools", func() {
Expect(meta.WorkloadKind).To(Equal(""))
Expect(meta.WorkloadName).To(Equal(""))
})
+
+ It("should error when there are less than 5 chunks in the serviceNodeID string", func() {
+ // this 'serviceNodeID' will yield 2 chunks
+ serviceNodeID := "$(POD_UID)/$(POD_NAMESPACE)"
+ _, err := ParseEnvoyServiceNodeID(serviceNodeID)
+ Expect(err).To(HaveOccurred())
+ })
})
})
