Change how we test the generateName reactor. (#688)

The 1.14 K8s test libs introduce changes that broke how we were testing this, but it still works in the cases we care about, so this adjusts the test to more accurately test the reactor in the way we actually care about.
This commit is contained in:
Matt Moore 2019-09-16 17:25:45 -07:00 committed by Knative Prow Robot
parent 53eebd4e81
commit 5cdf30f51e
2 changed files with 11 additions and 4 deletions

View File

@ -46,13 +46,11 @@ type GenerateNameReactor struct {
// mocking
func (r *GenerateNameReactor) Handles(action clientgotesting.Action) bool {
create, ok := action.(clientgotesting.CreateAction)
if !ok {
return false
}
objMeta, err := meta.Accessor(create.GetObject())
if err != nil {
return false
}

View File

@ -71,15 +71,24 @@ func TestGenerateNameReactor(t *testing.T) {
lastHandlerInvoked := false
fake := &clientgotesting.Fake{}
var mutated *appsv1.Deployment
fake.AddReactor("*", "*", func(action clientgotesting.Action) (handled bool, ret runtime.Object, err error) {
create, ok := action.(clientgotesting.CreateAction)
if !ok {
return false, nil, nil
}
deploy, ok := create.GetObject().(*appsv1.Deployment)
if !ok {
return false, nil, nil
}
lastHandlerInvoked = true
mutated = deploy
return false, nil, nil
})
PrependGenerateNameReactor(fake)
mutated := tc.deployment.DeepCopy()
action := clientgotesting.NewCreateAction(deploymentsResource, "namespace", mutated)
action := clientgotesting.NewCreateAction(deploymentsResource, "namespace", tc.deployment)
fake.Invokes(action, &appsv1.Deployment{})