* See the License for the specific language governing permissions and limitations under the License.
 */

package serialize

import (
	"github.com/adjust/gocheck"
	"os"
	"testing"
)

func TestSerialize(t *testing.T) { gocheck.TestingT(t) }

type SerializeSuite struct{}

var _ = gocheck.Suite(&SerializeSuite{})

type TestSerializeStruct struct {
	Int    int
	Bool   bool
	String string
	Slice  []string
	Map    map[string]string
}

func (s *SerializeSuite) TestSerialize(c *gocheck.C) {
	SaveDir = "save_test"
	os.RemoveAll(SaveDir)
	c.Assert(os.MkdirAll(SaveDir, 0755), gocheck.IsNil)
	// test save/retrieve slice
	savedSlice := []uint16{5, 4, 3, 2, 1}
Esempio n. 2
0
import (
	. "atlantis/common"
	"atlantis/supervisor/containers"
	. "atlantis/supervisor/rpc/types"
	"github.com/adjust/gocheck"
	"os"
	"sort"
	"testing"
)

func Test(t *testing.T) { gocheck.TestingT(t) }

type RpcSuite struct{}

var _ = gocheck.Suite(&RpcSuite{})

func (s *RpcSuite) TestInit(c *gocheck.C) {
	c.Assert(Listen, gocheck.PanicMatches, "Not Initialized.")
	c.Assert(Init(":1337"), gocheck.IsNil)
}

func (s *RpcSuite) TestDeploy(c *gocheck.C) {
	os.Setenv("SUPERVISOR_PRETEND", "true")
	saveDir := "save_test"
	os.RemoveAll(saveDir)
	containers.Init("localhost", saveDir, 2, 2, 61000, 100, 1024, false)
	ih := new(Supervisor)
	arg := SupervisorDeployArg{}
	var reply SupervisorDeployReply
	c.Assert(ih.Deploy(arg, &reply), gocheck.ErrorMatches, "Please specify an app\\.")
 */

package containers

import (
	"atlantis/supervisor/rpc/types"
	"github.com/adjust/gocheck"
	"os"
	"testing"
)

func TestContainers(t *testing.T) { gocheck.TestingT(t) }

type ContainersSuite struct{}

var _ = gocheck.Suite(&ContainersSuite{})

func (s *ContainersSuite) TestInit(c *gocheck.C) {
	// Positive test
	saveDir := "save_test"
	os.RemoveAll(saveDir)
	c.Assert(Init("localhost", saveDir, uint16(100), uint16(5), uint16(61000), 100, 1024, false), gocheck.IsNil)
	if _, err := os.Stat(saveDir); err != nil {
		c.Fatal("Init did not make the save directory")
	}
	os.RemoveAll(saveDir)
	dieChan <- true

	// Negative test for invalid config
	c.Assert(Init("localhost", saveDir, uint16(1000), uint16(5), uint16(61000), 100, 1024, false), gocheck.ErrorMatches, "Invalid Config.+")