Exemplo n.º 1
0
func TestListGlobalParams(t *testing.T) {
	th.SetupHTTP()
	defer th.TeardownHTTP()
	fixture.SetupHandler(t, globalParamListURL, "GET", "", ListParamsJSON, 200)

	pages := 0
	err := configurations.ListGlobalParams(fake.ServiceClient(), versionID).EachPage(func(page pagination.Page) (bool, error) {
		pages++

		actual, err := configurations.ExtractParams(page)
		if err != nil {
			return false, err
		}

		expected := []configurations.Param{
			{Max: 1, Min: 0, Name: "innodb_file_per_table", RestartRequired: true, Type: "integer"},
			{Max: 4294967296, Min: 0, Name: "key_buffer_size", RestartRequired: false, Type: "integer"},
			{Max: 65535, Min: 2, Name: "connect_timeout", RestartRequired: false, Type: "integer"},
			{Max: 4294967296, Min: 0, Name: "join_buffer_size", RestartRequired: false, Type: "integer"},
		}

		th.AssertDeepEquals(t, actual, expected)

		return true, nil
	})

	th.AssertNoErr(t, err)
	th.AssertEquals(t, 1, pages)
}
Exemplo n.º 2
0
func TestListInstances(t *testing.T) {
	th.SetupHTTP()
	defer th.TeardownHTTP()
	fixture.SetupHandler(t, resURL+"/instances", "GET", "", ListInstancesJSON, 200)

	expectedInstance := instances.Instance{
		ID:   "d4603f69-ec7e-4e9b-803f-600b9205576f",
		Name: "json_rack_instance",
	}

	pages := 0
	err := configurations.ListInstances(fake.ServiceClient(), configID).EachPage(func(page pagination.Page) (bool, error) {
		pages++

		actual, err := instances.ExtractInstances(page)
		if err != nil {
			return false, err
		}

		th.AssertDeepEquals(t, actual, []instances.Instance{expectedInstance})

		return true, nil
	})

	th.AssertNoErr(t, err)
	th.AssertEquals(t, 1, pages)
}
Exemplo n.º 3
0
func TestDelete(t *testing.T) {
	th.SetupHTTP()
	defer th.TeardownHTTP()
	fixture.SetupHandler(t, resURL, "DELETE", "", "", 202)

	err := configurations.Delete(fake.ServiceClient(), configID).ExtractErr()
	th.AssertNoErr(t, err)
}
Exemplo n.º 4
0
func TestGet(t *testing.T) {
	th.SetupHTTP()
	defer th.TeardownHTTP()
	fixture.SetupHandler(t, resURL, "GET", "", GetConfigJSON, 200)

	config, err := configurations.Get(fake.ServiceClient(), configID).Extract()
	th.AssertNoErr(t, err)
	th.AssertDeepEquals(t, &ExampleConfig, config)
}
Exemplo n.º 5
0
func TestGetVersion(t *testing.T) {
	th.SetupHTTP()
	defer th.TeardownHTTP()
	fixture.SetupHandler(t, "/datastores/{dsID}/versions/{versionID}", "GET", "", GetVersionResp, 200)

	ds, err := datastores.GetVersion(fake.ServiceClient(), "{dsID}", "{versionID}").Extract()
	th.AssertNoErr(t, err)
	th.AssertDeepEquals(t, &ExampleVersion1, ds)
}
Exemplo n.º 6
0
func TestReplace(t *testing.T) {
	th.SetupHTTP()
	defer th.TeardownHTTP()
	fixture.SetupHandler(t, resURL, "PUT", UpdateReq, "", 202)

	opts := configurations.UpdateOpts{
		Values: map[string]interface{}{
			"connect_timeout": 300,
		},
	}

	err := configurations.Replace(fake.ServiceClient(), configID, opts).ExtractErr()
	th.AssertNoErr(t, err)
}
Exemplo n.º 7
0
func TestGetGlobalParam(t *testing.T) {
	th.SetupHTTP()
	defer th.TeardownHTTP()
	fixture.SetupHandler(t, globalParamGetURL, "GET", "", GetParamJSON, 200)

	param, err := configurations.GetGlobalParam(fake.ServiceClient(), versionID, paramID).Extract()
	th.AssertNoErr(t, err)

	expected := &configurations.Param{
		Max: 1, Min: 0, Name: "innodb_file_per_table", RestartRequired: true, Type: "integer",
	}

	th.AssertDeepEquals(t, expected, param)
}
Exemplo n.º 8
0
func TestList(t *testing.T) {
	th.SetupHTTP()
	defer th.TeardownHTTP()
	fixture.SetupHandler(t, _baseURL, "GET", "", ListConfigsJSON, 200)

	count := 0
	err := configurations.List(fake.ServiceClient()).EachPage(func(page pagination.Page) (bool, error) {
		count++
		actual, err := configurations.ExtractConfigs(page)
		th.AssertNoErr(t, err)

		expected := []configurations.Config{ExampleConfig}
		th.AssertDeepEquals(t, expected, actual)

		return true, nil
	})

	th.AssertEquals(t, 1, count)
	th.AssertNoErr(t, err)
}
Exemplo n.º 9
0
func TestCreate(t *testing.T) {
	th.SetupHTTP()
	defer th.TeardownHTTP()
	fixture.SetupHandler(t, _baseURL, "POST", CreateReq, CreateConfigJSON, 200)

	opts := configurations.CreateOpts{
		Datastore: &configurations.DatastoreOpts{
			Type:    "a00000a0-00a0-0a00-00a0-000a000000aa",
			Version: "b00000b0-00b0-0b00-00b0-000b000000bb",
		},
		Description: "example description",
		Name:        "example-configuration-name",
		Values: map[string]interface{}{
			"collation_server": "latin1_swedish_ci",
			"connect_timeout":  120,
		},
	}

	config, err := configurations.Create(fake.ServiceClient(), opts).Extract()
	th.AssertNoErr(t, err)
	th.AssertDeepEquals(t, &ExampleConfigWithValues, config)
}
Exemplo n.º 10
0
func TestListVersions(t *testing.T) {
	th.SetupHTTP()
	defer th.TeardownHTTP()
	fixture.SetupHandler(t, "/datastores/{dsID}/versions", "GET", "", ListVersionsResp, 200)

	pages := 0

	err := datastores.ListVersions(fake.ServiceClient(), "{dsID}").EachPage(func(page pagination.Page) (bool, error) {
		pages++

		actual, err := datastores.ExtractVersions(page)
		if err != nil {
			return false, err
		}

		th.CheckDeepEquals(t, ExampleVersions, actual)

		return true, nil
	})

	th.AssertNoErr(t, err)
	th.AssertEquals(t, 1, pages)
}
Exemplo n.º 11
0
func HandleIsRootEnabled(t *testing.T) {
	fixture.SetupHandler(t, uRootURL, "GET", "", isUserEnabledResp, 200)
}
Exemplo n.º 12
0
func HandleDelete(t *testing.T) {
	fixture.SetupHandler(t, _rootURL+"/{userName}", "DELETE", "", "", 202)
}
Exemplo n.º 13
0
func HandleList(t *testing.T) {
	fixture.SetupHandler(t, resURL, "GET", "", listDBsResp, 200)
}
Exemplo n.º 14
0
func HandleGet(t *testing.T) {
	fixture.SetupHandler(t, resURL, "GET", "", getFlavorResp, 200)
}
Exemplo n.º 15
0
func HandleList(t *testing.T) {
	fixture.SetupHandler(t, _baseURL, "GET", "", listFlavorsResp, 200)
}
Exemplo n.º 16
0
func HandleResizeVol(t *testing.T) {
	fixture.SetupHandler(t, aURL, "POST", resizeVolReq, "", 202)
}
Exemplo n.º 17
0
func HandleRestart(t *testing.T) {
	fixture.SetupHandler(t, aURL, "POST", restartReq, "", 202)
}
Exemplo n.º 18
0
func HandleCreate(t *testing.T) {
	fixture.SetupHandler(t, _rootURL, "POST", createReq, "", 202)
}
Exemplo n.º 19
0
func HandleList(t *testing.T) {
	fixture.SetupHandler(t, rootURL, "GET", "", listInstancesResp, 200)
}
Exemplo n.º 20
0
func HandleList(t *testing.T) {
	fixture.SetupHandler(t, _rootURL, "GET", "", listResp, 200)
}
Exemplo n.º 21
0
func HandleGet(t *testing.T) {
	fixture.SetupHandler(t, resURL, "GET", "", getInstanceResp, 200)
}
Exemplo n.º 22
0
func HandleCreate(t *testing.T) {
	fixture.SetupHandler(t, resURL, "POST", createDBsReq, "", 202)
}
Exemplo n.º 23
0
func HandleEnableRoot(t *testing.T) {
	fixture.SetupHandler(t, uRootURL, "POST", "", enableUserResp, 200)
}
Exemplo n.º 24
0
func HandleDelete(t *testing.T) {
	fixture.SetupHandler(t, resURL+"/{dbName}", "DELETE", "", "", 202)
}
Exemplo n.º 25
0
func HandleCreate(t *testing.T) {
	fixture.SetupHandler(t, rootURL, "POST", createReq, createResp, 200)
}