(t *testing.T)
| 66 | } |
| 67 | |
| 68 | func TestRunCompileUpdateCheck(t *testing.T) { |
| 69 | originalVersion := GetVersion() |
| 70 | originalRelease := workflow.IsRelease() |
| 71 | originalLatestURL := compileUpdateCheckLatestReleaseURL |
| 72 | originalProbeURLFunc := compileUpdateCheckProbeURLFunc |
| 73 | defer func() { |
| 74 | SetVersionInfo(originalVersion) |
| 75 | workflow.SetIsRelease(originalRelease) |
| 76 | compileUpdateCheckLatestReleaseURL = originalLatestURL |
| 77 | compileUpdateCheckProbeURLFunc = originalProbeURLFunc |
| 78 | }() |
| 79 | |
| 80 | tests := []struct { |
| 81 | name string |
| 82 | currentVersion string |
| 83 | latestVersion string |
| 84 | existingTags map[string]bool |
| 85 | expected *compileUpdateNotification |
| 86 | }{ |
| 87 | { |
| 88 | name: "returns minor version upgrade hint", |
| 89 | currentVersion: "v1.2.3", |
| 90 | latestVersion: "v1.3.0", |
| 91 | existingTags: map[string]bool{ |
| 92 | "v1.2.3": true, |
| 93 | "v1.3.0": true, |
| 94 | }, |
| 95 | expected: &compileUpdateNotification{ |
| 96 | Kind: compileUpdateNotificationMinorBehind, |
| 97 | CurrentVersion: "v1.2.3", |
| 98 | LatestVersion: "v1.3.0", |
| 99 | }, |
| 100 | }, |
| 101 | { |
| 102 | name: "returns prominent notice when current tag is missing", |
| 103 | currentVersion: "v1.2.3", |
| 104 | latestVersion: "v1.3.0", |
| 105 | existingTags: map[string]bool{ |
| 106 | "v1.3.0": true, |
| 107 | }, |
| 108 | expected: &compileUpdateNotification{ |
| 109 | Kind: compileUpdateNotificationRemovedTag, |
| 110 | CurrentVersion: "v1.2.3", |
| 111 | LatestVersion: "v1.3.0", |
| 112 | }, |
| 113 | }, |
| 114 | { |
| 115 | name: "ignores patch-only difference", |
| 116 | currentVersion: "v1.2.3", |
| 117 | latestVersion: "v1.2.4", |
| 118 | existingTags: map[string]bool{ |
| 119 | "v1.2.3": true, |
| 120 | "v1.2.4": true, |
| 121 | }, |
| 122 | expected: nil, |
| 123 | }, |
| 124 | } |
| 125 |
nothing calls this directly
no test coverage detected