(t *testing.T)
| 8716 | } |
| 8717 | |
| 8718 | func 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) |
nothing calls this directly
no test coverage detected
searching dependent graphs…