Skip to content

Commit 56fdb1c

Browse files
committed
fix: update Alpine base image to 3.21.3 and add tests for help flags
1 parent f42c1a5 commit 56fdb1c

File tree

3 files changed

+50
-25
lines changed

3 files changed

+50
-25
lines changed

Dockerfile.dev

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build \
3434
./main.go
3535

3636
# Development stage - uses Alpine for shell access
37-
FROM alpine:3.19
37+
FROM alpine:3.21.3
3838

3939
# Install minimal dependencies
4040
RUN apk add --no-cache ca-certificates tzdata

main_test.go

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,55 @@ func TestRunWithInsufficientArgs(t *testing.T) {
236236
}
237237
}
238238

239+
// TestRunWithHelpFlags tests the run function with help flag arguments.
240+
func TestRunWithHelpFlags(t *testing.T) {
241+
helpFlags := []string{"--help", "-h", "help"}
242+
243+
for _, flag := range helpFlags {
244+
t.Run("help_flag_"+flag, func(t *testing.T) {
245+
// Capture stdout
246+
oldStdout := os.Stdout
247+
r, w, _ := os.Pipe()
248+
os.Stdout = w
249+
250+
// Run with help flag
251+
args := []string{"articulate-parser", flag}
252+
exitCode := run(args)
253+
254+
// Restore stdout
255+
w.Close()
256+
os.Stdout = oldStdout
257+
258+
// Read captured output
259+
var buf bytes.Buffer
260+
io.Copy(&buf, r)
261+
output := buf.String()
262+
263+
// Verify exit code is 0 (success)
264+
if exitCode != 0 {
265+
t.Errorf("Expected exit code 0 for help flag %s, got %d", flag, exitCode)
266+
}
267+
268+
// Verify help content is displayed
269+
expectedContent := []string{
270+
"Usage:",
271+
"source: URI or file path to the course",
272+
"format: export format",
273+
"output: output file path",
274+
"Example:",
275+
"articulate-sample.json markdown output.md",
276+
"https://rise.articulate.com/share/xyz docx output.docx",
277+
}
278+
279+
for _, expected := range expectedContent {
280+
if !strings.Contains(output, expected) {
281+
t.Errorf("Expected help output to contain %q when using flag %s, got: %s", expected, flag, output)
282+
}
283+
}
284+
})
285+
}
286+
}
287+
239288
// TestRunWithInvalidFile tests the run function with a non-existent file.
240289
func TestRunWithInvalidFile(t *testing.T) {
241290
// Capture stdout and stderr

pr-comments-response.md

Lines changed: 0 additions & 24 deletions
This file was deleted.

0 commit comments

Comments
 (0)