Пример #1
0
func TestCreate(t *testing.T) {
	th.SetupHTTP()
	defer th.TeardownHTTP()
	HandleCreate(t)

	opts := instances.CreateOpts{
		Name:      "json_rack_instance",
		FlavorRef: "1",
		Databases: db.BatchCreateOpts{
			{CharSet: "utf8", Collate: "utf8_general_ci", Name: "sampledb"},
			{Name: "nextround"},
		},
		Users: users.BatchCreateOpts{
			{
				Name:     "demouser",
				Password: "******",
				Databases: db.BatchCreateOpts{
					{Name: "sampledb"},
				},
			},
		},
		Size: 2,
	}

	instance, err := instances.Create(fake.ServiceClient(), opts).Extract()

	th.AssertNoErr(t, err)
	th.AssertDeepEquals(t, &expectedInstance, instance)
}
Пример #2
0
func (c context) createInstance() {
	if os.Getenv(envDSType) == "" {
		c.test.Fatalf("%s must be set as an environment var", envDSType)
	}

	opts := instances.CreateOpts{
		FlavorRef: "2",
		Size:      5,
		Name:      tools.RandomString("gopher_db", 5),
		Datastore: &instances.DatastoreOpts{Type: os.Getenv(envDSType)},
	}

	instance, err := instances.Create(c.client, opts).Extract()
	th.AssertNoErr(c.test, err)

	c.Logf("Restarting %s. Waiting...", instance.ID)
	c.WaitUntilActive(instance.ID)
	c.Logf("Created Instance %s", instance.ID)

	c.instanceID = instance.ID
}