Esempio n. 1
0
func TestUpSimple(t *testing.T) {
	t.Parallel()
	provider := new(providers.TestProvider)

	stdout, stderr := testRunCmd(t, "hostctl up test1", 0, provider, nil)
	ensure.DeepEqual(t, stderr.String(), "\n")
	ensure.DeepEqual(t, stdout.String(), "")

	ensure.NotDeepEqual(t, provider.Get("test1"), (*providers.Host)(nil))
}
Esempio n. 2
0
func TestScaleUpFromZero(t *testing.T) {
	t.Parallel()
	provider := new(providers.TestProvider)

	stdout, stderr := testRunCmd(t, "hostctl scale test 3", 0, provider, nil)
	ensure.DeepEqual(t, stderr.String(), "\n")
	ensure.DeepEqual(t, stdout.String(), "")

	ensure.NotDeepEqual(t, provider.Get("test.0"), (*providers.Host)(nil))
	ensure.NotDeepEqual(t, provider.Get("test.1"), (*providers.Host)(nil))
	ensure.NotDeepEqual(t, provider.Get("test.2"), (*providers.Host)(nil))
}
Esempio n. 3
0
func TestIpCmd(t *testing.T) {
	t.Parallel()
	provider := new(providers.TestProvider)
	provider.Create(providers.Host{
		Name: "test1",
		IP:   "127.0.0.1",
	})

	stdout, stderr := testRunCmd(t, "hostctl ip test1", 0, provider, nil)
	ensure.DeepEqual(t, stdout.String(), "127.0.0.1\n")
	ensure.DeepEqual(t, stderr.String(), "")
}
Esempio n. 4
0
func TestListBasic(t *testing.T) {
	t.Parallel()
	provider := new(providers.TestProvider)
	provider.Create(providers.Host{
		Name: "test1",
	})
	provider.Create(providers.Host{
		Name: "test2",
	})

	stdout, stderr := testRunCmd(t, "hostctl ls", 0, provider, nil)
	ensure.DeepEqual(t, stdout.String(), "test1\ntest2\n")
	ensure.DeepEqual(t, stderr.String(), "")
}
Esempio n. 5
0
func TestScaleDownToOne(t *testing.T) {
	t.Parallel()
	provider := new(providers.TestProvider)
	provider.Create(providers.Host{
		Name: "test.0",
	})
	provider.Create(providers.Host{
		Name: "test.1",
	})
	provider.Create(providers.Host{
		Name: "test.2",
	})

	stdout, stderr := testRunCmd(t, "hostctl scale test 1", 0, provider, nil)
	ensure.DeepEqual(t, stderr.String(), "\n")
	ensure.DeepEqual(t, stdout.String(), "")

	ensure.NotDeepEqual(t, provider.Get("test.0"), (*providers.Host)(nil))
	ensure.DeepEqual(t, provider.Get("test.1"), (*providers.Host)(nil))
	ensure.DeepEqual(t, provider.Get("test.2"), (*providers.Host)(nil))
}