gemini-code-assist[bot] commented on code in PR #38754:
URL: https://github.com/apache/beam/pull/38754#discussion_r3331039197
##########
sdks/go/pkg/beam/runners/dataflow/dataflowlib/job_test.go:
##########
@@ -312,6 +313,14 @@ func TestTranslate(t *testing.T) {
if wp.DiskProvisionedThroughputMibps != 200 {
t.Errorf("DiskProvisionedThroughputMibps = %v, want 200",
wp.DiskProvisionedThroughputMibps)
}
+
+ // Verify worker package has Sha256
+ if len(wp.Packages) != 1 {
+ t.Fatalf("len(wp.Packages) = %v, want 1", len(wp.Packages))
+ }
+ if wp.Packages[0].Name != "worker" || wp.Packages[0].Sha256 !=
"worker-sha256-hash" {
+ t.Errorf("wp.Packages[0] = {Name: %q, Sha256: %q}, want {Name:
%q, Sha256: %q}", wp.Packages[0].Name, wp.Packages[0].Sha256, "worker",
"worker-sha256-hash")
+ }
Review Comment:

The current test assertion assumes that the worker package is the only
package in `wp.Packages` and that it is always at index 0. To make the test
more robust against future changes (such as adding default packages or
artifacts), it is better to iterate through the packages to find the one named
`"worker"` and verify its hash.
```go
// Verify worker package has Sha256
found := false
for _, pkg := range wp.Packages {
if pkg.Name == "worker" {
found = true
if pkg.Sha256 != "worker-sha256-hash" {
t.Errorf("worker package Sha256 = %q, want %q",
pkg.Sha256, "worker-sha256-hash")
}
break
}
}
if !found {
t.Fatalf("worker package not found in wp.Packages")
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]