...
1
2
3
4 package testutil
5
6 import (
7 "testing"
8
9 "github.com/stretchr/testify/assert"
10 "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
11 "sigs.k8s.io/cli-utils/pkg/object/mutation"
12 "sigs.k8s.io/cli-utils/pkg/testutil"
13 )
14
15
16
17
18 func AddApplyTimeMutation(t *testing.T, mutation *mutation.ApplyTimeMutation) testutil.Mutator {
19 return applyTimeMutationMutator{
20 t: t,
21 mutation: mutation,
22 }
23 }
24
25
26
27 type applyTimeMutationMutator struct {
28 t *testing.T
29 mutation *mutation.ApplyTimeMutation
30 }
31
32
33
34 func (a applyTimeMutationMutator) Mutate(u *unstructured.Unstructured) {
35 err := mutation.WriteAnnotation(u, *a.mutation)
36 if !assert.NoError(a.t, err) {
37 a.t.FailNow()
38 }
39 }
40
View as plain text