Skip to content

Commit

Permalink
test: fix test compile
Browse files Browse the repository at this point in the history
  • Loading branch information
ppzqh committed Aug 19, 2024
1 parent a7d2e89 commit 33481ac
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 17 deletions.
16 changes: 16 additions & 0 deletions pkg/remote/codec/validate.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*
* Copyright 2024 CloudWeGo Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package codec

import (
Expand Down
4 changes: 0 additions & 4 deletions pkg/remote/codec/validate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,20 +74,16 @@ func TestPayloadChecksumGenerate(t *testing.T) {
test.Assert(t, err == nil, err)
test.Assert(t, len(strInfo) != 0)
test.Assert(t, strInfo[getValidatorKey(ctx, pv)] != "")
message.Recycle()

// failed, generate error
message = initClientSendMsg(transport.TTHeader)
strInfo = message.TransInfo().TransStrInfo()
ctx = context.WithValue(context.Background(), mockGenerateErrorKey, "true")
err = payloadChecksumGenerate(ctx, pv, payload, message)
test.Assert(t, err != nil, err)
test.Assert(t, errors.Is(err, kerrors.ErrPayloadValidation))
message.Recycle()

// failed, exceed limit
message = initClientSendMsg(transport.TTHeader)
strInfo = message.TransInfo().TransStrInfo()
ctx = context.WithValue(context.Background(), mockExceedLimitKey, "true")
err = payloadChecksumGenerate(ctx, pv, payload, message)
test.Assert(t, err != nil, err)
Expand Down
13 changes: 0 additions & 13 deletions pkg/remote/trans/netpoll/bytebuf_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,19 +223,6 @@ func TestBytes(t *testing.T) {
b1, err := netpollBuff.Bytes()
test.Assert(t, err == nil)
test.Assert(t, string(b1) == b)

// GetBytesNoCopy
b2, n, err := netpollBuff.(remote.NocopyRead).GetBytesNoCopy()
test.Assert(t, n == len(b))
test.Assert(t, err == nil)
actual := make([]byte, n)
off := 0
for i := 0; i < len(b2); i++ {
off += copy(actual[off:], b2[i])
}
for i := 0; i < n; i++ {
test.Assert(t, actual[i] == b[i])
}
}

func TestRelease(t *testing.T) {
Expand Down

0 comments on commit 33481ac

Please sign in to comment.