Example #1
0
func (s *MySuite) TestNodeCreate(c *C) {
	err := node.CreateCmd("test", "127.0.0.1", "/", "/id_rsa", "default", []string{"testing", "staging"})
	c.Assert(err, IsNil)
	data, _ := ioutil.ReadFile(node.FilePath("test"))
	c.Assert(string(data), Equals, "name: test\nurl: tcp://127.0.0.1:2376\ncert: /\nkey: /id_rsa\ncluster: default\ntags:\n- testing\n- staging\n")
	err = node.CreateCmd("test", "127.0.0.1", "/", "/id_rsa", "default", []string{"testing", "staging"})
	c.Assert(err, NotNil)
	err = node.CreateCmd("test2", "127.0.0.1", "/", "/id_rsa", "cluster", []string{"testing", "staging"})
	c.Assert(err, NotNil)
	err = cluster.CreateCmd("cluster", true, true, "pwd", true)
	c.Assert(err, IsNil)
	err = node.CreateCmd("test2", "127.0.0.1", "/", "/id_rsa", "cluster", []string{"testing", "staging"})
	c.Assert(err, IsNil)
	data, _ = ioutil.ReadFile(node.FilePath("test2"))
	c.Assert(string(data), Equals, "name: test2\nurl: tcp://127.0.0.1:2376\ncert: /\nkey: /id_rsa\ncluster: cluster\ntags:\n- testing\n- staging\n")
}
Example #2
0
func (s *MySuite) TestNodeUpdate(c *C) {
	err := node.CreateCmd("test", "127.0.0.1", "/", "/id_rsa", "default", []string{"testing", "staging"})
	c.Assert(err, IsNil)
	err = node.UpdateCmd("test", "192.168.99.100", "/tmp", "/tmp/id_rsa", []string{"prod"})
	c.Assert(err, IsNil)
	data, _ := ioutil.ReadFile(node.FilePath("test"))
	c.Assert(string(data), Equals, "name: test\nurl: tcp://192.168.99.100:2376\ncert: /tmp\nkey: /tmp/id_rsa\ncluster: default\ntags:\n- prod\n")
	err = node.UpdateCmd("test2", "192.168.99.100", "/tmp", "/tmp/id_rsa", []string{"prod"})
	c.Assert(err, NotNil)
}
Example #3
0
func (s *MySuite) TestNodeRemove(c *C) {
	err := node.CreateCmd("test", "127.0.0.1", "/", "/id_rsa", "default", []string{"testing", "staging"})
	c.Assert(err, IsNil)
	err = node.RemoveCmd("test")
	c.Assert(err, IsNil)
	filePath := node.FilePath("test")
	_, err = os.Stat(filePath)
	c.Assert(err, NotNil)
	err = node.RemoveCmd("test")
	c.Assert(err, NotNil)
}