Skip to content

Commit c476b49

Browse files
liggittk8s-publishing-bot
authored andcommitted
Add GC unit tests
Adds unit tests covering the problematic scenarios identified around conflicting data in child owner references Before After package level 51% 68% garbagecollector.go 60% 75% graph_builder.go 50% 81% graph.go 50% 68% Added/improved coverage of key functions that had lacking unit test coverage: * attemptToDeleteWorker * attemptToDeleteItem * processGraphChanges (added coverage of all added code) Kubernetes-commit: e491c3bc7056530d82590d95f0af0e8c4d8dded5
1 parent 77eda6a commit c476b49

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

Diff for: tools/record/fake.go

+14-2
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,29 @@ import (
2727
// thrown away in this case.
2828
type FakeRecorder struct {
2929
Events chan string
30+
31+
IncludeObject bool
32+
}
33+
34+
func objectString(object runtime.Object, includeObject bool) string {
35+
if !includeObject {
36+
return ""
37+
}
38+
return fmt.Sprintf(" involvedObject{kind=%s,apiVersion=%s}",
39+
object.GetObjectKind().GroupVersionKind().Kind,
40+
object.GetObjectKind().GroupVersionKind().GroupVersion(),
41+
)
3042
}
3143

3244
func (f *FakeRecorder) Event(object runtime.Object, eventtype, reason, message string) {
3345
if f.Events != nil {
34-
f.Events <- fmt.Sprintf("%s %s %s", eventtype, reason, message)
46+
f.Events <- fmt.Sprintf("%s %s %s%s", eventtype, reason, message, objectString(object, f.IncludeObject))
3547
}
3648
}
3749

3850
func (f *FakeRecorder) Eventf(object runtime.Object, eventtype, reason, messageFmt string, args ...interface{}) {
3951
if f.Events != nil {
40-
f.Events <- fmt.Sprintf(eventtype+" "+reason+" "+messageFmt, args...)
52+
f.Events <- fmt.Sprintf(eventtype+" "+reason+" "+messageFmt, args...) + objectString(object, f.IncludeObject)
4153
}
4254
}
4355

0 commit comments

Comments
 (0)