Skip to content

Commit b7889fe

Browse files
committed
add unit tests
1 parent 88ba4a3 commit b7889fe

File tree

13 files changed

+2532
-79
lines changed

13 files changed

+2532
-79
lines changed

.licenserc.yaml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Copyright 2024 StreamNative
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
#
15+
16+
header:
17+
license:
18+
spdx-id: Apache-2.0
19+
copyright-owner: StreamNative
20+
21+
paths-ignore:
22+
- 'dist'
23+
- 'licenses'
24+
- '**/*.md'
25+
- 'LICENSE'
26+
- 'NOTICE'
27+
- '.github/**'
28+
- 'PROJECT'
29+
- '**/go.mod'
30+
- '**/go.work'
31+
- '**/go.work.sum'
32+
- '**/go.sum'
33+
- '**/*.json'
34+
- 'sdk/**'
35+
- '**/*.yaml'
36+
- '**/*.yml'
37+
- 'Makefile'
38+
- '.gitignore'
39+
40+
comment: on-failure

Makefile

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,11 @@ build:
1919
-X ${VERSION_PATH}.date=${BUILD_DATE}" \
2020
-o bin/snmcp cmd/streamnative-mcp-server/main.go
2121

22-
# go install github.com/elastic/go-licenser@latest
23-
.PHONY: fix-license
24-
fix-license:
25-
go-licenser -license ASL2 -exclude sdk
22+
.PHONY: license-check
23+
license-check:
24+
license-eye header check
25+
26+
# go install github.com/apache/skywalking-eyes/cmd/license-eye@latest
27+
.PHONY: license-fix
28+
license-fix:
29+
license-eye header fix

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ require (
1717
github.com/streamnative/pulsarctl v0.4.3-0.20250312214758-e472faec284b
1818
github.com/streamnative/streamnative-mcp-server/sdk/sdk-apiserver v0.0.0-20250506174209-b67ea08ddd82
1919
github.com/streamnative/streamnative-mcp-server/sdk/sdk-kafkaconnect v0.0.0-00010101000000-000000000000
20+
github.com/stretchr/testify v1.10.0
2021
github.com/twmb/franz-go v1.18.1
2122
github.com/twmb/franz-go/pkg/kadm v1.16.0
2223
github.com/twmb/franz-go/pkg/sr v1.3.0

pkg/common/utils.go

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,22 @@ func RequiredParam[T comparable](arguments map[string]interface{}, p string) (T,
5555
return zero, fmt.Errorf("parameter %s is not of type %T", p, zero)
5656
}
5757

58-
if arguments[p].(T) == zero {
59-
return zero, fmt.Errorf("missing required parameter: %s", p)
60-
58+
_, isBool := interface{}(zero).(bool)
59+
_, isInt := interface{}(zero).(int)
60+
_, isInt8 := interface{}(zero).(int8)
61+
_, isInt16 := interface{}(zero).(int16)
62+
_, isInt32 := interface{}(zero).(int32)
63+
_, isInt64 := interface{}(zero).(int64)
64+
_, isFloat32 := interface{}(zero).(float32)
65+
_, isFloat64 := interface{}(zero).(float64)
66+
_, isUint8 := interface{}(zero).(uint8)
67+
_, isUint16 := interface{}(zero).(uint16)
68+
_, isUint32 := interface{}(zero).(uint32)
69+
_, isUint64 := interface{}(zero).(uint64)
70+
if !isBool && !isInt && !isInt8 && !isInt16 && !isInt32 && !isInt64 && !isFloat32 && !isFloat64 && !isUint8 && !isUint16 && !isUint32 && !isUint64 {
71+
if arguments[p].(T) == zero {
72+
return zero, fmt.Errorf("missing required parameter: %s", p)
73+
}
6174
}
6275

6376
return arguments[p].(T), nil

0 commit comments

Comments
 (0)