Skip to content

Commit 14e76d4

Browse files
authored
Docs and Tests (#14)
* Docs and Tests * Test Review
1 parent 47b3003 commit 14e76d4

File tree

4 files changed

+351
-11
lines changed

4 files changed

+351
-11
lines changed

CHANGELOG.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,28 @@
11
# Changelog
22

3+
## [1.4.9] - 2025-07-29
4+
5+
### 🧪 Testing
6+
7+
- Added **new unit tests** for `utify.go`, improving coverage and reliability.
8+
- Expanded tests to cover **logging-only functions** and **"Get" functions**.
9+
10+
### 📚 Documentation
11+
12+
- **Improved doccomments** in `utify.go`:
13+
- Added comprehensive package-level documentation.
14+
- Documented customization features for colors, icons, and logging.
15+
- Clarified usage examples for:
16+
- Direct output functions (e.g., `utify.Success()`)
17+
- Formatted functions (e.g., `utify.Infof()`)
18+
- Getters (e.g., `utify.GetSuccess()`)
19+
- Logging-only functions (e.g., `utify.LogInfo()`)
20+
21+
### 🛠 Maintenance
22+
23+
- Minor refactoring for **consistency across all message functions**.
24+
- Updated **aliases** for backward compatibility (`MessageType`, `Options`).
25+
326
## [1.4.8] - 2025-07-29
427

528
### 🔒 Security

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
![Stable Version](https://img.shields.io/github/v/release/jsas4coding/utify)
55
![License](https://img.shields.io/github/license/jsas4coding/utify)
66
![CI/CD](https://img.shields.io/github/actions/workflow/status/jsas4coding/utify/utify.yml?label=CI%2FCD&logo=githubactions&logoColor=white)
7-
![CodeQL](https://img.shields.io/github/actions/workflow/status/jsas4coding/utify/codeql-analysis.yml?label=CodeQL%20Security&logo=github&color=orange)
7+
![CodeQL](https://img.shields.io/github/actions/workflow/status/jsas4coding/utify/codeql-analysis.yml?label=CodeQL&style=flat-square)
88
![Coverage](https://img.shields.io/codecov/c/github/jsas4coding/utify?logo=codecov&logoColor=white)
99
![Stars](https://img.shields.io/github/stars/jsas4coding/utify?style=social)
1010

tests/unit/utify_test.go

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
package unit
2+
3+
import (
4+
"testing"
5+
6+
"github.com/jsas4coding/utify"
7+
)
8+
9+
func defaultOpts() *utify.Options {
10+
return utify.OptionsDefault()
11+
}
12+
13+
func TestBasicOutputFunctions(t *testing.T) {
14+
tests := []struct {
15+
name string
16+
fn func(string, *utify.Options)
17+
}{
18+
{"Success", utify.Success},
19+
{"Error", utify.Error},
20+
{"Warning", utify.Warning},
21+
{"Info", utify.Info},
22+
{"Debug", utify.Debug},
23+
{"Critical", utify.Critical},
24+
{"Delete", utify.Delete},
25+
{"Update", utify.Update},
26+
{"Install", utify.Install},
27+
{"Upgrade", utify.Upgrade},
28+
{"Edit", utify.Edit},
29+
{"New", utify.New},
30+
{"Download", utify.Download},
31+
{"Upload", utify.Upload},
32+
{"Sync", utify.Sync},
33+
{"Search", utify.Search},
34+
}
35+
36+
for _, tt := range tests {
37+
t.Run(tt.name, func(t *testing.T) {
38+
tt.fn("Test message", defaultOpts())
39+
})
40+
}
41+
}
42+
43+
func TestFormattedOutputFunctions(t *testing.T) {
44+
tests := []struct {
45+
name string
46+
fn func(string, *utify.Options, ...any)
47+
}{
48+
{"Successf", utify.Successf},
49+
{"Errorf", utify.Errorf},
50+
{"Warningf", utify.Warningf},
51+
{"Infof", utify.Infof},
52+
{"Debugf", utify.Debugf},
53+
{"Criticalf", utify.Criticalf},
54+
{"Deletef", utify.Deletef},
55+
{"Updatef", utify.Updatef},
56+
{"Installf", utify.Installf},
57+
{"Upgradef", utify.Upgradef},
58+
{"Editf", utify.Editf},
59+
{"Newf", utify.Newf},
60+
{"Downloadf", utify.Downloadf},
61+
{"Uploadf", utify.Uploadf},
62+
{"Syncf", utify.Syncf},
63+
{"Searchf", utify.Searchf},
64+
}
65+
66+
for _, tt := range tests {
67+
t.Run(tt.name, func(t *testing.T) {
68+
tt.fn("Formatted %s", defaultOpts(), "message")
69+
})
70+
}
71+
}
72+
73+
func TestGetFunctions(t *testing.T) {
74+
tests := []struct {
75+
name string
76+
fn func(string, *utify.Options) (string, error)
77+
}{
78+
{"GetSuccess", utify.GetSuccess},
79+
{"GetError", utify.GetError},
80+
{"GetWarning", utify.GetWarning},
81+
{"GetInfo", utify.GetInfo},
82+
{"GetDebug", utify.GetDebug},
83+
{"GetCritical", utify.GetCritical},
84+
{"GetDelete", utify.GetDelete},
85+
{"GetUpdate", utify.GetUpdate},
86+
{"GetInstall", utify.GetInstall},
87+
{"GetUpgrade", utify.GetUpgrade},
88+
{"GetEdit", utify.GetEdit},
89+
{"GetNew", utify.GetNew},
90+
{"GetDownload", utify.GetDownload},
91+
{"GetUpload", utify.GetUpload},
92+
{"GetSync", utify.GetSync},
93+
{"GetSearch", utify.GetSearch},
94+
}
95+
96+
for _, tt := range tests {
97+
t.Run(tt.name, func(t *testing.T) {
98+
_, err := tt.fn("Test message", defaultOpts())
99+
if err != nil && err != utify.ErrSilent {
100+
t.Errorf("%s returned unexpected error: %v", tt.name, err)
101+
}
102+
})
103+
}
104+
}
105+
106+
func TestLogOnlyFunctions(t *testing.T) {
107+
tests := []struct {
108+
name string
109+
fn func(string)
110+
}{
111+
{"LogSuccess", utify.LogSuccess},
112+
{"LogError", utify.LogError},
113+
{"LogWarning", utify.LogWarning},
114+
{"LogInfo", utify.LogInfo},
115+
{"LogDebug", utify.LogDebug},
116+
{"LogCritical", utify.LogCritical},
117+
{"LogDelete", utify.LogDelete},
118+
{"LogUpdate", utify.LogUpdate},
119+
{"LogInstall", utify.LogInstall},
120+
{"LogUpgrade", utify.LogUpgrade},
121+
{"LogEdit", utify.LogEdit},
122+
{"LogNew", utify.LogNew},
123+
{"LogDownload", utify.LogDownload},
124+
{"LogUpload", utify.LogUpload},
125+
{"LogSync", utify.LogSync},
126+
{"LogSearch", utify.LogSearch},
127+
}
128+
129+
for _, tt := range tests {
130+
t.Run(tt.name, func(t *testing.T) {
131+
tt.fn("Log-only message")
132+
})
133+
}
134+
}

0 commit comments

Comments
 (0)