MCPcopy Index your code
hub / github.com/riverqueue/river / TestClient_JobTimeout

Function TestClient_JobTimeout

client_test.go:8718–8788  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

8716}
8717
8718func TestClient_JobTimeout(t *testing.T) {
8719 t.Parallel()
8720
8721 tests := []struct {
8722 name string
8723 jobArgTimeout time.Duration
8724 clientJobTimeout time.Duration
8725 wantDuration time.Duration
8726 }{
8727 {
8728 name: "ClientJobTimeoutIsUsedIfJobArgTimeoutIsZero",
8729 jobArgTimeout: 0,
8730 clientJobTimeout: time.Hour,
8731 wantDuration: time.Hour,
8732 },
8733 {
8734 name: "JobArgTimeoutTakesPrecedenceIfBothAreSet",
8735 jobArgTimeout: 2 * time.Hour,
8736 clientJobTimeout: time.Hour,
8737 wantDuration: 2 * time.Hour,
8738 },
8739 {
8740 name: "DefaultJobTimeoutIsUsedIfBothAreZero",
8741 jobArgTimeout: 0,
8742 clientJobTimeout: 0,
8743 wantDuration: JobTimeoutDefault,
8744 },
8745 {
8746 name: "NoJobTimeoutIfClientIsNegativeOneAndJobArgIsZero",
8747 jobArgTimeout: 0,
8748 clientJobTimeout: -1,
8749 wantDuration: 0, // infinite
8750 },
8751 {
8752 name: "NoJobTimeoutIfJobArgIsNegativeOne",
8753 jobArgTimeout: -1,
8754 clientJobTimeout: time.Hour,
8755 wantDuration: 0, // infinite
8756 },
8757 }
8758
8759 for _, tt := range tests {
8760 t.Run(tt.name, func(t *testing.T) {
8761 t.Parallel()
8762
8763 ctx := context.Background()
8764
8765 testWorker := &timeoutTestWorker{doneCh: make(chan testWorkerDeadline)}
8766
8767 workers := NewWorkers()
8768 AddWorker(workers, testWorker)
8769
8770 config := newTestConfig(t, "")
8771 config.JobTimeout = tt.clientJobTimeout
8772 config.Queues = map[string]QueueConfig{QueueDefault: {MaxWorkers: 1}}
8773 config.Workers = workers
8774
8775 client := runNewTestClient(ctx, t, config)

Callers

nothing calls this directly

Calls 9

WaitOrTimeoutFunction · 0.92
NewWorkersFunction · 0.85
AddWorkerFunction · 0.85
runNewTestClientFunction · 0.85
InsertMethod · 0.80
newTestConfigFunction · 0.70
RunMethod · 0.65
NowMethod · 0.65
AddMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…