Files
atlantis/server/plan_executor_test.go
Luke Kysow 8fbe662185 Return error if workspace doesn't exist (#61)
* Return error if workspace doesn't exist
* Default data dir to ~/.atlantis. Don't clean workspaces
* Run goimports
2017-07-01 16:17:22 -07:00

29 lines
1.2 KiB
Go

package server
import (
"testing"
. "github.com/hootsuite/atlantis/testing_util"
)
var p PlanExecutor
func TestModifiedProjects(t *testing.T) {
runTest(t, "should handle no files modified", []string{}, []string{})
runTest(t, "should handle files at root", []string{"root.tf"}, []string{"."})
runTest(t, "should de-duplicate files at root", []string{"root1.tf", "root2.tf"}, []string{"."})
runTest(t, "should handle sub directories", []string{"sub/dir/file.tf"}, []string{"sub/dir"})
runTest(t, "should de-duplicate files in sub directories", []string{"sub/dir/file.tf", "sub/dir/file2.tf"}, []string{"sub/dir"})
runTest(t, "should handle nested sub directories", []string{"root.tf", "sub/child.tf", "sub/sub/child.tf"}, []string{".", "sub", "sub/sub"})
runTest(t, "should use parent of env/ dirs", []string{"env/env.tf"}, []string{"."})
runTest(t, "should use parent of env/ dirs in sub dirs", []string{"sub/env/env.tf"}, []string{"sub"})
}
func runTest(t *testing.T, testDescrip string, filesChanged []string, expectedPaths []string) {
projects := p.ModifiedProjects("owner/repo", filesChanged)
for i, p := range projects {
t.Log(testDescrip)
Equals(t, expectedPaths[i], p.Path)
}
}