Skip to content

Commit

Permalink
Merge pull request #70 from stakater/fix-customer-tests
Browse files Browse the repository at this point in the history
Fix customer tests
  • Loading branch information
ahmedwaleedmalik authored Mar 15, 2021
2 parents 35f3572 + d69deaa commit b1dc2fb
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 4 deletions.
4 changes: 2 additions & 2 deletions controllers/customer_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,12 @@ var _ = Describe("Customer Controller", func() {

Expect(customer.Status.CustomerId).ToNot(Equal(""))

customer.Spec.Projects = mockData.RemovedProjectsList
customer.Spec.Projects = []string{strings.ToUpper(projectKey)}

_ = cUtil.UpdateCustomer(customer, ns)
updatedCustomer := cUtil.GetCustomer(customer.Spec.Name, ns)

Expect(updatedCustomer.Status.AssociatedProjects).To(BeNil())
Expect(customer.Spec.Projects).To(Equal(updatedCustomer.Status.AssociatedProjects))
})
})
})
Expand Down
9 changes: 8 additions & 1 deletion controllers/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ var cUtil *controllerUtil.TestUtil

var log = logf.Log.WithName("config")
var customerKey = cUtil.RandSeqString(3)
var projectKey = cUtil.RandSeqString(3)

func TestAPIs(t *testing.T) {
RegisterFailHandler(Fail)
Expand Down Expand Up @@ -134,14 +135,20 @@ var _ = BeforeSuite(func(done Done) {
mockData.CustomerTestProjectInput.Spec.Name += customerKey
mockData.CustomerTestProjectInput.Spec.Key = strings.ToUpper(customerKey)

mockData.SampleProjectInput.Spec.Name += projectKey
mockData.SampleProjectInput.Spec.Key = strings.ToUpper(projectKey)

// Creating projects for customer tests
_ = util.CreateProject(mockData.CustomerTestProjectInput, ns)
_ = util.CreateProject(mockData.SampleProjectInput, ns)

close(done)
}, 60)

var _ = AfterSuite(func() {
// Delete the project created for customer tests
// Delete the projects created for customer tests
util.DeleteProject(mockData.CustomerTestProjectInput.Spec.Name, ns)
util.DeleteProject(mockData.SampleProjectInput.Spec.Name, ns)

// Cleanup - Delete all remnent resources
util.DeleteAllProjects(ns)
Expand Down
17 changes: 16 additions & 1 deletion mock/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,14 @@ var AddCustomerSuccessResponse = map[string]interface{}{
}

var AddedProjectsList = []string{"CTP"}
var RemovedProjectsList = []string{}

var SampleCustomer = jiraservicedeskv1alpha1.Customer{
Spec: jiraservicedeskv1alpha1.CustomerSpec{
Name: "customer",
Email: "[email protected]",
Projects: []string{
"SAMPLE",
},
},
}

Expand Down Expand Up @@ -111,6 +113,19 @@ var CreateProjectInvalidInput = jiraservicedeskv1alpha1.Project{
},
}

var SampleProjectInput = jiraservicedeskv1alpha1.Project{
Spec: jiraservicedeskv1alpha1.ProjectSpec{
Name: "sampleproject",
Key: "SAMPLE",
ProjectTypeKey: "service_desk",
ProjectTemplateKey: "com.atlassian.servicedesk:itil-v2-service-desk-project",
Description: "Sample project for jira-service-desk-operator",
AssigneeType: "PROJECT_LEAD",
LeadAccountId: "5f62e5902b42470070d1fb83",
URL: "https://test.com",
},
}

var UpdateMutableProjectFields = struct {
Name string
Key string
Expand Down

0 comments on commit b1dc2fb

Please sign in to comment.