|
| 1 | +package cloner |
| 2 | + |
| 3 | +import ( |
| 4 | + "os" |
| 5 | + "testing" |
| 6 | + |
| 7 | + "github.com/joshmedeski/sesh/model" |
| 8 | + "github.com/stretchr/testify/assert" |
| 9 | +) |
| 10 | + |
| 11 | +func TestListSessions(t *testing.T) { |
| 12 | + t.Run("get path with both cmd and repo", func(t *testing.T) { |
| 13 | + mockOpts := model.GitCloneOptions{Repo: "https://www.github.comtest/repo.git", CmdDir: "cmdDir", Dir: "dir"} |
| 14 | + actual := getPath(mockOpts) |
| 15 | + assert.Equal(t, "cmdDir/dir", actual) |
| 16 | + }) |
| 17 | + t.Run("get path cmdDir", func(t *testing.T) { |
| 18 | + mockOpts := model.GitCloneOptions{Repo: "https://www.github.comtest/repo.git", CmdDir: "cmdDir"} |
| 19 | + actual := getPath(mockOpts) |
| 20 | + assert.Equal(t, "cmdDir/repo", actual) |
| 21 | + }) |
| 22 | + t.Run("get path dir", func(t *testing.T) { |
| 23 | + mockOpts := model.GitCloneOptions{Repo: "https://www.github.comtest/repo.git", Dir: "dir"} |
| 24 | + actual := getPath(mockOpts) |
| 25 | + expected, _ := os.Getwd() |
| 26 | + expected = expected + "/" + "dir" |
| 27 | + assert.Equal(t, expected, actual) |
| 28 | + }) |
| 29 | + t.Run("get path with no dir or cmdDir", func(t *testing.T) { |
| 30 | + mockOpts := model.GitCloneOptions{Repo: "https://www.github.comtest/repo.git"} |
| 31 | + actual := getPath(mockOpts) |
| 32 | + expected, _ := os.Getwd() |
| 33 | + expected = expected + "/" + "repo" |
| 34 | + assert.Equal(t, expected, actual) |
| 35 | + }) |
| 36 | +} |
0 commit comments