test(tlv): add unit tests and refactor tlv.go#284
Conversation
83dc49e to
e38eca8
Compare
There was a problem hiding this comment.
Pull request overview
This PR expands and refactors PCEP TLV handling by introducing shared TLV parsing helpers, updating multiple TLV Encode/Decode implementations to use them, and adding extensive table-driven unit tests across TLV types.
Changes:
- Added
decodeTLVLength,paddedLength, andisIPv4Byteshelpers and corresponding unit tests. - Refactored multiple TLV
DecodeFromBytes/Serialize/Len/MarshalLogObjectimplementations to use shared offsets/constants and stricter length validation. - Greatly expanded TLV unit tests (decode/serialize/len/logging + DecodeTLV/DecodeTLVs cases) and added a capability test case for skipping
LSPDBVersion.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/packet/pcep/tlv.go | Refactors TLV parsing/serialization, adds offsets/alignment constants, updates TLV map, and modifies DecodeTLVs logic. |
| pkg/packet/pcep/tlv_common.go | Introduces shared TLV helper utilities (length validation, padding, IPv4-bytes detection). |
| pkg/packet/pcep/tlv_common_test.go | Adds unit tests for the new TLV helper utilities. |
| pkg/packet/pcep/tlv_test.go | Reworks TLV tests into table-driven helpers and adds broad coverage across TLV types and TLV decoding. |
| pkg/packet/pcep/capability_test.go | Adds a test case asserting LSPDBVersion is skipped by PolaCapability. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
c25c1ed to
2b4b27f
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
51c7ae2 to
05215d4
Compare
0209c61 to
960ef02
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
7580e62 to
382e292
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
b813494 to
15d13d9
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…atorAddr Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…e.DecodeFromBytes
…idatePathIdentifier
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
27edcda to
72ddfea
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: tatfujiwara <162294605+tatfujiwara@users.noreply.github.com>
Co-authored-by: tatfujiwara <162294605+tatfujiwara@users.noreply.github.com>
Description
Type of change
Motivation and Context
To increase test coverage and improve readability and maintainability of TLV handling code.
How is This Tested?
go test ./...test/directoryOther Information
No additional information.