Fix TestProvisioningFactoryReset when running with libfaketime#1371
Fix TestProvisioningFactoryReset when running with libfaketime#1371Danielius1922 merged 1 commit intomainfrom
Conversation
WalkthroughThe changes involve modifying the instantiation of the Changes
Possibly related PRs
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
c5a82d3 to
e1e3612
Compare
e1e3612 to
74aa474
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (11)
- cloud2cloud-connector/service/pull.go (4 hunks)
- cloud2cloud-connector/service/retrieveResource.go (2 hunks)
- cloud2cloud-connector/service/updateResource.go (2 hunks)
- cloud2cloud-gateway/store/mongodb/store.go (2 hunks)
- device-provisioning-service/service/provision_test.go (1 hunks)
- resource-aggregate/cqrs/aggregate/aggregate.go (2 hunks)
- resource-aggregate/cqrs/eventstore/cqldb/load.go (2 hunks)
- resource-aggregate/cqrs/eventstore/mongodb/load.go (5 hunks)
- resource-aggregate/cqrs/eventstore/mongodb/maintenance.go (2 hunks)
- resource-aggregate/cqrs/utils/utils.go (2 hunks)
- tools/mongodb/standby-tool/main.go (1 hunks)
Files skipped from review as they are similar to previous changes (1)
- device-provisioning-service/service/provision_test.go
Additional context used
Learnings (1)
tools/mongodb/standby-tool/main.go (1)
Learnt from: jkralik PR: plgd-dev/hub#1365 File: tools/mongodb/standby-tool/main.go:505-505 Timestamp: 2024-08-21T19:04:41.104Z Learning: The `//nolint:gosec` directive in the `tools/mongodb/standby-tool/main.go` file is necessary for Golangci-lint and should not be removed.
Additional comments not posted (15)
cloud2cloud-gateway/store/mongodb/store.go (2)
9-9: LGTM!The import statement for the
mathpackage is valid and follows the correct syntax.
55-55: LGTM!The changes to the return statement are approved for the following reasons:
- The usage of the
math.CastTofunction for type casting enhances type safety and clarity.- The function call syntax is correct and the types are properly specified.
- The subtraction of 1 from the casted value is performed correctly.
cloud2cloud-connector/service/retrieveResource.go (1)
70-70: LGTM, but verify the behavior ofmath.CastTo.The change introduces a utility function
math.CastTofor type casting, which may provide additional type safety or functionality compared to direct type conversion.However, ensure that the behavior of
math.CastToaligns with the expected functionality of converting the current timestamp in nanoseconds touint64.Run the following script to verify the behavior of
math.CastTo:Verification successful
The use of
math.CastTois correct and aligns with the expected functionality.The
math.CastTofunction is a generic utility for casting between integer types, ensuring type safety. It correctly converts the current timestamp in nanoseconds touint64, maintaining the intended functionality.
- Implementation of
math.CastTo:
- File:
internal/math/cast.go- Function:
func CastTo[T, F constraints.Integer](from F) T { return T(from) }Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the behavior of `math.CastTo` for converting int64 to uint64. # Test: Search for the implementation of `math.CastTo`. Expect: The function should correctly convert int64 to uint64. ast-grep --lang go --pattern $'func CastTo[$_]($_) $_ { $$$ }'Length of output: 205
resource-aggregate/cqrs/eventstore/mongodb/maintenance.go (1)
90-90: LGTM!The change to use the
math.CastTo[uint64]function for type casting enhances type safety and is consistent with the AI-generated summary.cloud2cloud-connector/service/updateResource.go (1)
92-92: LGTM!The change to use
math.CastTo[uint64](time.Now().UnixNano())for populating theSequencefield in theCommandMetadatastruct is an improvement over the previous approach. It enhances type safety and consistency in handling type conversions across the codebase by leveraging a dedicated casting function from themathpackage.The overall logic of the function remains intact, and the change only refines the method of obtaining the
Sequencevalue.resource-aggregate/cqrs/utils/utils.go (1)
83-84: LGTM!The changes to the
TimeNowMsfunction are approved.The modifications simplify the function implementation, making it more readable and efficient. The use of the
math.CastTo[uint64]function enhances type safety and clarity regarding the expected return type.resource-aggregate/cqrs/eventstore/cqldb/load.go (2)
12-12: LGTM!The addition of the
mathpackage import is approved.
87-87: LGTM!The modification of the type conversion from
uint64(version)tomath.CastTo[uint64](version)is approved.The change enhances type safety and robustness by leveraging the functionality provided by the
mathpackage.resource-aggregate/cqrs/aggregate/aggregate.go (1)
205-206: LGTM!The change enhances type safety by explicitly converting the length of
newEventstouint64before adding it tonewVersion. This may prevent potential issues related to type mismatches and refines the logic for snapshot handling, emphasizing type correctness.The code changes are approved.
cloud2cloud-connector/service/pull.go (3)
123-123: LGTM!The change to use the
math.CastTofunction for type conversion is approved. It enhances type safety and provides a consistent approach to handling type conversions.
238-238: LGTM!The change to use the
math.CastTofunction for type conversion is approved. It enhances type safety and provides a consistent approach to handling type conversions.
307-307: LGTM!The change to use the
math.CastTofunction for type conversion is approved. It enhances type safety and provides a consistent approach to handling type conversions.resource-aggregate/cqrs/eventstore/mongodb/load.go (3)
Line range hint
74-83: LGTM!The changes to the
getEventmethod are approved:
- The return type has been correctly updated to use
uint64for the version.- The
math.CastTo[uint64]function is used to safely cast the version fromint64touint64.
86-88: LGTM!The changes to the
nextEventmethod are approved:
- The return type has been correctly updated to use
uint64for the version.
189-200: LGTM!The changes to the
checkmethod are approved:
- The
versionparameter type has been correctly updated touint64.- Removing the explicit type conversion when comparing
versionagainstvimproves code readability and is safe since both are now of the same type.
|



No description provided.