MCPcopy Index your code
hub / github.com/coder/coder / TestGetProvisionerJobsByIDsWithQueuePosition

Function TestGetProvisionerJobsByIDsWithQueuePosition

coderd/database/querier_test.go:4695–5026  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

4693}
4694
4695func TestGetProvisionerJobsByIDsWithQueuePosition(t *testing.T) {
4696 t.Parallel()
4697
4698 testCases := []struct {
4699 name string
4700 jobTags []database.StringMap
4701 daemonTags []database.StringMap
4702 queueSizes []int64
4703 queuePositions []int64
4704 // GetProvisionerJobsByIDsWithQueuePosition takes jobIDs as a parameter.
4705 // If skipJobIDs is empty, all jobs are passed to the function; otherwise, the specified jobs are skipped.
4706 // NOTE: Skipping job IDs means they will be excluded from the result,
4707 // but this should not affect the queue position or queue size of other jobs.
4708 skipJobIDs map[int]struct{}
4709 }{
4710 // Baseline test case
4711 {
4712 name: "test-case-1",
4713 jobTags: []database.StringMap{
4714 {"a": "1", "b": "2"},
4715 {"a": "1"},
4716 {"a": "1", "c": "3"},
4717 },
4718 daemonTags: []database.StringMap{
4719 {"a": "1", "b": "2"},
4720 {"a": "1"},
4721 },
4722 queueSizes: []int64{2, 2, 0},
4723 queuePositions: []int64{1, 1, 0},
4724 },
4725 // Includes an additional provisioner
4726 {
4727 name: "test-case-2",
4728 jobTags: []database.StringMap{
4729 {"a": "1", "b": "2"},
4730 {"a": "1"},
4731 {"a": "1", "c": "3"},
4732 },
4733 daemonTags: []database.StringMap{
4734 {"a": "1", "b": "2"},
4735 {"a": "1"},
4736 {"a": "1", "b": "2", "c": "3"},
4737 },
4738 queueSizes: []int64{3, 3, 3},
4739 queuePositions: []int64{1, 1, 3},
4740 },
4741 // Skips job at index 0
4742 {
4743 name: "test-case-3",
4744 jobTags: []database.StringMap{
4745 {"a": "1", "b": "2"},
4746 {"a": "1"},
4747 {"a": "1", "c": "3"},
4748 },
4749 daemonTags: []database.StringMap{
4750 {"a": "1", "b": "2"},
4751 {"a": "1"},
4752 {"a": "1", "b": "2", "c": "3"},

Callers

nothing calls this directly

Calls 11

NewDBFunction · 0.92
NowFunction · 0.92
ContextFunction · 0.92
ProvisionerJobFunction · 0.92
ProvisionerDaemonFunction · 0.92
DurationMethod · 0.80
RunMethod · 0.65
AddMethod · 0.65
EqualMethod · 0.45
LenMethod · 0.45

Tested by

no test coverage detected