mirror of
https://github.com/semaphoreui/semaphore.git
synced 2025-01-20 15:29:28 +01:00
Move inventory tests to projects package
This commit is contained in:
parent
4bd51c6632
commit
16a0374937
28
api/projects/inventory_test.go
Normal file
28
api/projects/inventory_test.go
Normal 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")
|
||||
}
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
Loading…
Reference in New Issue
Block a user