Skip to content

Commit 3cb96f8

Browse files
committed
refactor: update fileserver HTTP test to use httpz.DataResponse for decoding upload responses
- Replace generic map decoding with `httpz.DataResponse[fileserver.UploadResult]` for improved type safety and clarity in test cases. Signed-off-by: tbxark <tbxark@outlook.com>
1 parent 64a206d commit 3cb96f8

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

storage/test/fileserver_http_test.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import (
1717

1818
"github.com/go-sphere/httpx"
1919
"github.com/go-sphere/sphere/cache/memory"
20+
"github.com/go-sphere/sphere/server/httpz"
2021
"github.com/go-sphere/sphere/storage"
2122
"github.com/go-sphere/sphere/storage/fileserver"
2223
)
@@ -73,12 +74,12 @@ func TestFileServerUploadAndDownloadOverHTTP(t *testing.T) {
7374
body, _ := io.ReadAll(putResp.Body)
7475
t.Fatalf("upload status = %d, want %d, body = %s", putResp.StatusCode, http.StatusOK, string(body))
7576
}
76-
var putResult map[string]string
77+
var putResult httpz.DataResponse[fileserver.UploadResult]
7778
if err = json.NewDecoder(putResp.Body).Decode(&putResult); err != nil {
7879
t.Fatalf("decode upload response: %v", err)
7980
}
80-
if putResult["key"] != key {
81-
t.Fatalf("upload response key = %q, want %q", putResult["key"], key)
81+
if putResult.Data.Key != key {
82+
t.Fatalf("upload response key = %q, want %q", putResult.Data.Key, key)
8283
}
8384

8485
getResp, err := server.Client().Get(downloadURL)

0 commit comments

Comments
 (0)