-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: allow slash in slug to avoid gitlab subgroup flattening
- Loading branch information
1 parent
ad3391c
commit 73c73c2
Showing
2 changed files
with
38 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package util | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/gosimple/slug" | ||
) | ||
|
||
func TestSlugify(t *testing.T) { | ||
testCases := []struct { | ||
input string | ||
namingStyle string | ||
expectedOutput string | ||
}{ | ||
{"Hello World", "lowercase", "hello world"}, | ||
{"Hello World", "slug", "hello-world"}, | ||
{"Hello World/My Project", "slug", "hello-world/my-project"}, | ||
{"Hello World", "name", "Hello World"}, | ||
|
||
// Test case for empty naming style, defaulting to slug | ||
{"Hello World", "", slug.Make("Hello World")}, | ||
} | ||
|
||
for _, tc := range testCases { | ||
t.Run(tc.namingStyle, func(t *testing.T) { | ||
result := Slugify(tc.input, tc.namingStyle) | ||
|
||
if result != tc.expectedOutput { | ||
t.Errorf("Expected %s, but got %s", tc.expectedOutput, result) | ||
} | ||
}) | ||
} | ||
} |