Files
eleithandeleith e9271dd149 feat: Improve testing and add coverage enforcement (#3)
This commit introduces a test coverage check to the CI pipeline,
which will fail the build if the total coverage is below 60%. A
number of new tests were added to the project to meet this new
threshold. This change helps to maintain code quality by requiring
tests for new code.

The `config` and `archive` packages were refactored to make them
more modular and testable. The paths for the config file and the
archive directory are now defined in the `main.go` file, making
them a concern of the user rather than the package.

Finally, the `golangci-lint` dependency was removed from the
`tools.go` file, as per the recommendation of the `golangci-lint`
authors.

Reviewed-on: #3
Co-authored-by: eleith
Co-committed-by: eleith
2025-07-23 00:48:29 +00:00

51 lines
926 B
Go

package utils
import "testing"
func TestSlugify(t *testing.T) {
tests := []struct {
name string
input string
want string
}{
{
name: "simple case",
input: "Hello World",
want: "hello-world",
},
{
name: "with extra spaces",
input: " leading and trailing spaces ",
want: "leading-and-trailing-spaces",
},
{
name: "with special characters",
input: "special!@#$%^&*()_+-=[]{}|;':,./<>?`~characters",
want: "special-characters",
},
{
name: "with mixed case",
input: "MixedCase Test",
want: "mixedcase-test",
},
{
name: "empty string",
input: "",
want: "",
},
{
name: "string with only special characters",
input: "!@#$%^&*()",
want: "",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := Slugify(tt.input); got != tt.want {
t.Errorf("Slugify() = %v, want %v", got, tt.want)
}
})
}
}