MCPcopy Create free account
hub / github.com/github/gh-aw / TestShouldCheckForUpdate

Function TestShouldCheckForUpdate

pkg/cli/update_check_test.go:16–124  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

14)
15
16func TestShouldCheckForUpdate(t *testing.T) {
17 // Save original environment
18 origCI := os.Getenv("CI")
19 origMCP := os.Getenv("GH_AW_MCP_SERVER")
20 origGetLastCheckFilePath := getLastCheckFilePathFunc
21 defer func() {
22 os.Setenv("CI", origCI)
23 os.Setenv("GH_AW_MCP_SERVER", origMCP)
24 getLastCheckFilePathFunc = origGetLastCheckFilePath
25 }()
26
27 tests := []struct {
28 name string
29 noCheckUpdate bool
30 ciEnv string
31 mcpEnv string
32 lastCheckTime string
33 expectedResult bool
34 }{
35 {
36 name: "should check when flag is false and no recent check",
37 noCheckUpdate: false,
38 ciEnv: "",
39 mcpEnv: "",
40 lastCheckTime: "",
41 expectedResult: true,
42 },
43 {
44 name: "should not check when flag is true",
45 noCheckUpdate: true,
46 ciEnv: "",
47 mcpEnv: "",
48 lastCheckTime: "",
49 expectedResult: false,
50 },
51 {
52 name: "should not check in CI environment",
53 noCheckUpdate: false,
54 ciEnv: "true",
55 mcpEnv: "",
56 lastCheckTime: "",
57 expectedResult: false,
58 },
59 {
60 name: "should not check in MCP server mode",
61 noCheckUpdate: false,
62 ciEnv: "",
63 mcpEnv: "true",
64 lastCheckTime: "",
65 expectedResult: false,
66 },
67 {
68 name: "should not check when recent check exists",
69 noCheckUpdate: false,
70 ciEnv: "",
71 mcpEnv: "",
72 lastCheckTime: time.Now().Format(time.RFC3339),
73 expectedResult: false,

Callers

nothing calls this directly

Calls 6

shouldCheckForUpdateFunction · 0.85
GetenvMethod · 0.80
SetenvMethod · 0.80
AddMethod · 0.45
RunMethod · 0.45
ErrorfMethod · 0.45

Tested by

no test coverage detected