Skip to content

feat: add dotfiles command #1723

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

Merged
merged 32 commits into from
May 25, 2022
Merged
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
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
try removing parallel
  • Loading branch information
f0ssel committed May 24, 2022
commit 23c950a9abc87752c38069dbccf43da991e68f39
11 changes: 8 additions & 3 deletions cli/dotfiles_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,43 +11,48 @@ import (
"github.com/coder/coder/cli/clitest"
)

// nolint:paralleltest
func TestDotfiles(t *testing.T) {
t.Run("MissingArg", func(t *testing.T) {
t.Parallel()
cmd, _ := clitest.New(t, "dotfiles")
err := cmd.Execute()
assert.Error(t, err)
})
t.Run("NoInstallScript", func(t *testing.T) {
t.Parallel()
_, root := clitest.New(t)
testRepo := filepath.Join(string(root), "test-repo")

err := os.MkdirAll(testRepo, 0750)
assert.NoError(t, err)

c := exec.Command("git", "init")
c.Dir = testRepo
err = c.Run()
assert.NoError(t, err)

// nolint:gosec
err = os.WriteFile(filepath.Join(testRepo, ".bashrc"), []byte("wow"), 0750)
assert.NoError(t, err)

c = exec.Command("git", "add", ".bashrc")
c.Dir = testRepo
err = c.Run()
assert.NoError(t, err)

c = exec.Command("git", "commit", "-m", `"add .bashrc"`)
c.Dir = testRepo
err = c.Run()
assert.NoError(t, err)

cmd, _ := clitest.New(t, "dotfiles", "--global-config", string(root), "--home-dir", string(root), "-y", testRepo)
err = cmd.Execute()
assert.NoError(t, err)

b, err := os.ReadFile(filepath.Join(string(root), ".bashrc"))
assert.NoError(t, err)
assert.Equal(t, string(b), "wow")
})
t.Run("InstallScript", func(t *testing.T) {
t.Parallel()
_, root := clitest.New(t)
testRepo := filepath.Join(string(root), "test-repo")
err := os.MkdirAll(testRepo, 0750)
Expand Down