Move inventory tests to projects package

This commit is contained in:
Denis 2018-03-08 18:45:53 +05:00
parent 4bd51c6632
commit 16a0374937
2 changed files with 28 additions and 25 deletions

View File

@ -0,0 +1,28 @@
package projects
import (
"testing"
)
func TestIsValidInventoryPath(t *testing.T) {
if !IsValidInventoryPath("inventories/test") {
t.Fatal(" a path below the cwd should be valid")
}
if !IsValidInventoryPath("inventories/test/../prod") {
t.Fatal(" a path below the cwd should be valid")
}
if IsValidInventoryPath("/test/../../../inventory") {
t.Fatal(" a path out of the cwd should be invalid")
}
if IsValidInventoryPath("/test/inventory") {
t.Fatal(" a path out of the cwd should be invalid")
}
if IsValidInventoryPath("c:\\test\\inventory") {
t.Fatal(" a path out of the cwd should be invalid")
}
}

View File

@ -1,25 +0,0 @@
package tests
import (
"testing"
. "gopkg.in/check.v1"
"github.com/ansible-semaphore/semaphore/api/projects"
)
func Test(t *testing.T) { TestingT(t) }
type MySuite struct{}
var _ = Suite(&MySuite{})
func (s *MySuite) TestIsValidInventoryPath(c *C) {
c.Assert(projects.IsValidInventoryPath("inventories/test"), Equals, true)
c.Assert(projects.IsValidInventoryPath("inventories/test/../prod"), Equals, true)
c.Assert(projects.IsValidInventoryPath("/test/../../../inventory"), Equals, false)
c.Assert(projects.IsValidInventoryPath("/test/inventory"), Equals, false)
c.Assert(projects.IsValidInventoryPath("c:\\test\\inventory"), Equals, false)
}