mirror of
https://git.fightbot.fun/hxuanyu/BingPaper.git
synced 2026-02-15 08:59:33 +08:00
增加多地区每日图片抓取能力
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package handlers
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"testing"
|
||||
@@ -66,3 +67,27 @@ func TestHandleImageResponseRedirect(t *testing.T) {
|
||||
assert.Contains(t, variants[0]["url"].(string), "/api/v1/image/date/")
|
||||
})
|
||||
}
|
||||
|
||||
func TestGetRegions(t *testing.T) {
|
||||
gin.SetMode(gin.TestMode)
|
||||
|
||||
t.Run("GetRegions should respect pinned order", func(t *testing.T) {
|
||||
// Setup config with custom pinned regions
|
||||
config.Init("")
|
||||
config.GetConfig().Fetcher.Regions = []string{"en-US", "ja-JP"}
|
||||
|
||||
w := httptest.NewRecorder()
|
||||
c, _ := gin.CreateTestContext(w)
|
||||
GetRegions(c)
|
||||
|
||||
assert.Equal(t, http.StatusOK, w.Code)
|
||||
|
||||
var regions []map[string]string
|
||||
err := json.Unmarshal(w.Body.Bytes(), ®ions)
|
||||
assert.NoError(t, err)
|
||||
|
||||
assert.GreaterOrEqual(t, len(regions), 2)
|
||||
assert.Equal(t, "en-US", regions[0]["value"])
|
||||
assert.Equal(t, "ja-JP", regions[1]["value"])
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user