Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tests exposing a paths issue. #881

Merged
merged 2 commits into from
Jan 2, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion EXPERIMENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
We frequently introduce new experimental features to the agent. You can use the `--experiment` flag to opt-in to them and test them out:

```bash
buildkite-agent start --experiment experiment1 --experiment expertiment2
buildkite-agent start --experiment experiment1 --experiment experiment2
Copy link
Contributor

Choose a reason for hiding this comment

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

😅

```

Or you can set them in your [agent configuration file](https://buildkite.com/docs/agent/v3/configuration):
Expand Down
32 changes: 32 additions & 0 deletions utils/path_test_windows.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// +build windows

package utils

import (
"os"
"path/filepath"
"testing"
)

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

fp, err := NormalizeFilePath("C:\\programdata\\buildkite-agent")
assert.NoError(t, err)
expected := filepath.Join("C:", "programdata", "buildkite-agent")
assert.Equal(t, expected, fp)
}

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

// A naked backslash on Windows resolves to root of current working directory's drive.
dir, err := os.Getwd()
assert.NoError(t, err)
drive := filepath.VolumeName(dir)
fp, err := NormalizeFilePath("\\")

assert.NoError(t, err)
expected := filepath.Join(drive, "programdata", "buildkite-agent")
assert.Equal(t, expected, fp)
}