Skip to content

Commit 6af8c5d

Browse files
feat: adding new forth color (blue) option
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
1 parent a3790e4 commit 6af8c5d

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

badge.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,14 @@ func (m *Markdown) GreenBadge(text string) *Markdown {
3434
func (m *Markdown) GreenBadgef(format string, args ...interface{}) *Markdown {
3535
return m.GreenBadge(fmt.Sprintf(format, args...))
3636
}
37+
38+
// BlueBadge set text with blue badge format.
39+
func (m *Markdown) blueBadge(text string) *Markdown {
40+
m.body = append(m.body, fmt.Sprintf("![Badge](https://img.shields.io/badge/%s-blue)", text))
41+
return m
42+
}
43+
44+
// BlueBadgef set text with blue badge format. It is similar to fmt.Sprintf.
45+
func (m *Markdown) BlueBadgef(format string, args ...interface{}) *Markdown {
46+
return m.blueBadge(fmt.Sprintf(format, args...))
47+
}

badge_test.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,17 @@ func TestMarkdown_RedBadgef(t *testing.T) {
4747
t.Errorf("value is mismatch (-want +got):\n%s", diff)
4848
}
4949
})
50+
51+
t.Run("success BlueBadgef()", func(t *testing.T) {
52+
t.Parallel()
53+
54+
m := NewMarkdown(io.Discard)
55+
m.BlueBadgef("%s", "Hello")
56+
want := []string{"![Badge](https://img.shields.io/badge/Hello-blue)"}
57+
got := m.body
58+
59+
if diff := cmp.Diff(want, got); diff != "" {
60+
t.Errorf("value is mismatch (-want +got):\n%s", diff)
61+
}
62+
})
5063
}

0 commit comments

Comments
 (0)