(t *testing.T)
| 143 | } |
| 144 | |
| 145 | func TestPrintCompileUpdateNotification(t *testing.T) { |
| 146 | tests := []struct { |
| 147 | name string |
| 148 | notification *compileUpdateNotification |
| 149 | expected []string |
| 150 | }{ |
| 151 | { |
| 152 | name: "minor version behind", |
| 153 | notification: &compileUpdateNotification{ |
| 154 | Kind: compileUpdateNotificationMinorBehind, |
| 155 | CurrentVersion: "v1.2.3", |
| 156 | LatestVersion: "v1.3.0", |
| 157 | }, |
| 158 | expected: []string{ |
| 159 | "Compiler upgrade recommended: gh-aw v1.2.3 is behind the latest release v1.3.0.", |
| 160 | "Hint: upgrade the compiler with: gh extension upgrade github/gh-aw", |
| 161 | }, |
| 162 | }, |
| 163 | { |
| 164 | name: "removed tag warning", |
| 165 | notification: &compileUpdateNotification{ |
| 166 | Kind: compileUpdateNotificationRemovedTag, |
| 167 | CurrentVersion: "v1.2.3", |
| 168 | LatestVersion: "v1.3.0", |
| 169 | }, |
| 170 | expected: []string{ |
| 171 | "The installed gh-aw compiler version v1.2.3 is no longer available as a repository tag.", |
| 172 | "Update the compiler before recompiling workflows (latest release: v1.3.0).", |
| 173 | }, |
| 174 | }, |
| 175 | } |
| 176 | |
| 177 | for _, tt := range tests { |
| 178 | t.Run(tt.name, func(t *testing.T) { |
| 179 | oldStderr := os.Stderr |
| 180 | r, w, err := os.Pipe() |
| 181 | require.NoError(t, err, "pipe creation should succeed") |
| 182 | defer r.Close() |
| 183 | os.Stderr = w |
| 184 | |
| 185 | printCompileUpdateNotification(tt.notification) |
| 186 | |
| 187 | require.NoError(t, w.Close(), "pipe writer should close cleanly") |
| 188 | os.Stderr = oldStderr |
| 189 | |
| 190 | var buf bytes.Buffer |
| 191 | _, err = buf.ReadFrom(r) |
| 192 | require.NoError(t, err, "pipe reader should capture stderr output") |
| 193 | output := buf.String() |
| 194 | |
| 195 | for _, expected := range tt.expected { |
| 196 | assert.Contains(t, output, expected, "output should contain expected message") |
| 197 | } |
| 198 | }) |
| 199 | } |
| 200 | } |
| 201 | |
| 202 | func TestIsMinorVersionBehind(t *testing.T) { |
nothing calls this directly
no test coverage detected