Add a fake scheduler
To allow for testing whether an item gets re-queued in unit tests Signed-off-by: irbekrm <irbekrm@gmail.com>
This commit is contained in:
parent
1e235c79f2
commit
8d5023a72d
@ -24,7 +24,10 @@ filegroup(
|
||||
|
||||
filegroup(
|
||||
name = "all-srcs",
|
||||
srcs = [":package-srcs"],
|
||||
srcs = [
|
||||
":package-srcs",
|
||||
"//pkg/scheduler/test:all-srcs",
|
||||
],
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
23
pkg/scheduler/test/BUILD.bazel
Normal file
23
pkg/scheduler/test/BUILD.bazel
Normal file
@ -0,0 +1,23 @@
|
||||
load("@io_bazel_rules_go//go:def.bzl", "go_library")
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = ["fake.go"],
|
||||
importpath = "github.com/jetstack/cert-manager/pkg/scheduler/test",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = ["//pkg/scheduler:go_default_library"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "package-srcs",
|
||||
srcs = glob(["**"]),
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:private"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "all-srcs",
|
||||
srcs = [":package-srcs"],
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
39
pkg/scheduler/test/fake.go
Normal file
39
pkg/scheduler/test/fake.go
Normal file
@ -0,0 +1,39 @@
|
||||
/*
|
||||
Copyright 2020 The cert-manager Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package test
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/jetstack/cert-manager/pkg/scheduler"
|
||||
)
|
||||
|
||||
var _ scheduler.ScheduledWorkQueue = &FakeScheduler{}
|
||||
|
||||
// FakeScheduler allows stubbing the methods of scheduler.ScheduledWorkQueue in tests.
|
||||
type FakeScheduler struct {
|
||||
AddFunc func(interface{}, time.Duration)
|
||||
ForgetFunc func(interface{})
|
||||
}
|
||||
|
||||
func (f *FakeScheduler) Add(obj interface{}, duration time.Duration) {
|
||||
f.AddFunc(obj, duration)
|
||||
}
|
||||
|
||||
func (f *FakeScheduler) Forget(obj interface{}) {
|
||||
f.ForgetFunc(obj)
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user