Use long and short gh param value for color scheme and pattern

This commit is contained in:
Paul-Christian Volkmer 2023-02-05 17:51:21 +01:00
parent 18a1c2276b
commit 6f3912a543
2 changed files with 16 additions and 2 deletions

View File

@ -47,12 +47,12 @@ func requestHandler(w http.ResponseWriter, r *http.Request) {
cFunc := icons.ColorV2
if colorScheme == "v1" {
cFunc = icons.ColorV1
} else if colorScheme == "gh" {
} else if colorScheme == "gh" || colorScheme == "github" {
cFunc = icons.ColorGh
}
var iconGenerator icons.IconGenerator
if pattern == "github" {
if pattern == "github" || pattern == "gh" {
iconGenerator = icons.NewGhIconGenerator().WithColorGenerator(cFunc)
} else {
iconGenerator = icons.NewIdIconGenerator().WithColorGenerator(cFunc)

View File

@ -85,6 +85,20 @@ func TestCorrectResponseForGHColorSchemeAndPattern(t *testing.T) {
}
}
func TestCorrectResponseForAltGHColorSchemeAndPattern(t *testing.T) {
req, err := http.NewRequest("GET", "/avatar/1a79a4d60de6718e8e5b326e338ae533?c=github&d=gh", nil)
if err != nil {
t.Fatal(err)
}
rr := httptest.NewRecorder()
testRouter().ServeHTTP(rr, req)
if !reflect.DeepEqual(rr.Body.Bytes(), gh1) {
t.Errorf("returned image does not match expected image")
}
}
func TestUsesConfig(t *testing.T) {
configure("./testdata/testconfig.toml")