(t *testing.T)
| 21 | } |
| 22 | |
| 23 | func TestUpgrade(t *testing.T) { |
| 24 | co := newCapturedOutput() |
| 25 | co.override() |
| 26 | defer co.reset() |
| 27 | |
| 28 | testCases := []struct { |
| 29 | desc string |
| 30 | upToDate bool |
| 31 | expected bool |
| 32 | }{ |
| 33 | { |
| 34 | desc: "upgrade should be called for an outdated CLI", |
| 35 | upToDate: false, |
| 36 | expected: true, |
| 37 | }, |
| 38 | { |
| 39 | desc: "upgrade should not be called for an already updated CLI", |
| 40 | upToDate: true, |
| 41 | expected: false, |
| 42 | }, |
| 43 | } |
| 44 | |
| 45 | for _, tc := range testCases { |
| 46 | t.Run(tc.desc, func(t *testing.T) { |
| 47 | fc := &fakeCLI{UpToDate: tc.upToDate} |
| 48 | |
| 49 | err := updateCLI(fc) |
| 50 | assert.NoError(t, err) |
| 51 | assert.Equal(t, tc.expected, fc.UpgradeCalled) |
| 52 | }) |
| 53 | } |
| 54 | } |
nothing calls this directly
no test coverage detected