This is an automated email from the ASF dual-hosted git repository.
zixuan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pulsar-client-go.git
The following commit(s) were added to refs/heads/master by this push:
new 9785c01b fix(utils): add JSON tag for UpdateAuthData in UpdateOptions
(#1450)
9785c01b is described below
commit 9785c01be189b6756fbc6acafa2ca79cd8be6ec0
Author: Rui Fu <[email protected]>
AuthorDate: Mon Dec 15 11:32:33 2025 +0800
fix(utils): add JSON tag for UpdateAuthData in UpdateOptions (#1450)
* feat(utils): add JSON tag for UpdateAuthData in UpdateOptions
* add tests
* Update pulsaradmin/pkg/utils/update_options.go
Co-authored-by: Copilot <[email protected]>
---------
Co-authored-by: Copilot <[email protected]>
---
pulsaradmin/pkg/utils/update_options.go | 4 +--
.../{update_options.go => update_options_test.go} | 30 +++++++++++++++++-----
2 files changed, 25 insertions(+), 9 deletions(-)
diff --git a/pulsaradmin/pkg/utils/update_options.go
b/pulsaradmin/pkg/utils/update_options.go
index d78fccfc..731844b1 100644
--- a/pulsaradmin/pkg/utils/update_options.go
+++ b/pulsaradmin/pkg/utils/update_options.go
@@ -17,9 +17,9 @@
package utils
-// Options while updating the sink
+// Options while updating functions, sources, and sinks
type UpdateOptions struct {
- UpdateAuthData bool
+ UpdateAuthData bool `json:"updateAuthData"`
}
func NewUpdateOptions() *UpdateOptions {
diff --git a/pulsaradmin/pkg/utils/update_options.go
b/pulsaradmin/pkg/utils/update_options_test.go
similarity index 59%
copy from pulsaradmin/pkg/utils/update_options.go
copy to pulsaradmin/pkg/utils/update_options_test.go
index d78fccfc..b9497731 100644
--- a/pulsaradmin/pkg/utils/update_options.go
+++ b/pulsaradmin/pkg/utils/update_options_test.go
@@ -17,13 +17,29 @@
package utils
-// Options while updating the sink
-type UpdateOptions struct {
- UpdateAuthData bool
+import (
+ "encoding/json"
+ "testing"
+
+ "github.com/stretchr/testify/assert"
+ "github.com/stretchr/testify/require"
+)
+
+func TestUpdateOptionsMarshalJSON(t *testing.T) {
+ opts := UpdateOptions{UpdateAuthData: true}
+
+ data, err := json.Marshal(opts)
+ require.NoError(t, err)
+
+ assert.JSONEq(t, `{"updateAuthData":true}`, string(data))
}
-func NewUpdateOptions() *UpdateOptions {
- return &UpdateOptions{
- UpdateAuthData: false,
- }
+func TestUpdateOptionsUnmarshalJSON(t *testing.T) {
+ payload := `{"updateAuthData":true}`
+
+ var opts UpdateOptions
+ err := json.Unmarshal([]byte(payload), &opts)
+ require.NoError(t, err)
+
+ assert.True(t, opts.UpdateAuthData)
}