Repository: kubernetes/kubernetes
File: pkg/scheduler/backend/queue/unschedulable_pods_test.go (Go)

Code before:
		Update: func(pInfo *framework.QueuedPodInfo, upm *unschedulablePods, gatedBefore bool) {
			upm.addOrUpdate(pInfo, gatedBefore, framework.EventUnscheduledPodUpdate.Label())
		},
		Delete: func(pInfo *framework.QueuedPodInfo, upm *unschedulablePods, gatedBefore bool) {
			upm.delete(pInfo.Pod, gatedBefore)
		},
		Clear: func(_ *framework.QueuedPodInfo, upm *unschedulablePods, _ bool) {
			upm.clear()
		},
	}

	var pods = []*v1.Pod{
		st.MakePod().Name("p0").Namespace("ns1").Annotation("annot1", "val1").NominatedNodeName("node1").Obj(),
		st.MakePod().Name("p1").Namespace("ns1").Annotation("annot", "val").Obj(),
		st.MakePod().Name("p2").Namespace("ns2").Annotation("annot2", "val2").Annotation("annot3", "val3").NominatedNodeName("node3").Obj(),
		st.MakePod().Name("p3").Namespace("ns1").Annotation("annot4", "val4").Obj(),
		st.MakePod().Name("p4").Namespace("ns2").Annotation("annot5", "val5").NominatedNodeName("node4").Obj(),
		st.MakePod().Name("p5").Namespace("ns1").Annotation("annot6", "val6").Obj(),
	}

	gated := func(p *v1.Pod, upm *unschedulablePods) bool {
		pInfo := upm.get(p)
		return pInfo != nil && pInfo.Gated()
	}

	makeInfo := func(p *v1.Pod, gated bool) *framework.QueuedPodInfo {
		info := &framework.QueuedPodInfo{
			PodInfo:              mustNewTestPodInfo(t, p),
			UnschedulablePlugins: sets.New[string](),
		}
		if gated {
			info.GatingPlugin = "test"
			info.UnschedulablePlugins.Insert("test")
		}
		return info
	}

	tests := []struct {
		name  string
		steps []step
	}{
		{
			name: "create, update, delete subset of pods",
			steps: []step{
				{
					Action: Add,
					Pods:   []*framework.QueuedPodInfo{makeInfo(pods[0], false), makeInfo(pods[1], false), makeInfo(pods[2], false), makeInfo(pods[2], false), makeInfo(pods[3], false)},
					ExpectedMap: map[string]*framework.QueuedPodInfo{
						util.GetPodFullName(pods[0]): makeInfo(pods[0], false),
						util.GetPodFullName(pods[1]): makeInfo(pods[1], false),
						util.GetPodFullName(pods[2]): makeInfo(pods[2], false),

Review comment (suggestion):
```suggestion
	makePodInfo := func(p *v1.Pod, gated bool) *framework.QueuedPodInfo {
```

Code after:
		add: func(upm *unschedulablePods, pInfo *framework.QueuedPodInfo, _ bool) {
			upm.addOrUpdate(pInfo, false, framework.EventUnscheduledPodAdd.Label())
		},
		update: func(upm *unschedulablePods, pInfo *framework.QueuedPodInfo, gatedBefore bool) {
			upm.addOrUpdate(pInfo, gatedBefore, framework.EventUnscheduledPodUpdate.Label())
		},
		delete: func(upm *unschedulablePods, pInfo *framework.QueuedPodInfo, gatedBefore bool) {
			upm.delete(pInfo.Pod, gatedBefore)
		},
		clear: func(upm *unschedulablePods, _ *framework.QueuedPodInfo, _ bool) {
			upm.clear()
		},
	}

	var pods = []*v1.Pod{
		st.MakePod().Name("p0").Namespace("ns1").Annotation("annot1", "val1").NominatedNodeName("node1").Obj(),
		st.MakePod().Name("p1").Namespace("ns1").Annotation("annot", "val").Obj(),
		st.MakePod().Name("p2").Namespace("ns2").Annotation("annot2", "val2").Annotation("annot3", "val3").NominatedNodeName("node3").Obj(),
		st.MakePod().Name("p3").Namespace("ns1").Annotation("annot4", "val4").Obj(),
		st.MakePod().Name("p4").Namespace("ns2").Annotation("annot5", "val5").NominatedNodeName("node4").Obj(),
		st.MakePod().Name("p5").Namespace("ns1").Annotation("annot6", "val6").Obj(),
	}

	gated := func(p *v1.Pod, upm *unschedulablePods) bool {
		pInfo := upm.get(p)
		return pInfo != nil && pInfo.Gated()
	}

	makePodInfo := func(p *v1.Pod, gated bool) *framework.QueuedPodInfo {
		info := &framework.QueuedPodInfo{
			PodInfo:              mustNewTestPodInfo(t, p),
			UnschedulablePlugins: sets.New[string](),
		}
		if gated {
			info.GatingPlugin = "test"
			info.UnschedulablePlugins.Insert("test")
		}
		return info
	}

	makePodInfoMap := func(pods []*framework.QueuedPodInfo) map[string]*framework.QueuedPodInfo {
		podInfoMap := make(map[string]*framework.QueuedPodInfo)
		for _, p := range pods {
			podInfoMap[util.GetPodFullName(p.Pod)] = p
		}
		return podInfoMap
	}

	tests := []struct {
		name  string
		steps []step