Bump github.com/onsi/gomega from 1.34.2 to 1.35.0

Bumps [github.com/onsi/gomega](https://github.com/onsi/gomega) from 1.34.2 to 1.35.0.
- [Release notes](https://github.com/onsi/gomega/releases)
- [Changelog](https://github.com/onsi/gomega/blob/master/CHANGELOG.md)
- [Commits](https://github.com/onsi/gomega/compare/v1.34.2...v1.35.0)

---
updated-dependencies:
- dependency-name: github.com/onsi/gomega
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
This commit is contained in:
dependabot[bot]
2024-10-30 09:06:45 +01:00
committed by Ralf Haferkamp
parent 30f001e3c2
commit 7e5b189685
13 changed files with 96 additions and 121 deletions
+1 -1
View File
@@ -64,7 +64,7 @@ require (
github.com/olekukonko/tablewriter v0.0.5 github.com/olekukonko/tablewriter v0.0.5
github.com/onsi/ginkgo v1.16.5 github.com/onsi/ginkgo v1.16.5
github.com/onsi/ginkgo/v2 v2.20.2 github.com/onsi/ginkgo/v2 v2.20.2
github.com/onsi/gomega v1.34.2 github.com/onsi/gomega v1.35.0
github.com/open-policy-agent/opa v0.69.0 github.com/open-policy-agent/opa v0.69.0
github.com/orcaman/concurrent-map v1.0.0 github.com/orcaman/concurrent-map v1.0.0
github.com/owncloud/libre-graph-api-go v1.0.5-0.20240829135935-80dc00d6f5ea github.com/owncloud/libre-graph-api-go v1.0.5-0.20240829135935-80dc00d6f5ea
+2 -2
View File
@@ -875,8 +875,8 @@ github.com/onsi/ginkgo/v2 v2.20.2/go.mod h1:K9gyxPIlb+aIvnZ8bd9Ak+YP18w3APlR+5co
github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY=
github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo=
github.com/onsi/gomega v1.34.2 h1:pNCwDkzrsv7MS9kpaQvVb1aVLahQXyJ/Tv5oAZMI3i8= github.com/onsi/gomega v1.35.0 h1:xuM1M/UvMp9BCdS4hojhS9/4jEuVqS9Er3bqupeaoPM=
github.com/onsi/gomega v1.34.2/go.mod h1:v1xfxRgk0KIsG+QOdm7p8UosrOzPYRo60fd3B/1Dukc= github.com/onsi/gomega v1.35.0/go.mod h1:PvZbdDc8J6XJEpDK4HCuRBm8a6Fzp9/DmhC9C7yFlog=
github.com/open-policy-agent/opa v0.69.0 h1:s2igLw2Z6IvGWGuXSfugWkVultDMsM9pXiDuMp7ckWw= github.com/open-policy-agent/opa v0.69.0 h1:s2igLw2Z6IvGWGuXSfugWkVultDMsM9pXiDuMp7ckWw=
github.com/open-policy-agent/opa v0.69.0/go.mod h1:+qyXJGkpEJ6kpB1kGo8JSwHtVXbTdsGdQYPWWNYNj+4= github.com/open-policy-agent/opa v0.69.0/go.mod h1:+qyXJGkpEJ6kpB1kGo8JSwHtVXbTdsGdQYPWWNYNj+4=
github.com/opencontainers/runtime-spec v1.1.0 h1:HHUyrt9mwHUjtasSbXSMvs4cyFxh+Bll4AjJ9odEGpg= github.com/opencontainers/runtime-spec v1.1.0 h1:HHUyrt9mwHUjtasSbXSMvs4cyFxh+Bll4AjJ9odEGpg=
-15
View File
@@ -1,15 +0,0 @@
# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib
# Test binary, built with `go test -c`
*.test
# Output of the go coverage tool, specifically when used with LiteIDE
*.out
# Dependency directories (remove the comment below to include it)
# vendor/
-65
View File
@@ -1,65 +0,0 @@
# automemlimit
[![Go Reference](https://pkg.go.dev/badge/github.com/KimMachineGun/automemlimit.svg)](https://pkg.go.dev/github.com/KimMachineGun/automemlimit)
[![Go Report Card](https://goreportcard.com/badge/github.com/KimMachineGun/automemlimit)](https://goreportcard.com/report/github.com/KimMachineGun/automemlimit)
[![Test](https://github.com/KimMachineGun/automemlimit/actions/workflows/test.yml/badge.svg?branch=main)](https://github.com/KimMachineGun/automemlimit/actions/workflows/test.yml)
Automatically set `GOMEMLIMIT` to match Linux [cgroups(7)](https://man7.org/linux/man-pages/man7/cgroups.7.html) memory limit.
See more details about `GOMEMLIMIT` [here](https://tip.golang.org/doc/gc-guide#Memory_limit).
## Notice
Version `v0.5.0` introduces a fallback to system memory limits as an experimental feature when cgroup limits are unavailable. Activate this by setting `AUTOMEMLIMIT_EXPERIMENT=system`.
You can also use system memory limits via `memlimit.FromSystem` provider directly.
This feature is under evaluation and might become a default or be removed based on user feedback.
If you have any feedback about this feature, please open an issue.
## Installation
```shell
go get github.com/KimMachineGun/automemlimit@latest
```
## Usage
```go
package main
// By default, it sets `GOMEMLIMIT` to 90% of cgroup's memory limit.
// This is equivalent to `memlimit.SetGoMemLimitWithOpts(memlimit.WithLogger(slog.Default()))`
// To disable logging, use `memlimit.SetGoMemLimitWithOpts` directly.
import _ "github.com/KimMachineGun/automemlimit"
```
or
```go
package main
import "github.com/KimMachineGun/automemlimit/memlimit"
func init() {
memlimit.SetGoMemLimitWithOpts(
memlimit.WithRatio(0.9),
memlimit.WithProvider(memlimit.FromCgroup),
memlimit.WithLogger(slog.Default()),
)
memlimit.SetGoMemLimitWithOpts(
memlimit.WithRatio(0.9),
memlimit.WithProvider(
memlimit.ApplyFallback(
memlimit.FromCgroup,
memlimit.FromSystem,
),
),
)
memlimit.SetGoMemLimit(0.9)
memlimit.SetGoMemLimitWithProvider(memlimit.Limit(1024*1024), 0.9)
memlimit.SetGoMemLimitWithProvider(memlimit.FromCgroup, 0.9)
memlimit.SetGoMemLimitWithProvider(memlimit.FromCgroupV1, 0.9)
memlimit.SetGoMemLimitWithProvider(memlimit.FromCgroupHybrid, 0.9)
memlimit.SetGoMemLimitWithProvider(memlimit.FromCgroupV2, 0.9)
}
```
-13
View File
@@ -1,13 +0,0 @@
package automemlimit
import (
"log/slog"
"github.com/KimMachineGun/automemlimit/memlimit"
)
func init() {
memlimit.SetGoMemLimitWithOpts(
memlimit.WithLogger(slog.Default()),
)
}
+15
View File
@@ -1,3 +1,18 @@
## 1.35.0
### Features
- You can now call `EnforceDefaultTimeoutsWhenUsingContexts()` to have `Eventually` honor the default timeout when passed a context. (prior to this you had to expclility add a timeout) [e4c4265]
- You can call `StopTrying(message).Successfully()` to abort a `Consistently` early without failure [eeca931]
### Fixes
- Stop memoizing the result of `HaveField` to avoid unexpected errors when used with async assertions. [3bdbc4e]
### Maintenance
- Bump all dependencies [a05a416]
## 1.34.2 ## 1.34.2
Require Go 1.22+ Require Go 1.22+
+14 -2
View File
@@ -22,7 +22,7 @@ import (
"github.com/onsi/gomega/types" "github.com/onsi/gomega/types"
) )
const GOMEGA_VERSION = "1.34.2" const GOMEGA_VERSION = "1.35.0"
const nilGomegaPanic = `You are trying to make an assertion, but haven't registered Gomega's fail handler. const nilGomegaPanic = `You are trying to make an assertion, but haven't registered Gomega's fail handler.
If you're using Ginkgo then you probably forgot to put your assertion in an It(). If you're using Ginkgo then you probably forgot to put your assertion in an It().
@@ -319,7 +319,19 @@ you an also use Eventually().WithContext(ctx) to pass in the context. Passed-in
Eventually(client.FetchCount).WithContext(ctx).WithArguments("/users").Should(BeNumerically(">=", 17)) Eventually(client.FetchCount).WithContext(ctx).WithArguments("/users").Should(BeNumerically(">=", 17))
}, SpecTimeout(time.Second)) }, SpecTimeout(time.Second))
Either way the context passd to Eventually is also passed to the underlying function. Now, when Ginkgo cancels the context both the FetchCount client and Gomega will be informed and can exit. Either way the context pasesd to Eventually is also passed to the underlying function. Now, when Ginkgo cancels the context both the FetchCount client and Gomega will be informed and can exit.
By default, when a context is passed to Eventually *without* an explicit timeout, Gomega will rely solely on the context's cancellation to determine when to stop polling. If you want to specify a timeout in addition to the context you can do so using the .WithTimeout() method. For example:
Eventually(client.FetchCount).WithContext(ctx).WithTimeout(10*time.Second).Should(BeNumerically(">=", 17))
now either the context cacnellation or the timeout will cause Eventually to stop polling.
If, instead, you would like to opt out of this behavior and have Gomega's default timeouts govern Eventuallys that take a context you can call:
EnforceDefaultTimeoutsWhenUsingContexts()
in the DSL (or on a Gomega instance). Now all calls to Eventually that take a context will fail if eitehr the context is cancelled or the default timeout elapses.
**Category 3: Making assertions _in_ the function passed into Eventually** **Category 3: Making assertions _in_ the function passed into Eventually**
+10 -2
View File
@@ -335,7 +335,7 @@ func (assertion *AsyncAssertion) afterTimeout() <-chan time.Time {
if assertion.asyncType == AsyncAssertionTypeConsistently { if assertion.asyncType == AsyncAssertionTypeConsistently {
return time.After(assertion.g.DurationBundle.ConsistentlyDuration) return time.After(assertion.g.DurationBundle.ConsistentlyDuration)
} else { } else {
if assertion.ctx == nil { if assertion.ctx == nil || assertion.g.DurationBundle.EnforceDefaultTimeoutsWhenUsingContexts {
return time.After(assertion.g.DurationBundle.EventuallyTimeout) return time.After(assertion.g.DurationBundle.EventuallyTimeout)
} else { } else {
return nil return nil
@@ -496,7 +496,15 @@ func (assertion *AsyncAssertion) match(matcher types.GomegaMatcher, desiredMatch
for _, err := range []error{actualErr, matcherErr} { for _, err := range []error{actualErr, matcherErr} {
if pollingSignalErr, ok := AsPollingSignalError(err); ok { if pollingSignalErr, ok := AsPollingSignalError(err); ok {
if pollingSignalErr.IsStopTrying() { if pollingSignalErr.IsStopTrying() {
fail("Told to stop trying") if pollingSignalErr.IsSuccessful() {
if assertion.asyncType == AsyncAssertionTypeEventually {
fail("Told to stop trying (and ignoring call to Successfully(), as it is only relevant with Consistently)")
} else {
return true // early escape hatch for Consistently
}
} else {
fail("Told to stop trying")
}
return false return false
} }
if pollingSignalErr.IsTryAgainAfter() { if pollingSignalErr.IsTryAgainAfter() {
+11 -6
View File
@@ -8,10 +8,11 @@ import (
) )
type DurationBundle struct { type DurationBundle struct {
EventuallyTimeout time.Duration EventuallyTimeout time.Duration
EventuallyPollingInterval time.Duration EventuallyPollingInterval time.Duration
ConsistentlyDuration time.Duration ConsistentlyDuration time.Duration
ConsistentlyPollingInterval time.Duration ConsistentlyPollingInterval time.Duration
EnforceDefaultTimeoutsWhenUsingContexts bool
} }
const ( const (
@@ -20,15 +21,19 @@ const (
ConsistentlyDurationEnvVarName = "GOMEGA_DEFAULT_CONSISTENTLY_DURATION" ConsistentlyDurationEnvVarName = "GOMEGA_DEFAULT_CONSISTENTLY_DURATION"
ConsistentlyPollingIntervalEnvVarName = "GOMEGA_DEFAULT_CONSISTENTLY_POLLING_INTERVAL" ConsistentlyPollingIntervalEnvVarName = "GOMEGA_DEFAULT_CONSISTENTLY_POLLING_INTERVAL"
EnforceDefaultTimeoutsWhenUsingContextsEnvVarName = "GOMEGA_ENFORCE_DEFAULT_TIMEOUTS_WHEN_USING_CONTEXTS"
) )
func FetchDefaultDurationBundle() DurationBundle { func FetchDefaultDurationBundle() DurationBundle {
_, EnforceDefaultTimeoutsWhenUsingContexts := os.LookupEnv(EnforceDefaultTimeoutsWhenUsingContextsEnvVarName)
return DurationBundle{ return DurationBundle{
EventuallyTimeout: durationFromEnv(EventuallyTimeoutEnvVarName, time.Second), EventuallyTimeout: durationFromEnv(EventuallyTimeoutEnvVarName, time.Second),
EventuallyPollingInterval: durationFromEnv(EventuallyPollingIntervalEnvVarName, 10*time.Millisecond), EventuallyPollingInterval: durationFromEnv(EventuallyPollingIntervalEnvVarName, 10*time.Millisecond),
ConsistentlyDuration: durationFromEnv(ConsistentlyDurationEnvVarName, 100*time.Millisecond), ConsistentlyDuration: durationFromEnv(ConsistentlyDurationEnvVarName, 100*time.Millisecond),
ConsistentlyPollingInterval: durationFromEnv(ConsistentlyPollingIntervalEnvVarName, 10*time.Millisecond), ConsistentlyPollingInterval: durationFromEnv(ConsistentlyPollingIntervalEnvVarName, 10*time.Millisecond),
EnforceDefaultTimeoutsWhenUsingContexts: EnforceDefaultTimeoutsWhenUsingContexts,
} }
} }
+8
View File
@@ -127,3 +127,11 @@ func (g *Gomega) SetDefaultConsistentlyDuration(t time.Duration) {
func (g *Gomega) SetDefaultConsistentlyPollingInterval(t time.Duration) { func (g *Gomega) SetDefaultConsistentlyPollingInterval(t time.Duration) {
g.DurationBundle.ConsistentlyPollingInterval = t g.DurationBundle.ConsistentlyPollingInterval = t
} }
func (g *Gomega) EnforceDefaultTimeoutsWhenUsingContexts() {
g.DurationBundle.EnforceDefaultTimeoutsWhenUsingContexts = true
}
func (g *Gomega) DisableDefaultTimeoutsWhenUsingContext() {
g.DurationBundle.EnforceDefaultTimeoutsWhenUsingContexts = false
}
+11
View File
@@ -17,6 +17,7 @@ type PollingSignalError interface {
error error
Wrap(err error) PollingSignalError Wrap(err error) PollingSignalError
Attach(description string, obj any) PollingSignalError Attach(description string, obj any) PollingSignalError
Successfully() PollingSignalError
Now() Now()
} }
@@ -45,6 +46,7 @@ type PollingSignalErrorImpl struct {
wrappedErr error wrappedErr error
pollingSignalErrorType PollingSignalErrorType pollingSignalErrorType PollingSignalErrorType
duration time.Duration duration time.Duration
successful bool
Attachments []PollingSignalErrorAttachment Attachments []PollingSignalErrorAttachment
} }
@@ -73,6 +75,11 @@ func (s *PollingSignalErrorImpl) Unwrap() error {
return s.wrappedErr return s.wrappedErr
} }
func (s *PollingSignalErrorImpl) Successfully() PollingSignalError {
s.successful = true
return s
}
func (s *PollingSignalErrorImpl) Now() { func (s *PollingSignalErrorImpl) Now() {
panic(s) panic(s)
} }
@@ -81,6 +88,10 @@ func (s *PollingSignalErrorImpl) IsStopTrying() bool {
return s.pollingSignalErrorType == PollingSignalErrorTypeStopTrying return s.pollingSignalErrorType == PollingSignalErrorTypeStopTrying
} }
func (s *PollingSignalErrorImpl) IsSuccessful() bool {
return s.successful
}
func (s *PollingSignalErrorImpl) IsTryAgainAfter() bool { func (s *PollingSignalErrorImpl) IsTryAgainAfter() bool {
return s.pollingSignalErrorType == PollingSignalErrorTypeTryAgainAfter return s.pollingSignalErrorType == PollingSignalErrorTypeTryAgainAfter
} }
+23 -13
View File
@@ -17,7 +17,7 @@ func (e missingFieldError) Error() string {
return string(e) return string(e)
} }
func extractField(actual interface{}, field string, matchername string) (interface{}, error) { func extractField(actual interface{}, field string, matchername string) (any, error) {
fields := strings.SplitN(field, ".", 2) fields := strings.SplitN(field, ".", 2)
actualValue := reflect.ValueOf(actual) actualValue := reflect.ValueOf(actual)
@@ -64,36 +64,46 @@ func extractField(actual interface{}, field string, matchername string) (interfa
type HaveFieldMatcher struct { type HaveFieldMatcher struct {
Field string Field string
Expected interface{} Expected interface{}
}
extractedField interface{} func (matcher *HaveFieldMatcher) expectedMatcher() omegaMatcher {
expectedMatcher omegaMatcher var isMatcher bool
expectedMatcher, isMatcher := matcher.Expected.(omegaMatcher)
if !isMatcher {
expectedMatcher = &EqualMatcher{Expected: matcher.Expected}
}
return expectedMatcher
} }
func (matcher *HaveFieldMatcher) Match(actual interface{}) (success bool, err error) { func (matcher *HaveFieldMatcher) Match(actual interface{}) (success bool, err error) {
matcher.extractedField, err = extractField(actual, matcher.Field, "HaveField") extractedField, err := extractField(actual, matcher.Field, "HaveField")
if err != nil { if err != nil {
return false, err return false, err
} }
var isMatcher bool return matcher.expectedMatcher().Match(extractedField)
matcher.expectedMatcher, isMatcher = matcher.Expected.(omegaMatcher)
if !isMatcher {
matcher.expectedMatcher = &EqualMatcher{Expected: matcher.Expected}
}
return matcher.expectedMatcher.Match(matcher.extractedField)
} }
func (matcher *HaveFieldMatcher) FailureMessage(actual interface{}) (message string) { func (matcher *HaveFieldMatcher) FailureMessage(actual interface{}) (message string) {
extractedField, err := extractField(actual, matcher.Field, "HaveField")
if err != nil {
// this really shouldn't happen
return fmt.Sprintf("Failed to extract field '%s': %s", matcher.Field, err)
}
message = fmt.Sprintf("Value for field '%s' failed to satisfy matcher.\n", matcher.Field) message = fmt.Sprintf("Value for field '%s' failed to satisfy matcher.\n", matcher.Field)
message += matcher.expectedMatcher.FailureMessage(matcher.extractedField) message += matcher.expectedMatcher().FailureMessage(extractedField)
return message return message
} }
func (matcher *HaveFieldMatcher) NegatedFailureMessage(actual interface{}) (message string) { func (matcher *HaveFieldMatcher) NegatedFailureMessage(actual interface{}) (message string) {
extractedField, err := extractField(actual, matcher.Field, "HaveField")
if err != nil {
// this really shouldn't happen
return fmt.Sprintf("Failed to extract field '%s': %s", matcher.Field, err)
}
message = fmt.Sprintf("Value for field '%s' satisfied matcher, but should not have.\n", matcher.Field) message = fmt.Sprintf("Value for field '%s' satisfied matcher, but should not have.\n", matcher.Field)
message += matcher.expectedMatcher.NegatedFailureMessage(matcher.extractedField) message += matcher.expectedMatcher().NegatedFailureMessage(extractedField)
return message return message
} }
+1 -2
View File
@@ -20,7 +20,6 @@ github.com/BurntSushi/toml/internal
github.com/CiscoM31/godata github.com/CiscoM31/godata
# github.com/KimMachineGun/automemlimit v0.6.1 # github.com/KimMachineGun/automemlimit v0.6.1
## explicit; go 1.21 ## explicit; go 1.21
github.com/KimMachineGun/automemlimit
github.com/KimMachineGun/automemlimit/memlimit github.com/KimMachineGun/automemlimit/memlimit
# github.com/Masterminds/goutils v1.1.1 # github.com/Masterminds/goutils v1.1.1
## explicit ## explicit
@@ -1484,7 +1483,7 @@ github.com/onsi/ginkgo/v2/internal/parallel_support
github.com/onsi/ginkgo/v2/internal/testingtproxy github.com/onsi/ginkgo/v2/internal/testingtproxy
github.com/onsi/ginkgo/v2/reporters github.com/onsi/ginkgo/v2/reporters
github.com/onsi/ginkgo/v2/types github.com/onsi/ginkgo/v2/types
# github.com/onsi/gomega v1.34.2 # github.com/onsi/gomega v1.35.0
## explicit; go 1.22 ## explicit; go 1.22
github.com/onsi/gomega github.com/onsi/gomega
github.com/onsi/gomega/format github.com/onsi/gomega/format