Skip to content

test: add nil-kind coverage for IsNilObject (#352)#353

Merged
zouyx merged 4 commits intodevelopfrom
feature/mergeMaster
Mar 14, 2026
Merged

test: add nil-kind coverage for IsNilObject (#352)#353
zouyx merged 4 commits intodevelopfrom
feature/mergeMaster

Conversation

@zouyx
Copy link
Copy Markdown
Member

@zouyx zouyx commented Mar 14, 2026

No description provided.

Copilot AI review requested due to automatic review settings March 14, 2026 11:17
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 14, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 70098445-cbec-4908-9a0c-e573a56263e6

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature/mergeMaster
📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Tip

You can customize the tone of the review comments and chat replies.

Configure the tone_instructions setting to customize the tone of the review comments and chat replies. For example, you can set the tone to Act like a strict teacher, Act like a pirate and more.

@mergify
Copy link
Copy Markdown
Contributor

mergify Bot commented Mar 14, 2026

感谢您提出Pull Request,我会尽快Review。我会在1-2日内进行查看或者回复,如果遇到节假日可能会处理较慢,敬请谅解。

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR expands test coverage around nil-detection and YAML array parsing, and updates runtime behavior to better handle YAML-parsed slice types and 304-not-modified sync responses. It also includes widespread license-header normalization and some README/.gitignore updates across the repo.

Changes:

  • Add tests for IsNilObject across additional nil-able kinds (map/slice/chan/func/ptr) and add YAML array parsing tests.
  • Extend storage.Config slice getters to support values parsed as []interface{} (common from YAML/Viper).
  • Fix async sync behavior to acknowledge notifications even when config fetch returns HTTP 304 by making SyncWithNamespace return an error value and updating notification IDs on successful responses.

Reviewed changes

Copilot reviewed 80 out of 81 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
utils/utils_test.go Adds coverage for IsNilObject with more nil-able kinds.
utils/utils.go Comment/header formatting updates; nil detection logic unchanged.
utils/parse/yml/parser_test.go Adds YAML array parsing tests for the yml parser.
utils/parse/yml/parser.go Import formatting only.
utils/parse/yaml/parser_test.go Adds YAML array parsing tests for the yaml parser.
utils/parse/yaml/parser.go Import formatting only.
utils/parse/properties/parser_test.go License header normalization.
utils/parse/properties/parser.go License header normalization.
utils/parse/parser.go License header normalization and comment formatting.
utils/parse/normal/parser_test.go License header normalization.
utils/parse/normal/parser.go License header normalization.
storage/repository_test.go Adds tests for slice conversion behavior (YAML []interface{} cases).
storage/repository.go Adds []interface{}[]string/[]int conversions in slice getters.
storage/event_dispatch_test.go License header normalization.
storage/event_dispatch.go License header normalization.
storage/change_event_test.go License header normalization.
storage/change_event.go Comment formatting updates.
start_test.go Import ordering tweak and license header normalization.
start.go Comment formatting updates.
protocol/http/request_test.go Import reordering/cleanup and license header normalization.
protocol/http/request_server_test.go Minor formatting and license header normalization.
protocol/http/request.go Import ordering tweak and license header normalization.
protocol/auth/sign/sign_test.go License header normalization.
protocol/auth/sign/sign.go License header normalization.
protocol/auth/auth.go License header normalization.
mock_server_test.go Comment formatting updates.
extension/sign.go License header normalization.
extension/sgin_test.go License header normalization.
extension/load_balance_test.go Import ordering and comment formatting.
extension/load_balance.go Comment formatting updates.
extension/format_parser_test.go Import ordering and license header normalization.
extension/format_parser.go License header normalization.
extension/file_test.go Import ordering and license header normalization.
extension/file.go Comment formatting updates.
extension/cache_test.go Import ordering and comment formatting updates.
extension/cache.go Comment formatting updates.
env/server/server_test.go Import ordering and license header normalization.
env/server/server.go License header normalization.
env/request_config.go Comment formatting updates.
env/file/json/raw_test.go Import ordering and license header normalization.
env/file/json/raw.go Import ordering and comment formatting updates.
env/file/json/json_test.go Import ordering and license header normalization.
env/file/json/json.go Import ordering and comment formatting updates.
env/file/file_handler.go Comment formatting updates.
env/config/json/json_config_test.go Import ordering and license header normalization.
env/config/json/json_config.go License header normalization.
env/config/config_test.go Import ordering and license header normalization.
env/config/config.go License header normalization.
env/config/apollo_config_test.go Import ordering and license header normalization.
env/config/apollo_config.go Comment formatting updates.
env/app_config_test.go Import ordering and license header normalization.
env/app_config.go Comment formatting updates.
constant/config_file_format.go Comment formatting updates.
component/serverlist/sync_test.go Import ordering and license header normalization.
component/serverlist/sync.go Import ordering and license header normalization.
component/serverlist/app_config_server_test.go Comment formatting updates.
component/remote/sync_test.go Import ordering and comment formatting updates.
component/remote/sync.go Updates sync calls to match new SyncWithNamespace signature.
component/remote/remote.go Changes ApolloConfig.SyncWithNamespace to return (*config.ApolloConfig, error).
component/remote/async_test.go Adds regression test for 304-not-modified notification acknowledgement.
component/remote/async.go Updates notification ID on successful SyncWithNamespace (including 304).
component/remote/abs.go Implements new SyncWithNamespace signature and propagates request errors.
component/notify/mock_server_test.go License header normalization.
component/notify/componet_notify_test.go License header normalization.
component/notify/componet_notify.go Import ordering and license header normalization.
component/notify/change_event_test.go Import ordering and license header normalization.
component/log/log_test.go License header normalization.
component/log/log.go Comment formatting updates.
component/common_test.go Import ordering and license header normalization.
component/common.go License header normalization.
cluster/roundrobin/round_robin_test.go Import ordering and license header normalization.
cluster/roundrobin/round_robin.go Comment formatting updates.
cluster/load_balance.go Comment formatting updates.
client_test.go Updates mocks for new SyncWithNamespace signature; import reordering.
client.go Updates call sites for new SyncWithNamespace return values.
agcache/memory/memory_test.go Import ordering and license header normalization.
agcache/memory/memory.go Comment formatting updates.
agcache/cache.go Comment formatting updates.
README_CN.md Adds Chinese README.
README.md Adds language toggle and English content cleanup.
.gitignore Ignores test-generated JSON artifacts.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Comment on lines 24 to 30
"github.com/apolloconfig/agollo/v4/agcache/memory"
_ "github.com/apolloconfig/agollo/v4/agcache/memory"
"github.com/apolloconfig/agollo/v4/env"
"github.com/apolloconfig/agollo/v4/env/config"
_ "github.com/apolloconfig/agollo/v4/env/file/json"
jsonFile "github.com/apolloconfig/agollo/v4/env/file/json"
"github.com/apolloconfig/agollo/v4/extension"
Comment on lines +27 to +31
_ "github.com/apolloconfig/agollo/v4/agcache/memory"
"github.com/apolloconfig/agollo/v4/cluster/roundrobin"
"github.com/apolloconfig/agollo/v4/component/remote"
"github.com/apolloconfig/agollo/v4/env/config"
_ "github.com/apolloconfig/agollo/v4/env/file/json"
Comment thread client_test.go
"github.com/apolloconfig/agollo/v4/agcache/memory"
"github.com/apolloconfig/agollo/v4/component/remote"
"github.com/apolloconfig/agollo/v4/env/config"
_ "github.com/apolloconfig/agollo/v4/env/file/json"
CallBack(namespace string) http.CallBack
// SyncWithNamespace 通过 namespace 同步 apollo 配置
SyncWithNamespace(namespace string, appConfigFunc func() config.AppConfig) *config.ApolloConfig
SyncWithNamespace(namespace string, appConfigFunc func() config.AppConfig) (*config.ApolloConfig, error)
Comment thread storage/repository.go
Comment on lines +170 to +176
// 尝试直接转换为 []string
if v, ok := value.([]string); ok {
return v
}
return v

// 尝试从 []interface{} 转换为 []string (YAML 数组解析后的类型)
if ifaceSlice, ok := value.([]interface{}); ok {
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR broadens test coverage around nil detection and YAML array parsing, extends config slice getters to handle YAML-parsed []interface{} values, and adjusts remote sync behavior/API to prevent repeated notifications on 304 responses. It also includes widespread license-header normalization plus README and .gitignore updates.

Changes:

  • Add tests for IsNilObject across nil-able kinds, and YAML/YML array parsing.
  • Extend Config slice getters ([]string/[]int) to convert from []interface{} (common from YAML parsing) and add corresponding repository tests.
  • Change remote SyncWithNamespace API to return (config, error) and update notification IDs on successful syncs (including 304), plus add a regression test for the 304 loop scenario.

Reviewed changes

Copilot reviewed 80 out of 81 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
utils/utils_test.go Add IsNilObject nil-kind tests; update header.
utils/utils.go Comment/header normalization (no logic change).
utils/parse/yml/parser_test.go Add YML array parsing test; import order/header.
utils/parse/yml/parser.go Import order/header normalization.
utils/parse/yaml/parser_test.go Add YAML array parsing test; import order/header.
utils/parse/yaml/parser.go Import order/header normalization.
utils/parse/properties/parser_test.go Header normalization.
utils/parse/properties/parser.go Header normalization.
utils/parse/parser.go Comment/header normalization.
utils/parse/normal/parser_test.go Header normalization.
utils/parse/normal/parser.go Header normalization.
storage/repository_test.go Add slice-conversion tests (YAML []interface{} cases).
storage/repository.go Convert []interface{} to []string/[]int in getters.
storage/event_dispatch_test.go Header normalization.
storage/event_dispatch.go Header normalization.
storage/change_event_test.go Header normalization.
storage/change_event.go Comment/header normalization.
start_test.go Import order/header normalization.
start.go Comment/header normalization.
protocol/http/request_test.go Import order/header normalization.
protocol/http/request_server_test.go Minor formatting/header normalization.
protocol/http/request.go Import order/header normalization.
protocol/auth/sign/sign_test.go Header normalization.
protocol/auth/sign/sign.go Header normalization.
protocol/auth/auth.go Header normalization.
mock_server_test.go Comment/header normalization.
extension/sign.go Header normalization.
extension/sgin_test.go Header normalization.
extension/load_balance_test.go Import order/comment normalization.
extension/load_balance.go Comment/header normalization.
extension/format_parser_test.go Import order/header normalization.
extension/format_parser.go Header normalization.
extension/file_test.go Import order/header normalization.
extension/file.go Comment/header normalization.
extension/cache_test.go Import order/comment normalization.
extension/cache.go Comment/header normalization.
env/server/server_test.go Import order/header normalization.
env/server/server.go Header normalization.
env/request_config.go Comment/header normalization.
env/file/json/raw_test.go Import order/header normalization.
env/file/json/raw.go Import order/comment normalization.
env/file/json/json_test.go Import order/header normalization.
env/file/json/json.go Import order/comment normalization.
env/file/file_handler.go Comment/header normalization.
env/config/json/json_config_test.go Import order/header normalization.
env/config/json/json_config.go Header normalization.
env/config/config_test.go Import order/header normalization.
env/config/config.go Header normalization.
env/config/apollo_config_test.go Import order/header normalization.
env/config/apollo_config.go Comment/header normalization.
env/app_config_test.go Import order/header normalization.
env/app_config.go Comment/header normalization.
constant/config_file_format.go Comment/header normalization.
component/serverlist/sync_test.go Import order/header normalization.
component/serverlist/sync.go Import order/header normalization.
component/serverlist/app_config_server_test.go Comment/header normalization.
component/remote/sync_test.go Import order/comment normalization.
component/remote/sync.go Adapt to new SyncWithNamespace signature.
component/remote/remote.go Change interface method signature to return error.
component/remote/async_test.go Add regression test for 304 notification loop.
component/remote/async.go Update notify ID on successful syncs (incl. 304).
component/remote/abs.go Return errors from SyncWithNamespace.
component/notify/mock_server_test.go Header normalization.
component/notify/componet_notify_test.go Header normalization.
component/notify/componet_notify.go Import order/header normalization.
component/notify/change_event_test.go Import order/header normalization.
component/log/log_test.go Header normalization.
component/log/log.go Comment/header normalization.
component/common_test.go Import order/header normalization.
component/common.go Header normalization.
cluster/roundrobin/round_robin_test.go Import order/header normalization.
cluster/roundrobin/round_robin.go Comment/header normalization.
cluster/load_balance.go Comment/header normalization.
client_test.go Update mocks for new SyncWithNamespace signature.
client.go Adapt call site to new SyncWithNamespace signature.
agcache/memory/memory_test.go Import order/header normalization.
agcache/memory/memory.go Comment/header normalization.
agcache/cache.go Comment/header normalization.
README_CN.md Add Chinese README.
README.md Add language switch + English rewrite/example tweaks.
.gitignore Ignore additional test-generated JSON artifacts.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Comment on lines 24 to +26
"github.com/apolloconfig/agollo/v4/agcache/memory"
_ "github.com/apolloconfig/agollo/v4/agcache/memory"
"github.com/apolloconfig/agollo/v4/env"
Comment thread storage/repository.go
Comment on lines +413 to +420
// JSON/YAML 数字默认解析为 float64
// 验证值是否为整数(无小数部分)
if v != float64(int(v)) {
log.Debugf("convert to []int fail! float64 value has fractional part: %v", v)
return defaultValue
}
result = append(result, int(v))
case string:
Comment thread storage/repository.go
Comment on lines +170 to +176
// 尝试直接转换为 []string
if v, ok := value.([]string); ok {
return v
}
return v

// 尝试从 []interface{} 转换为 []string (YAML 数组解析后的类型)
if ifaceSlice, ok := value.([]interface{}); ok {
Comment thread README.md
Check out our [Wiki](https://github.com/apolloconfig/agollo/wiki) or [godoc](http://godoc.org/github.com/zouyx/agollo) for more information.

如果你觉得该工具还不错或者有问题,一定要让我知道,可以发邮件或者[留言](https://github.com/apolloconfig/agollo/issues)。
If you find this tool useful or encounter any issues, please let me know via email or by [creating an issue](https://github.com/apolloconfig/agollo/issues)。
Comment on lines 27 to 29
"github.com/apolloconfig/agollo/v4/env/config"
_ "github.com/apolloconfig/agollo/v4/env/file/json"
jsonFile "github.com/apolloconfig/agollo/v4/env/file/json"
. "github.com/tevid/gohamcrest"

"github.com/apolloconfig/agollo/v4/agcache/memory"
_ "github.com/apolloconfig/agollo/v4/agcache/memory"
Comment on lines +27 to +31
_ "github.com/apolloconfig/agollo/v4/agcache/memory"
"github.com/apolloconfig/agollo/v4/cluster/roundrobin"
"github.com/apolloconfig/agollo/v4/component/remote"
"github.com/apolloconfig/agollo/v4/env/config"
_ "github.com/apolloconfig/agollo/v4/env/file/json"
Comment thread storage/repository.go
Comment on lines +211 to +218
case float64:
// JSON/YAML 数字默认解析为 float64
// 验证值是否为整数(无小数部分)
if v != float64(int(v)) {
log.Debugf("convert to []int fail! float64 value has fractional part: %v", v)
return defaultValue
}
result = append(result, int(v))
Comment on lines +33 to 34
SyncWithNamespace(namespace string, appConfigFunc func() config.AppConfig) (*config.ApolloConfig, error)
}
@zouyx zouyx merged commit 9f10a7a into develop Mar 14, 2026
5 checks passed
@zouyx zouyx deleted the feature/mergeMaster branch March 14, 2026 13:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants