+func TestHandlerAddJob_shouldAddJobToJobsMap(t *testing.T) {
+ assertions := require.New(t)
+
+ jobInfo := JobInfo{
+ InfoTypeIdentity: "type1",
+ InfoJobIdentity: "job1",
+ TargetUri: "http://consumerHost/target",
+ }
+
+ addCh := make(chan JobInfo)
+ handlerUnderTest := jobHandler{
+ mu: sync.Mutex{},
+ jobs: map[string]JobInfo{},
+ addJobCh: addCh,
+ }
+
+ go func() {
+ addCh <- jobInfo
+ }()
+
+ handlerUnderTest.monitorManagementChannels()
+
+ assertions.Len(handlerUnderTest.jobs, 1)
+ assertions.Equal(jobInfo, handlerUnderTest.jobs["job1"])
+}
+
+func TestHandlerDeleteJob_shouldDeleteJobFromJobsMap(t *testing.T) {
+ assertions := require.New(t)
+
+ deleteCh := make(chan string)
+ handlerUnderTest := jobHandler{
+ mu: sync.Mutex{},
+ jobs: map[string]JobInfo{"job1": {
+ InfoJobIdentity: "job1",
+ }},
+ deleteJobCh: deleteCh,
+ }
+
+ go func() {
+ deleteCh <- "job1"
+ }()
+
+ handlerUnderTest.monitorManagementChannels()
+
+ assertions.Len(handlerUnderTest.jobs, 0)
+}
+