cleanup: omit comparison with bool constants
Signed-off-by: tao.yang <tao.yang@daocloud.io> Kubernetes-commit: b35357b6c08f21ba0fd312536051394c2567ec79
This commit is contained in:
parent
611ba24d58
commit
47998d1ee6
|
|
@ -541,9 +541,9 @@ func TestValidateEgressSelectorConfiguration(t *testing.T) {
|
||||||
for _, tc := range testcases {
|
for _, tc := range testcases {
|
||||||
t.Run(tc.name, func(t *testing.T) {
|
t.Run(tc.name, func(t *testing.T) {
|
||||||
errs := ValidateEgressSelectorConfiguration(tc.contents)
|
errs := ValidateEgressSelectorConfiguration(tc.contents)
|
||||||
if tc.expectError == false && len(errs) != 0 {
|
if !tc.expectError && len(errs) != 0 {
|
||||||
t.Errorf("Calling ValidateEgressSelectorConfiguration expected no error, got %v", errs)
|
t.Errorf("Calling ValidateEgressSelectorConfiguration expected no error, got %v", errs)
|
||||||
} else if tc.expectError == true && len(errs) == 0 {
|
} else if tc.expectError && len(errs) == 0 {
|
||||||
t.Errorf("Calling ValidateEgressSelectorConfiguration expected error, got no error")
|
t.Errorf("Calling ValidateEgressSelectorConfiguration expected error, got no error")
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -67,9 +67,9 @@ func TestValidateTracingOptions(t *testing.T) {
|
||||||
for _, tc := range testcases {
|
for _, tc := range testcases {
|
||||||
t.Run(tc.name, func(t *testing.T) {
|
t.Run(tc.name, func(t *testing.T) {
|
||||||
errs := tc.contents.Validate()
|
errs := tc.contents.Validate()
|
||||||
if tc.expectError == false && len(errs) != 0 {
|
if !tc.expectError && len(errs) != 0 {
|
||||||
t.Errorf("Calling Validate expected no error, got %v", errs)
|
t.Errorf("Calling Validate expected no error, got %v", errs)
|
||||||
} else if tc.expectError == true && len(errs) == 0 {
|
} else if tc.expectError && len(errs) == 0 {
|
||||||
t.Errorf("Calling Validate expected error, got no error")
|
t.Errorf("Calling Validate expected error, got no error")
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -485,7 +485,7 @@ func TestCacheWatcherDrainingNoBookmarkAfterResourceVersionReceived(t *testing.T
|
||||||
forget := func(drainWatcher bool) {
|
forget := func(drainWatcher bool) {
|
||||||
lock.Lock()
|
lock.Lock()
|
||||||
defer lock.Unlock()
|
defer lock.Unlock()
|
||||||
if drainWatcher == true {
|
if drainWatcher {
|
||||||
t.Fatalf("didn't expect drainWatcher to be set to true")
|
t.Fatalf("didn't expect drainWatcher to be set to true")
|
||||||
}
|
}
|
||||||
count++
|
count++
|
||||||
|
|
|
||||||
|
|
@ -1252,7 +1252,7 @@ func (c *Cacher) LastSyncResourceVersion() (uint64, error) {
|
||||||
//
|
//
|
||||||
// The returned function must be called under the watchCache lock.
|
// The returned function must be called under the watchCache lock.
|
||||||
func (c *Cacher) getBookmarkAfterResourceVersionLockedFunc(ctx context.Context, parsedResourceVersion uint64, opts storage.ListOptions) (func() uint64, error) {
|
func (c *Cacher) getBookmarkAfterResourceVersionLockedFunc(ctx context.Context, parsedResourceVersion uint64, opts storage.ListOptions) (func() uint64, error) {
|
||||||
if opts.SendInitialEvents == nil || *opts.SendInitialEvents == false || !opts.Predicate.AllowWatchBookmarks {
|
if opts.SendInitialEvents == nil || !*opts.SendInitialEvents || !opts.Predicate.AllowWatchBookmarks {
|
||||||
return func() uint64 { return 0 }, nil
|
return func() uint64 { return 0 }, nil
|
||||||
}
|
}
|
||||||
return c.getCommonResourceVersionLockedFunc(ctx, parsedResourceVersion, opts)
|
return c.getCommonResourceVersionLockedFunc(ctx, parsedResourceVersion, opts)
|
||||||
|
|
@ -1267,7 +1267,7 @@ func (c *Cacher) getBookmarkAfterResourceVersionLockedFunc(ctx context.Context,
|
||||||
//
|
//
|
||||||
// The returned function must be called under the watchCache lock.
|
// The returned function must be called under the watchCache lock.
|
||||||
func (c *Cacher) getStartResourceVersionForWatchLockedFunc(ctx context.Context, parsedWatchResourceVersion uint64, opts storage.ListOptions) (func() uint64, error) {
|
func (c *Cacher) getStartResourceVersionForWatchLockedFunc(ctx context.Context, parsedWatchResourceVersion uint64, opts storage.ListOptions) (func() uint64, error) {
|
||||||
if opts.SendInitialEvents == nil || *opts.SendInitialEvents == true {
|
if opts.SendInitialEvents == nil || *opts.SendInitialEvents {
|
||||||
return func() uint64 { return parsedWatchResourceVersion }, nil
|
return func() uint64 { return parsedWatchResourceVersion }, nil
|
||||||
}
|
}
|
||||||
return c.getCommonResourceVersionLockedFunc(ctx, parsedWatchResourceVersion, opts)
|
return c.getCommonResourceVersionLockedFunc(ctx, parsedWatchResourceVersion, opts)
|
||||||
|
|
@ -1298,7 +1298,7 @@ func (c *Cacher) getCommonResourceVersionLockedFunc(ctx context.Context, parsedW
|
||||||
// Additionally, it instructs the caller whether it should ask for
|
// Additionally, it instructs the caller whether it should ask for
|
||||||
// all events from the cache (full state) or not.
|
// all events from the cache (full state) or not.
|
||||||
func (c *Cacher) waitUntilWatchCacheFreshAndForceAllEvents(ctx context.Context, requestedWatchRV uint64, opts storage.ListOptions) (bool, error) {
|
func (c *Cacher) waitUntilWatchCacheFreshAndForceAllEvents(ctx context.Context, requestedWatchRV uint64, opts storage.ListOptions) (bool, error) {
|
||||||
if opts.SendInitialEvents != nil && *opts.SendInitialEvents == true {
|
if opts.SendInitialEvents != nil && *opts.SendInitialEvents {
|
||||||
err := c.watchCache.waitUntilFreshAndBlock(ctx, requestedWatchRV)
|
err := c.watchCache.waitUntilFreshAndBlock(ctx, requestedWatchRV)
|
||||||
defer c.watchCache.RUnlock()
|
defer c.watchCache.RUnlock()
|
||||||
return err == nil, err
|
return err == nil, err
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue