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
Fix golden files
  • Loading branch information
Emyrk committed Jun 22, 2023
commit b67cec920df1b44bbab9265c13da92f530f316ab
5 changes: 5 additions & 0 deletions cli/configssh_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ import (
"github.com/stretchr/testify/require"
)

func init() {
// For golden files, always show the flag.
hideForceUnixSlashes = false
}

func Test_sshConfigSplitOnCoderSection(t *testing.T) {
t.Parallel()

Expand Down
2 changes: 1 addition & 1 deletion cli/configssh_other.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

package cli

const hideForceUnixSlashes = true
var hideForceUnixSlashes = true
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know if it's considered good practice or not, but there's a trick you can use to avoid the build flag:

var hideForceUnixSlashes = func() bool { return runtime.GOOS == "windows" }()

I'll leave it up to you whether or not to use it (two less files might be nice). 😄

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was following our other pattern. I was unsure if a build tag or that was the move

3 changes: 2 additions & 1 deletion cli/configssh_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@

package cli

const hideForceUnixSlashes = false
// Must be a var for unit tests to conform behavior
var hideForceUnixSlashes = false
6 changes: 6 additions & 0 deletions cli/testdata/coder_config-ssh_--help.golden
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ Add an SSH Host entry for your workspaces "ssh coder.workspace"
-n, --dry-run bool, $CODER_SSH_DRY_RUN
Perform a trial run with no changes made, showing a diff at the end.

--force-unix-filepaths bool, $CODER_CONFIGSSH_UNIX_FILEPATHS
By default, 'config-ssh' uses the os path separator when writing the
ssh config. This might be an issue in Windows machine that use a
unix-like shell. This flag forces the use of unix file paths (the
forward slash '/').

--ssh-config-file string, $CODER_SSH_CONFIG_FILE (default: ~/.ssh/config)
Specifies the path to an SSH config.

Expand Down