Skip to content

Commit 35d8add

Browse files
committed
add tests
1 parent c815795 commit 35d8add

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

pkg/file/azure_test.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"context"
55
"encoding/base64"
66
"errors"
7+
"math"
78
"net/url"
89
"strconv"
910
"testing"
@@ -102,6 +103,26 @@ func Test_azure_push(t *testing.T) {
102103
_ = localFile.Close()
103104
}
104105

106+
func TestValidateAndConvertToUint16(t *testing.T) {
107+
tests := []struct {
108+
desc string
109+
input int
110+
output uint16
111+
}{
112+
{"less than 0", -1, uint16(0)},
113+
{"is 0", 0, uint16(0)},
114+
{"is max uint16", math.MaxUint16, uint16(math.MaxUint16)},
115+
{"in uint16 range", 10, uint16(10)},
116+
{"greater than uint16 range", math.MaxUint16 + 1, uint16(0)},
117+
}
118+
119+
for _, tc := range tests {
120+
result := validateAndConvertToUint16(tc.input)
121+
122+
assert.Equal(t, tc.output, result)
123+
}
124+
}
125+
105126
func Test_azure_fetch(t *testing.T) {
106127
testPipelineMock := testPipeline{}
107128

0 commit comments

Comments
 (0)