aboutsummaryrefslogtreecommitdiff
path: root/lib/http/server_test.go
diff options
context:
space:
mode:
authorShulhan <ms@kilabit.info>2023-09-10 21:27:22 +0700
committerShulhan <ms@kilabit.info>2023-09-11 02:16:52 +0700
commit310ca99dd0b47e15428089028546fcfa1e0e02e7 (patch)
tree1aa5ec46b562e8f183937347bc6252fbe9a48185 /lib/http/server_test.go
parentdf58e21e4a8fa4fa308ec1b791867968972f57f3 (diff)
downloadpakakeh.go-310ca99dd0b47e15428089028546fcfa1e0e02e7.tar.xz
lib/http: realign struct for better size allocation
The realignment reduce the cost of the following struct, * EndpointResponse: from 72 to 56 bytes (-16 bytes) * RangePosition: from 48 to 24 bytes (-24 bytes) * testCase in TestParseContentRange: from 24 to 16 bytes (-8 bytes)
Diffstat (limited to 'lib/http/server_test.go')
-rw-r--r--lib/http/server_test.go12
1 files changed, 6 insertions, 6 deletions
diff --git a/lib/http/server_test.go b/lib/http/server_test.go
index bea01131..fd7330d6 100644
--- a/lib/http/server_test.go
+++ b/lib/http/server_test.go
@@ -757,32 +757,32 @@ func TestStatusError(t *testing.T) {
desc: "With registered error no body",
reqURL: testServerUrl + "/error/no-body?k=v",
expStatusCode: http.StatusLengthRequired,
- expBody: `{"code":411,"message":"Length required"}`,
+ expBody: `{"message":"Length required","code":411}`,
}, {
desc: "With registered error binary",
reqURL: testServerUrl + "/error/binary?k=v",
expStatusCode: http.StatusLengthRequired,
- expBody: `{"code":411,"message":"Length required"}`,
+ expBody: `{"message":"Length required","code":411}`,
}, {
desc: "With registered error plain",
reqURL: testServerUrl + "/error/plain?k=v",
expStatusCode: http.StatusLengthRequired,
- expBody: `{"code":411,"message":"Length required"}`,
+ expBody: `{"message":"Length required","code":411}`,
}, {
desc: "With registered error plain",
reqURL: testServerUrl + "/error/json?k=v",
expStatusCode: http.StatusLengthRequired,
- expBody: `{"code":411,"message":"Length required"}`,
+ expBody: `{"message":"Length required","code":411}`,
}, {
desc: "With registered error plain",
reqURL: testServerUrl + "/error/no-code?k=v",
expStatusCode: http.StatusInternalServerError,
- expBody: `{"code":500,"message":"internal server error","name":"ERR_INTERNAL"}`,
+ expBody: `{"message":"internal server error","name":"ERR_INTERNAL","code":500}`,
}, {
desc: "With registered error plain",
reqURL: testServerUrl + "/error/custom?k=v",
expStatusCode: http.StatusInternalServerError,
- expBody: `{"code":500,"message":"internal server error","name":"ERR_INTERNAL"}`,
+ expBody: `{"message":"internal server error","name":"ERR_INTERNAL","code":500}`,
}}
for _, c := range cases {