Beispiel #1
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))
}
Beispiel #2
0
func TestUpMultiple(t *testing.T) {
	t.Parallel()
	provider := new(providers.TestProvider)

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

	ensure.NotDeepEqual(t, provider.Get("test1"), (*providers.Host)(nil))
	ensure.NotDeepEqual(t, provider.Get("test2"), (*providers.Host)(nil))
	ensure.NotDeepEqual(t, provider.Get("test3"), (*providers.Host)(nil))
}
Beispiel #3
0
func TestNotDeepEqualStruct(t *testing.T) {
	var c capture
	v := typ{Answer: 42}
	ensure.NotDeepEqual(&c, v, v)
	c.Equal(t, `ensure_test.go:85: expected two different values, but got the same:
(ensure_test.typ) {
 Answer: (int) 42
}`)
}
Beispiel #4
0
func TestUserAgent(t *testing.T) {
	t.Parallel()
	done := make(chan struct{})
	c := &parse.Client{
		Transport: transportFunc(func(r *http.Request) (*http.Response, error) {
			defer close(done)
			ensure.NotDeepEqual(t, r.Header.Get("User-Agent"), "")
			return nil, errors.New("")
		}),
	}
	c.Do(&http.Request{}, nil, nil)
	<-done
}
Beispiel #5
0
func TestUpExists(t *testing.T) {
	t.Parallel()
	provider := new(providers.TestProvider)
	provider.Create(providers.Host{
		Name: "test1",
	})

	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))
}
Beispiel #6
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))
}