(t *testing.T)
| 11 | ) |
| 12 | |
| 13 | func TestWarnMatchedProvisioners(t *testing.T) { |
| 14 | t.Parallel() |
| 15 | |
| 16 | for _, tt := range []struct { |
| 17 | name string |
| 18 | mp *codersdk.MatchedProvisioners |
| 19 | job codersdk.ProvisionerJob |
| 20 | expect string |
| 21 | }{ |
| 22 | { |
| 23 | name: "no_match", |
| 24 | mp: &codersdk.MatchedProvisioners{ |
| 25 | Count: 0, |
| 26 | Available: 0, |
| 27 | }, |
| 28 | job: codersdk.ProvisionerJob{ |
| 29 | Status: codersdk.ProvisionerJobPending, |
| 30 | }, |
| 31 | expect: `there are no provisioners that accept the required tags`, |
| 32 | }, |
| 33 | { |
| 34 | name: "no_available", |
| 35 | mp: &codersdk.MatchedProvisioners{ |
| 36 | Count: 1, |
| 37 | Available: 0, |
| 38 | }, |
| 39 | job: codersdk.ProvisionerJob{ |
| 40 | Status: codersdk.ProvisionerJobPending, |
| 41 | }, |
| 42 | expect: `Provisioners that accept the required tags have not responded for longer than expected`, |
| 43 | }, |
| 44 | { |
| 45 | name: "match", |
| 46 | mp: &codersdk.MatchedProvisioners{ |
| 47 | Count: 1, |
| 48 | Available: 1, |
| 49 | }, |
| 50 | job: codersdk.ProvisionerJob{ |
| 51 | Status: codersdk.ProvisionerJobPending, |
| 52 | }, |
| 53 | }, |
| 54 | { |
| 55 | name: "not_pending", |
| 56 | mp: &codersdk.MatchedProvisioners{}, |
| 57 | job: codersdk.ProvisionerJob{ |
| 58 | Status: codersdk.ProvisionerJobRunning, |
| 59 | }, |
| 60 | }, |
| 61 | } { |
| 62 | t.Run(tt.name, func(t *testing.T) { |
| 63 | t.Parallel() |
| 64 | var w strings.Builder |
| 65 | cliutil.WarnMatchedProvisioners(&w, tt.mp, tt.job) |
| 66 | if tt.expect != "" { |
| 67 | require.Contains(t, w.String(), tt.expect) |
| 68 | } else { |
| 69 | require.Empty(t, w.String()) |
| 70 | } |
nothing calls this directly
no test coverage detected