From 5c6e36ae65f36d9edbf8fb4ad50bb0f5ed41388e Mon Sep 17 00:00:00 2001 From: Michael Brooks Date: Mon, 23 Nov 2026 15:07:00 -0700 Subject: [PATCH 1/2] fix: show the watch configuration hint when hooks omit the watch config --- internal/hooks/sdk_config.go | 2 +- internal/hooks/sdk_config_test.go | 28 ++++++++++++++++++++++++++-- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/internal/hooks/sdk_config.go b/internal/hooks/sdk_config.go index e3ae830f..dad996dc 100644 --- a/internal/hooks/sdk_config.go +++ b/internal/hooks/sdk_config.go @@ -37,7 +37,7 @@ type SDKCLIConfig struct { Start HookScript `json:"start,omitempty"` } `json:"hooks,omitempty"` Config struct { - Watch WatchOpts `json:"watch,omitempty"` + Watch *WatchOpts `json:"watch,omitempty"` SDKManagedConnection bool `json:"sdk-managed-connection-enabled,omitempty"` TriggerPaths []string `json:"trigger-paths,omitempty"` SupportedProtocols ProtocolVersions `json:"protocol-version,omitempty"` diff --git a/internal/hooks/sdk_config_test.go b/internal/hooks/sdk_config_test.go index e7cff337..f94cecdc 100644 --- a/internal/hooks/sdk_config_test.go +++ b/internal/hooks/sdk_config_test.go @@ -15,6 +15,7 @@ package hooks import ( + "encoding/json" "testing" "github.com/slackapi/slack-cli/internal/slackerror" @@ -54,7 +55,7 @@ func Test_ProtocolResolution(t *testing.T) { }{ "Returns the first valid protocol version": { config: SDKCLIConfig{Config: struct { - Watch WatchOpts `json:"watch,omitempty"` + Watch *WatchOpts `json:"watch,omitempty"` SDKManagedConnection bool `json:"sdk-managed-connection-enabled,omitempty"` TriggerPaths []string `json:"trigger-paths,omitempty"` SupportedProtocols ProtocolVersions `json:"protocol-version,omitempty"` @@ -72,7 +73,7 @@ func Test_ProtocolResolution(t *testing.T) { }, "Returns default config if no valid protocols are present": { config: SDKCLIConfig{Config: struct { - Watch WatchOpts `json:"watch,omitempty"` + Watch *WatchOpts `json:"watch,omitempty"` SDKManagedConnection bool `json:"sdk-managed-connection-enabled,omitempty"` TriggerPaths []string `json:"trigger-paths,omitempty"` SupportedProtocols ProtocolVersions `json:"protocol-version,omitempty"` @@ -122,6 +123,29 @@ func Test_WatchOpts_IsAvailable(t *testing.T) { } } +func Test_SDKCLIConfig_WatchIsAvailable(t *testing.T) { + tests := map[string]struct { + hooksJSON string + expectedIsAvailable bool + }{ + "watch config is provided": { + hooksJSON: `{"config":{"watch":{"manifest":{"paths":["manifest.json"]}}}}`, + expectedIsAvailable: true, + }, + "watch config is not provided": { + hooksJSON: `{"config":{}}`, + expectedIsAvailable: false, + }, + } + for name, tc := range tests { + t.Run(name, func(t *testing.T) { + var sdkCLIConfig SDKCLIConfig + require.NoError(t, json.Unmarshal([]byte(tc.hooksJSON), &sdkCLIConfig)) + require.Equal(t, tc.expectedIsAvailable, sdkCLIConfig.Config.Watch.IsAvailable()) + }) + } +} + func Test_WatchOpts_GetManifestWatchConfig(t *testing.T) { tests := map[string]struct { watchOpts *WatchOpts From 9c3dda540ebb4b65d0b92371a64443c2cf39512b Mon Sep 17 00:00:00 2001 From: Michael Brooks Date: Mon, 23 Nov 2026 15:10:19 -0700 Subject: [PATCH 2/2] test: cover watch options from hooks JSON in Test_WatchOpts_IsAvailable --- internal/hooks/sdk_config_test.go | 29 ++++++++++------------------- 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/internal/hooks/sdk_config_test.go b/internal/hooks/sdk_config_test.go index f94cecdc..478a189a 100644 --- a/internal/hooks/sdk_config_test.go +++ b/internal/hooks/sdk_config_test.go @@ -104,6 +104,7 @@ func Test_ProtocolResolution(t *testing.T) { func Test_WatchOpts_IsAvailable(t *testing.T) { tests := map[string]struct { watchOpts *WatchOpts + hooksJSON string expectedIsAvailable bool }{ "WatchOpts exists": { @@ -114,34 +115,24 @@ func Test_WatchOpts_IsAvailable(t *testing.T) { watchOpts: nil, expectedIsAvailable: false, }, - } - for name, tc := range tests { - t.Run(name, func(t *testing.T) { - returnedIsAvailable := tc.watchOpts.IsAvailable() - require.Equal(t, tc.expectedIsAvailable, returnedIsAvailable) - }) - } -} - -func Test_SDKCLIConfig_WatchIsAvailable(t *testing.T) { - tests := map[string]struct { - hooksJSON string - expectedIsAvailable bool - }{ - "watch config is provided": { + "Hooks config with watch options": { hooksJSON: `{"config":{"watch":{"manifest":{"paths":["manifest.json"]}}}}`, expectedIsAvailable: true, }, - "watch config is not provided": { + "Hooks config without watch options": { hooksJSON: `{"config":{}}`, expectedIsAvailable: false, }, } for name, tc := range tests { t.Run(name, func(t *testing.T) { - var sdkCLIConfig SDKCLIConfig - require.NoError(t, json.Unmarshal([]byte(tc.hooksJSON), &sdkCLIConfig)) - require.Equal(t, tc.expectedIsAvailable, sdkCLIConfig.Config.Watch.IsAvailable()) + if tc.hooksJSON != "" { + var sdkCLIConfig SDKCLIConfig + require.NoError(t, json.Unmarshal([]byte(tc.hooksJSON), &sdkCLIConfig)) + tc.watchOpts = sdkCLIConfig.Config.Watch + } + returnedIsAvailable := tc.watchOpts.IsAvailable() + require.Equal(t, tc.expectedIsAvailable, returnedIsAvailable) }) } }