Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fixup color
  • Loading branch information
ammario committed May 10, 2023
commit d6470dba03e3814c345f592b0ec5b2e675d3ee04
13 changes: 12 additions & 1 deletion cli/root_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import (
"strings"
"testing"

"github.com/charmbracelet/lipgloss"
"github.com/muesli/termenv"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

Expand All @@ -33,8 +35,17 @@ var updateGoldenFiles = flag.Bool("update", false, "update .golden files")

var timestampRegex = regexp.MustCompile(`(?i)\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(.\d+)?Z`)

// We need to override the global color profile.
//
//nolint:tparallel,paralleltest
func TestCommandHelp(t *testing.T) {
t.Parallel()
ogColorProfile := lipgloss.ColorProfile()
// ANSI256 escape codes are far easier for humans to parse in a diff,
// but TrueColor is probably more popular with modern terminals.
lipgloss.SetColorProfile(termenv.ANSI)
t.Cleanup(func() {
lipgloss.SetColorProfile(ogColorProfile)
})
rootClient, replacements := prepareTestData(t)

type testCase struct {
Expand Down
8 changes: 4 additions & 4 deletions cli/testdata/coder_--help.golden
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ Usage: coder [global-flags] <subcommand>
Coder v0.0.0-devel — A tool for provisioning self-hosted development environments with Terraform.
- Start a Coder server:

$ coder server
 $ coder server 

- Get started by creating a template from an example:

$ coder templates init
 $ coder templates init 

Subcommands
Subcommands
config-ssh Add an SSH Host entry for your workspaces "ssh
coder.workspace"
create Create a workspace
Expand Down Expand Up @@ -43,7 +43,7 @@ Subcommands
users Manage users
version Show coder version

Global Options
Global Options
Global options are applied to all commands. They can be set using environment
variables or flags.

Expand Down
2 changes: 1 addition & 1 deletion cli/testdata/coder_agent_--help.golden
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Usage: coder agent [flags]

Starts the Coder workspace agent.

Options
Options
--auth string, $CODER_AGENT_AUTH (default: token)
Specify the authentication type to use for the agent.

Expand Down
6 changes: 3 additions & 3 deletions cli/testdata/coder_config-ssh_--help.golden
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ Add an SSH Host entry for your workspaces "ssh coder.workspace"
- You can use -o (or --ssh-option) so set SSH options to be used for all your
workspaces:

$ coder config-ssh -o ForwardAgent=yes
 $ coder config-ssh -o ForwardAgent=yes 

- You can use --dry-run (or -n) to see the changes that would be made:

$ coder config-ssh --dry-run
 $ coder config-ssh --dry-run 

Options
Options
-n, --dry-run bool, $CODER_SSH_DRY_RUN
Perform a trial run with no changes made, showing a diff at the end.

Expand Down
2 changes: 1 addition & 1 deletion cli/testdata/coder_create_--help.golden
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Usage: coder create [flags] [name]

Create a workspace

Options
Options
--parameter-file string, $CODER_PARAMETER_FILE
Specify a file path with parameter values.

Expand Down
2 changes: 1 addition & 1 deletion cli/testdata/coder_delete_--help.golden
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Delete a workspace

Aliases: rm

Options
Options
--orphan bool
Delete a workspace without deleting its resources. This can delete a
workspace in a broken state, but may also lead to unaccounted cloud
Expand Down
4 changes: 2 additions & 2 deletions cli/testdata/coder_dotfiles_--help.golden
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ Personalize your workspace by applying a canonical dotfiles repository

- Check out and install a dotfiles repository without prompts:

$ coder dotfiles --yes git@github.com:example/dotfiles.git
 $ coder dotfiles --yes git@github.com:example/dotfiles.git 

Options
Options
--symlink-dir string, $CODER_SYMLINK_DIR
Specifies the directory for the dotfiles symlink destinations. If
empty, will use $HOME.
Expand Down
2 changes: 1 addition & 1 deletion cli/testdata/coder_list_--help.golden
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ List workspaces

Aliases: ls

Options
Options
-a, --all bool
Specifies whether all workspaces will be listed or not.

Expand Down
2 changes: 1 addition & 1 deletion cli/testdata/coder_login_--help.golden
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Usage: coder login [flags] <url>

Authenticate with Coder deployment

Options
Options
--first-user-email string, $CODER_FIRST_USER_EMAIL
Specifies an email address to use if creating the first user for the
deployment.
Expand Down
2 changes: 1 addition & 1 deletion cli/testdata/coder_logout_--help.golden
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Usage: coder logout [flags]

Unauthenticate your local session

Options
Options
-y, --yes bool
Bypass prompts.

Expand Down
2 changes: 1 addition & 1 deletion cli/testdata/coder_ping_--help.golden
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Usage: coder ping [flags] <workspace>

Ping a workspace

Options
Options
-n, --num int (default: 10)
Specifies the number of pings to perform.

Expand Down
10 changes: 5 additions & 5 deletions cli/testdata/coder_port-forward_--help.golden
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,22 @@ Aliases: tunnel
- Port forward a single TCP port from 1234 in the workspace to port 5678 on
your local machine:

$ coder port-forward <workspace> --tcp 5678:1234
 $ coder port-forward <workspace> --tcp 5678:1234 

- Port forward a single UDP port from port 9000 to port 9000 on your local
machine:

$ coder port-forward <workspace> --udp 9000
 $ coder port-forward <workspace> --udp 9000 

- Port forward multiple TCP ports and a UDP port:

$ coder port-forward <workspace> --tcp 8080:8080 --tcp 9000:3000 --udp 5353:53
 $ coder port-forward <workspace> --tcp 8080:8080 --tcp 9000:3000 --udp 5353:53 

- Port forward multiple ports (TCP or UDP) in condensed syntax:

$ coder port-forward <workspace> --tcp 8080,9000:3000,9090-9092,10000-10002:10010-10012
 $ coder port-forward <workspace> --tcp 8080,9000:3000,9090-9092,10000-10002:10010-10012 

Options
Options
-p, --tcp string-array, $CODER_PORT_FORWARD_TCP
Forward TCP port(s) from the workspace to the local machine.

Expand Down
2 changes: 1 addition & 1 deletion cli/testdata/coder_publickey_--help.golden
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Output your Coder public key used for Git operations

Aliases: pubkey

Options
Options
--reset bool
Regenerate your public key. This will require updating the key on any
services it's registered with.
Expand Down
2 changes: 1 addition & 1 deletion cli/testdata/coder_rename_--help.golden
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Usage: coder rename [flags] <workspace> <new name>

Rename a workspace

Options
Options
-y, --yes bool
Bypass prompts.

Expand Down
2 changes: 1 addition & 1 deletion cli/testdata/coder_reset-password_--help.golden
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Usage: coder reset-password [flags] <username>

Directly connect to the database to reset a user's password

Options
Options
--postgres-url string, $CODER_PG_CONNECTION_URL
URL of a PostgreSQL database to connect to.

Expand Down
2 changes: 1 addition & 1 deletion cli/testdata/coder_restart_--help.golden
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Usage: coder restart [flags] <workspace>

Restart a workspace

Options
Options
-y, --yes bool
Bypass prompts.

Expand Down
2 changes: 1 addition & 1 deletion cli/testdata/coder_scaletest_--help.golden
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Usage: coder scaletest

Run a scale test against the Coder API

Subcommands
Subcommands
cleanup Cleanup scaletest workspaces, then cleanup scaletest
users.
create-workspaces Creates many users, then creates a workspace for each
Expand Down
2 changes: 1 addition & 1 deletion cli/testdata/coder_scaletest_cleanup_--help.golden
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Cleanup scaletest workspaces, then cleanup scaletest users.

The strategy flags will apply to each stage of the cleanup process.

Options
Options
--cleanup-concurrency int, $CODER_SCALETEST_CLEANUP_CONCURRENCY (default: 1)
Number of concurrent cleanup jobs to run. 0 means unlimited.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ workspace, and connects to the workspace over WireGuard.

It is recommended that all rate limits are disabled on the server before running this scaletest. This test generates many login events which will be rate limited against the (most likely single) IP.

Options
Options
--cleanup-concurrency int, $CODER_SCALETEST_CLEANUP_CONCURRENCY (default: 1)
Number of concurrent cleanup jobs to run. 0 means unlimited.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Usage: coder scaletest workspace-traffic [flags]

Generate traffic to scaletest workspaces through coderd

Options
Options
--bytes-per-tick int, $CODER_SCALETEST_WORKSPACE_TRAFFIC_BYTES_PER_TICK (default: 1024)
How much traffic to generate per tick.

Expand Down
2 changes: 1 addition & 1 deletion cli/testdata/coder_schedule_--help.golden
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Usage: coder schedule { show | start | stop | override } <workspace>

Schedule automated start and stop times for workspaces

Subcommands
Subcommands
override-stop Override the stop time of a currently running workspace
instance.
show Show workspace schedule
Expand Down
2 changes: 1 addition & 1 deletion cli/testdata/coder_schedule_override-stop_--help.golden
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Override the stop time of a currently running workspace instance.
* The new stop time must be at least 30 minutes in the future.
* The workspace template may restrict the maximum workspace runtime.

$ coder schedule override-stop my-workspace 90m
 $ coder schedule override-stop my-workspace 90m 

---
Run `coder --help` for a list of global options.
2 changes: 1 addition & 1 deletion cli/testdata/coder_schedule_start_--help.golden
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Schedule format: <start-time> [day-of-week] [location].

- Set the workspace to start at 9:30am (in Dublin) from Monday to Friday:

$ coder schedule start my-workspace 9:30AM Mon-Fri Europe/Dublin
 $ coder schedule start my-workspace 9:30AM Mon-Fri Europe/Dublin 

---
Run `coder --help` for a list of global options.
2 changes: 1 addition & 1 deletion cli/testdata/coder_schedule_stop_--help.golden
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ When enabling scheduled stop, enter a duration in one of the following formats:
* 2m (2 minutes)
* 2 (2 minutes)

$ coder schedule stop my-workspace 2h30m
 $ coder schedule stop my-workspace 2h30m 

---
Run `coder --help` for a list of global options.
Loading