示例#1
0
func TestSpaceRequirement(t *testing.T) {
	ui := new(testterm.FakeUI)
	config := &configuration.Configuration{
		Organization: cf.Organization{
			Name: "my-org",
			Guid: "my-org-guid",
		},
		Space: cf.Space{
			Name: "my-space",
			Guid: "my-space-guid",
		},
	}

	req := newTargetedSpaceRequirement(ui, config)
	success := req.Execute()
	assert.True(t, success)

	config.Space = cf.Space{}

	req = newTargetedSpaceRequirement(ui, config)
	success = req.Execute()
	assert.False(t, success)
	assert.Contains(t, ui.Outputs[0], "FAILED")
	assert.Contains(t, ui.Outputs[1], "No space targeted")

	ui.ClearOutputs()
	config.Organization = cf.Organization{}

	req = newTargetedSpaceRequirement(ui, config)
	success = req.Execute()
	assert.False(t, success)
	assert.Contains(t, ui.Outputs[0], "FAILED")
	assert.Contains(t, ui.Outputs[1], "No org and space targeted")
}
示例#2
0
func TestSpaceRequirement(t *testing.T) {
	ui := new(testterm.FakeUI)
	org := cf.OrganizationFields{}
	org.Name = "my-org"
	org.Guid = "my-org-guid"
	space := cf.SpaceFields{}
	space.Name = "my-space"
	space.Guid = "my-space-guid"
	config := &configuration.Configuration{
		OrganizationFields: org,

		SpaceFields: space,
	}

	req := newTargetedSpaceRequirement(ui, config)
	success := req.Execute()
	assert.True(t, success)

	config.SpaceFields = cf.SpaceFields{}

	req = newTargetedSpaceRequirement(ui, config)
	success = req.Execute()
	assert.False(t, success)
	testassert.SliceContains(t, ui.Outputs, testassert.Lines{
		{"FAILED"},
		{"No space targeted"},
	})

	ui.ClearOutputs()
	config.OrganizationFields = cf.OrganizationFields{}

	req = newTargetedSpaceRequirement(ui, config)
	success = req.Execute()
	assert.False(t, success)
	testassert.SliceContains(t, ui.Outputs, testassert.Lines{
		{"FAILED"},
		{"No org and space targeted"},
	})
}
示例#3
0
		config := testconfig.NewRepositoryWithDefaults()

		req := NewTargetedSpaceRequirement(ui, config)
		success := req.Execute()
		Expect(success).To(BeTrue())

		config.SetSpaceFields(models.SpaceFields{})

		testassert.AssertPanic(testterm.FailedWasCalled, func() {
			NewTargetedSpaceRequirement(ui, config).Execute()
		})

		testassert.SliceContains(ui.Outputs, testassert.Lines{
			{"FAILED"},
			{"No space targeted"},
		})

		ui.ClearOutputs()
		config.SetOrganizationFields(models.OrganizationFields{})

		testassert.AssertPanic(testterm.FailedWasCalled, func() {
			NewTargetedSpaceRequirement(ui, config).Execute()
		})

		testassert.SliceContains(ui.Outputs, testassert.Lines{
			{"FAILED"},
			{"No org and space targeted"},
		})
	})
})