Skip to content

Commit

Permalink
Test metadata, not fields for evt cancelled info
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewvc committed Apr 30, 2019
1 parent b860676 commit 61cdef9
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions heartbeat/monitors/wrappers/monitors_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,11 @@ type fields struct {
}

type testDef struct {
name string
fields fields
jobs []jobs.Job
want []mapval.Validator
name string
fields fields
jobs []jobs.Job
want []mapval.Validator
metaWant []mapval.Validator
}

func testCommonWrap(t *testing.T, tt testDef) {
Expand All @@ -57,6 +58,11 @@ func testCommonWrap(t *testing.T, tt testDef) {
t.Run(fmt.Sprintf("result at index %d", idx), func(t *testing.T) {
want := tt.want[idx]
mapval.Test(t, mapval.Strict(want), r.Fields)

if tt.metaWant != nil {
metaWant := tt.metaWant[idx]
mapval.Test(t, mapval.Strict(metaWant), r.Meta)
}
})
}
})
Expand All @@ -83,6 +89,7 @@ func TestSimpleJob(t *testing.T) {
}),
summaryValidator(1, 0),
)},
nil,
})
}

Expand Down Expand Up @@ -116,6 +123,7 @@ func TestErrorJob(t *testing.T) {
errorJobValidator,
summaryValidator(0, 1),
)},
nil,
})
}

Expand Down Expand Up @@ -146,6 +154,7 @@ func TestMultiJobNoConts(t *testing.T) {
fields,
[]jobs.Job{makeURLJob(t, "http://foo.com"), makeURLJob(t, "http://bar.com")},
[]mapval.Validator{validator("http://foo.com"), validator("http://bar.com")},
nil,
})
}

Expand Down Expand Up @@ -203,6 +212,7 @@ func TestMultiJobConts(t *testing.T) {
summaryValidator(2, 0),
),
},
nil,
})
}

Expand Down Expand Up @@ -245,28 +255,33 @@ func TestMultiJobContsCancelledEvents(t *testing.T) {
)
}

metaCancelledValidator := mapval.MustCompile(mapval.Map{eventext.EventCancelledMetaKey: true})
testCommonWrap(t, testDef{
"multi-job-continuations",
fields,
[]jobs.Job{makeContJob(t, "http://foo.com"), makeContJob(t, "http://bar.com")},
[]mapval.Validator{
mapval.Compose(
contJobValidator("http://foo.com", "1st"),
mapval.MustCompile(mapval.Map{eventext.EventCancelledMetaKey: true}),
),
mapval.Compose(
contJobValidator("http://foo.com", "2nd"),
summaryValidator(1, 0),
),
mapval.Compose(
contJobValidator("http://bar.com", "1st"),
mapval.MustCompile(mapval.Map{eventext.EventCancelledMetaKey: true}),
),
mapval.Compose(
contJobValidator("http://bar.com", "2nd"),
summaryValidator(1, 0),
),
},
[]mapval.Validator{
metaCancelledValidator,
mapval.MustCompile(mapval.Map{}),
metaCancelledValidator,
mapval.MustCompile(mapval.Map{}),
},
})
}

Expand Down

0 comments on commit 61cdef9

Please sign in to comment.