Skip to content

Commit

Permalink
add more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jakecoffman committed Dec 22, 2023
1 parent 18c1cd3 commit 8c44f9d
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 0 deletions.
4 changes: 4 additions & 0 deletions cmd/dependabot/internal/cmd/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package cmd

import (
"bytes"
"context"
"encoding/json"
"errors"
"fmt"
Expand Down Expand Up @@ -91,6 +92,9 @@ func NewUpdateCommand() *cobra.Command {
Writer: writer,
ApiUrl: flags.apiUrl,
}); err != nil {
if errors.Is(err, context.DeadlineExceeded) {
log.Fatalf("update timed out after %s", flags.timeout)
}
log.Fatalf("failed to run updater: %v", err)
}

Expand Down
2 changes: 2 additions & 0 deletions testdata/scripts/basic.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ dependabot update go_modules dependabot/cli --updater-image dummy-updater
stderr 'bin/run arguments: fetch_files'
stderr 'bin/run arguments: update_files'

exec docker rmi -f dummy-updater

-- Dockerfile --
FROM ubuntu:22.04

Expand Down
5 changes: 5 additions & 0 deletions testdata/scripts/input.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ stderr 'commit must be a SHA, or not provided'
dependabot update go_modules dependabot/cli --dep golang.org/x/image --updater-image input-verify-updater
stderr '"allowed-updates":\[\{"dependency-name":"golang.org/x/image"\}\]'

dependabot update go_modules dependabot/cli --directory /code --updater-image input-verify-updater
stderr '"directory":"\/code"'

exec docker rmi -f input-verify-updater

-- Dockerfile --
FROM ubuntu:22.04

Expand Down
2 changes: 2 additions & 0 deletions testdata/scripts/local.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ dependabot update go_modules dependabot-fixtures/go-modules-lib --updater-image
stderr \.git
stderr hello.txt

exec docker rmi -f local-updater

-- Dockerfile --
FROM ubuntu:22.04

Expand Down
24 changes: 24 additions & 0 deletions testdata/scripts/timeout.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
exec docker build -t sleepy-updater .

! dependabot update go_modules dependabot/cli --timeout 1s --updater-image sleepy-updater
stderr 'update timed out after 1s'

exec docker rmi -f sleepy-updater

-- Dockerfile --
FROM ubuntu:22.04

RUN useradd dependabot

COPY --chown=dependabot --chmod=755 update-ca-certificates /usr/bin/update-ca-certificates
COPY --chown=dependabot --chmod=755 run bin/run

-- update-ca-certificates --
#!/usr/bin/env bash

echo "Updated those certificates for ya"

-- run --
#!/usr/bin/env bash

sleep 10

0 comments on commit 8c44f9d

Please sign in to comment.