コード例 #1
0
ファイル: rm_test.go プロジェクト: MerlinDMC/machine
func TestCmdRmforceDoesAutoConfirm(t *testing.T) {
	commandLine := &commandstest.FakeCommandLine{
		CliArgs: []string{"machineToRemove1", "machineToRemove2"},
		LocalFlags: &commandstest.FakeFlagger{
			Data: map[string]interface{}{
				"y":     false,
				"force": true,
			},
		},
	}
	api := &libmachinetest.FakeAPI{
		Hosts: []*host.Host{
			{
				Name:   "machineToRemove1",
				Driver: &fakedriver.Driver{},
			},
			{
				Name:   "machineToRemove2",
				Driver: &fakedriver.Driver{},
			},
		},
	}

	err := cmdRm(commandLine, api)
	assert.NoError(t, err)

	assert.False(t, libmachinetest.Exists(api, "machineToRemove1"))
	assert.False(t, libmachinetest.Exists(api, "machineToRemove2"))
}
コード例 #2
0
ファイル: rm_test.go プロジェクト: MerlinDMC/machine
func TestDontStopWhenADriverRemovalFails(t *testing.T) {
	commandLine := &commandstest.FakeCommandLine{
		CliArgs: []string{"machineToRemove1", "machineToRemove2", "machineToRemove3"},
		LocalFlags: &commandstest.FakeFlagger{
			Data: map[string]interface{}{
				"y": true,
			},
		},
	}
	api := &libmachinetest.FakeAPI{
		Hosts: []*host.Host{
			{
				Name:   "machineToRemove1",
				Driver: &fakedriver.Driver{},
			},
			{
				Name:   "machineToRemove2",
				Driver: &DriverWithRemoveWhichFail{},
			},
			{
				Name:   "machineToRemove3",
				Driver: &fakedriver.Driver{},
			},
		},
	}

	err := cmdRm(commandLine, api)
	assert.EqualError(t, err, "Error removing host \"machineToRemove2\": unknown error")

	assert.False(t, libmachinetest.Exists(api, "machineToRemove1"))
	assert.True(t, libmachinetest.Exists(api, "machineToRemove2"))
	assert.False(t, libmachinetest.Exists(api, "machineToRemove3"))
}
コード例 #3
0
ファイル: rm_test.go プロジェクト: MerlinDMC/machine
func TestDontRemoveMachineIsRemovalFailsAndNotForced(t *testing.T) {
	commandLine := &commandstest.FakeCommandLine{
		CliArgs: []string{"machineToRemove1"},
		LocalFlags: &commandstest.FakeFlagger{
			Data: map[string]interface{}{
				"y":     true,
				"force": false,
			},
		},
	}
	api := &libmachinetest.FakeAPI{
		Hosts: []*host.Host{
			{
				Name:   "machineToRemove1",
				Driver: &DriverWithRemoveWhichFail{},
			},
		},
	}

	err := cmdRm(commandLine, api)
	assert.EqualError(t, err, "Error removing host \"machineToRemove1\": unknown error")

	assert.True(t, libmachinetest.Exists(api, "machineToRemove1"))
}
コード例 #4
0
ファイル: rm_test.go プロジェクト: RaulKite/machine
func TestForceRemoveEvenWhenItFails(t *testing.T) {
	commandLine := &commandstest.FakeCommandLine{
		CliArgs: []string{"machineToRemove1"},
		LocalFlags: &commandstest.FakeFlagger{
			Data: map[string]interface{}{
				"y":     true,
				"force": true,
			},
		},
	}
	api := &libmachinetest.FakeAPI{
		Hosts: []*host.Host{
			{
				Name:   "machineToRemove1",
				Driver: &DriverWithRemoveWhichFail{},
			},
		},
	}

	err := cmdRm(commandLine, api)
	assert.NoError(t, err)

	assert.False(t, libmachinetest.Exists(api, "machineToRemove1"))
}