MCPcopy Create free account
hub / github.com/exercism/cli / TestUpgrade

Function TestUpgrade

cmd/upgrade_test.go:23–54  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

21}
22
23func 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}

Callers

nothing calls this directly

Calls 4

newCapturedOutputFunction · 0.85
updateCLIFunction · 0.85
overrideMethod · 0.80
resetMethod · 0.80

Tested by

no test coverage detected