mirror of
https://github.com/containrrr/watchtower.git
synced 2025-09-22 05:40:50 +02:00
feat(notifications): add title field to template data (#1125)
This commit is contained in:
parent
1d59fb83dd
commit
aa02d8d31b
9 changed files with 94 additions and 35 deletions
|
@ -48,9 +48,12 @@ var mockDataAllFresh = Data{
|
|||
}
|
||||
|
||||
func mockDataFromStates(states ...s.State) Data {
|
||||
hostname := "Mock"
|
||||
return Data{
|
||||
Entries: legacyMockData.Entries,
|
||||
Report: mocks.CreateMockProgressReport(states...),
|
||||
Title: GetTitle(hostname),
|
||||
Host: hostname,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -177,6 +180,22 @@ var _ = Describe("Shoutrrr", func() {
|
|||
|
||||
})
|
||||
|
||||
When("using a template referencing Title", func() {
|
||||
It("should contain the title in the output", func() {
|
||||
expected := `Watchtower updates on Mock`
|
||||
data := mockDataFromStates(s.UpdatedState)
|
||||
Expect(getTemplatedResult(`{{ .Title }}`, false, data)).To(Equal(expected))
|
||||
})
|
||||
})
|
||||
|
||||
When("using a template referencing Host", func() {
|
||||
It("should contain the hostname in the output", func() {
|
||||
expected := `Mock`
|
||||
data := mockDataFromStates(s.UpdatedState)
|
||||
Expect(getTemplatedResult(`{{ .Host }}`, false, data)).To(Equal(expected))
|
||||
})
|
||||
})
|
||||
|
||||
Describe("the default template", func() {
|
||||
When("all containers are fresh", func() {
|
||||
It("should return an empty string", func() {
|
||||
|
@ -278,6 +297,7 @@ func sendNotificationsWithBlockingRouter(legacy bool) (*shoutrrrTypeNotifier, *b
|
|||
done: make(chan bool),
|
||||
Router: router,
|
||||
legacyTemplate: legacy,
|
||||
params: &types.Params{},
|
||||
}
|
||||
|
||||
entry := &logrus.Entry{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue