Repository: hashicorp/nomad
File: scheduler/rank_test.go (Go)

Code before:
		Namespace:          structs.DefaultNamespace,
		ID:                 uuid.Generate(),
		EvalID:             uuid.Generate(),
		NodeID:             nodes[0].Node.ID,
		JobID:              j1.ID,
		Job:                j1,
		AllocatedResources: &structs.AllocatedResources{},
		DesiredStatus:      structs.AllocDesiredStatusRun,
		ClientStatus:       structs.AllocClientStatusPending,
		TaskGroup:          "web",
	}
	alloc2 := &structs.Allocation{
		Namespace:          structs.DefaultNamespace,
		ID:                 uuid.Generate(),
		EvalID:             uuid.Generate(),
		NodeID:             nodes[1].Node.ID,
		JobID:              j2.ID,
		Job:                j2,
		AllocatedResources: &structs.AllocatedResources{},
		DesiredStatus:      structs.AllocDesiredStatusRun,
		ClientStatus:       structs.AllocClientStatusPending,
		TaskGroup:          "web",
	}
	require.NoError(t, state.UpsertJobSummary(998, mock.JobSummary(alloc1.JobID)))
	require.NoError(t, state.UpsertJobSummary(999, mock.JobSummary(alloc2.JobID)))
	require.NoError(t, state.UpsertAllocs(structs.MsgTypeTestSetup, 1000, []*structs.Allocation{alloc1, alloc2}))

	testCases := []struct {
		name          string
		maxAllocNode1 int
		maxAllocNode2 int
		tasks         []*structs.Task
		tasksOn1      int
		nodesPlaced   int
		noNodes       bool
	}{
		{
			name:          "both_nodes",
			maxAllocNode1: 2,
			maxAllocNode2: 2,
			tasks: []*structs.Task{
				taskGen("web1"),
				taskGen("web2"),
				taskGen("web3")},
			nodesPlaced: 2,
		},
		{
			name:          "only_node2",
			maxAllocNode1: 1,
			maxAllocNode2: 2,
			tasks: []*structs.Task{

Review comment (suggestion):
```suggestion
	must.NoError(t, state.UpsertJobSummary(998, mock.JobSummary(alloc1.JobID)))
	must.NoError(t, state.UpsertJobSummary(999, mock.JobSummary(alloc2.JobID)))
	must.NoError(t, state.UpsertAllocs(structs.MsgTypeTestSetup, 1000, []*structs.Allocation{alloc1, alloc2}))
```

Code after:
		Namespace:          structs.DefaultNamespace,
		ID:                 uuid.Generate(),
		EvalID:             uuid.Generate(),
		NodeID:             nodes[0].Node.ID,
		JobID:              j1.ID,
		Job:                j1,
		AllocatedResources: &structs.AllocatedResources{},
		DesiredStatus:      structs.AllocDesiredStatusRun,
		ClientStatus:       structs.AllocClientStatusPending,
		TaskGroup:          "web",
	}
	alloc2 := &structs.Allocation{
		Namespace:          structs.DefaultNamespace,
		ID:                 uuid.Generate(),
		EvalID:             uuid.Generate(),
		NodeID:             nodes[1].Node.ID,
		JobID:              j2.ID,
		Job:                j2,
		AllocatedResources: &structs.AllocatedResources{},
		DesiredStatus:      structs.AllocDesiredStatusRun,
		ClientStatus:       structs.AllocClientStatusPending,
		TaskGroup:          "web",
	}
	must.NoError(t, state.UpsertJobSummary(998, mock.JobSummary(alloc1.JobID)))
	must.NoError(t, state.UpsertJobSummary(999, mock.JobSummary(alloc2.JobID)))
	must.NoError(t, state.UpsertAllocs(structs.MsgTypeTestSetup, 1000, []*structs.Allocation{alloc1, alloc2}))

	testCases := []struct {
		name          string
		maxAllocNode1 int
		maxAllocNode2 int
		tasks         []*structs.Task
		tasksOn1      int
		nodesPlaced   int
		noNodes       bool
	}{
		{
			name:          "both_nodes",
			maxAllocNode1: 2,
			maxAllocNode2: 2,
			tasks: []*structs.Task{
				taskGen("web1"),
				taskGen("web2"),
				taskGen("web3")},
			nodesPlaced: 2,
		},
		{
			name:          "only_node2",
			maxAllocNode1: 1,
			maxAllocNode2: 2,
			tasks: []*structs.Task{