Skip to content

Commit

Permalink
feat: adding new forth color (blue) option
Browse files Browse the repository at this point in the history
I guess we needed new color, I met a situation where I needed new color option

Let us say
red: failed deployment
yellow: deploying
green: deployed
blue: undeployed (new color)

I bilieve the third color would be able to fit  other scenarios  which must not necessary  be in error,warning,sucess color scheme
  • Loading branch information
claranceliberi committed Jun 1, 2024
1 parent a3790e4 commit 6af8c5d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
11 changes: 11 additions & 0 deletions badge.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,14 @@ func (m *Markdown) GreenBadge(text string) *Markdown {
func (m *Markdown) GreenBadgef(format string, args ...interface{}) *Markdown {
return m.GreenBadge(fmt.Sprintf(format, args...))
}

// BlueBadge set text with blue badge format.
func (m *Markdown) blueBadge(text string) *Markdown {
m.body = append(m.body, fmt.Sprintf("![Badge](https://img.shields.io/badge/%s-blue)", text))
return m
}

// BlueBadgef set text with blue badge format. It is similar to fmt.Sprintf.
func (m *Markdown) BlueBadgef(format string, args ...interface{}) *Markdown {
return m.blueBadge(fmt.Sprintf(format, args...))
}
13 changes: 13 additions & 0 deletions badge_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,17 @@ func TestMarkdown_RedBadgef(t *testing.T) {
t.Errorf("value is mismatch (-want +got):\n%s", diff)
}
})

t.Run("success BlueBadgef()", func(t *testing.T) {
t.Parallel()

m := NewMarkdown(io.Discard)
m.BlueBadgef("%s", "Hello")
want := []string{"![Badge](https://img.shields.io/badge/Hello-blue)"}
got := m.body

if diff := cmp.Diff(want, got); diff != "" {
t.Errorf("value is mismatch (-want +got):\n%s", diff)
}
})
}

0 comments on commit 6af8c5d

Please sign in to comment.