@@ -2219,6 +2219,88 @@ func TestRunPluginInstallCLI(t *testing.T) {
22192219 }
22202220}
22212221
2222+ func TestRunPluginUpdateCLI (t * testing.T ) {
2223+ configHome := t .TempDir ()
2224+ t .Setenv ("CLAUDE_CONFIG_DIR" , configHome )
2225+ project := t .TempDir ()
2226+ if err := os .MkdirAll (filepath .Join (project , ".git" ), 0o755 ); err != nil {
2227+ t .Fatal (err )
2228+ }
2229+ marketDir := filepath .Join (t .TempDir (), "market-demo" )
2230+ if err := os .MkdirAll (filepath .Join (marketDir , "assets" ), 0o755 ); err != nil {
2231+ t .Fatal (err )
2232+ }
2233+ if err := os .WriteFile (filepath .Join (marketDir , "plugin.json" ), []byte (`{"name":"market demo","version":"1.0.0","description":"Deploy marketplace plugin"}` ), 0o644 ); err != nil {
2234+ t .Fatal (err )
2235+ }
2236+ if err := os .WriteFile (filepath .Join (marketDir , "assets" , "README.md" ), []byte ("v1" ), 0o644 ); err != nil {
2237+ t .Fatal (err )
2238+ }
2239+ settings := fmt .Sprintf (`{
2240+ "extraKnownMarketplaces": {
2241+ "team": {"source": {"source": "settings", "name": "team", "plugins": [%q]}}
2242+ },
2243+ "strictKnownMarketplaces": ["team"]
2244+ }` , marketDir )
2245+ if err := os .WriteFile (filepath .Join (configHome , "settings.json" ), []byte (settings ), 0o644 ); err != nil {
2246+ t .Fatal (err )
2247+ }
2248+
2249+ var stdout , stderr bytes.Buffer
2250+ code := run ([]string {"--cwd" , project , "plugin" , "install" , "--scope" , "project" , "market demo" }, strings .NewReader ("" ), & stdout , & stderr )
2251+ if code != 0 {
2252+ t .Fatalf ("install exit = %d stderr=%s" , code , stderr .String ())
2253+ }
2254+ if err := os .WriteFile (filepath .Join (marketDir , "plugin.json" ), []byte (`{"name":"market demo","version":"2.0.0","description":"Deploy marketplace plugin"}` ), 0o644 ); err != nil {
2255+ t .Fatal (err )
2256+ }
2257+ if err := os .WriteFile (filepath .Join (marketDir , "assets" , "README.md" ), []byte ("v2" ), 0o644 ); err != nil {
2258+ t .Fatal (err )
2259+ }
2260+ resolvedProject , err := filepath .EvalSymlinks (project )
2261+ if err != nil {
2262+ t .Fatal (err )
2263+ }
2264+ installedDir := filepath .Join (resolvedProject , ".claude" , "plugins" , "market-demo" )
2265+
2266+ stdout .Reset ()
2267+ stderr .Reset ()
2268+ code = run ([]string {"--cwd" , project , "plugin" , "update" , "--scope" , "project" , "market demo" }, strings .NewReader ("" ), & stdout , & stderr )
2269+ if code != 0 {
2270+ t .Fatalf ("update exit = %d stderr=%s" , code , stderr .String ())
2271+ }
2272+ for _ , want := range []string {
2273+ "Plugin update" ,
2274+ "Marketplace plugins: 1" ,
2275+ "Updated plugins: 1" ,
2276+ "- market demo -> " + installedDir ,
2277+ } {
2278+ if ! strings .Contains (stdout .String (), want ) {
2279+ t .Fatalf ("stdout missing %q: %q" , want , stdout .String ())
2280+ }
2281+ }
2282+ if data , err := os .ReadFile (filepath .Join (installedDir , "plugin.json" )); err != nil || ! strings .Contains (string (data ), `"version":"2.0.0"` ) {
2283+ t .Fatalf ("updated plugin json=%q err=%v" , data , err )
2284+ }
2285+ if data , err := os .ReadFile (filepath .Join (installedDir , "assets" , "README.md" )); err != nil || string (data ) != "v2" {
2286+ t .Fatalf ("updated asset data=%q err=%v" , data , err )
2287+ }
2288+
2289+ stdout .Reset ()
2290+ stderr .Reset ()
2291+ code = run ([]string {"--cwd" , project , "plugin" , "update" , "--scope" , "user" , "market demo" }, strings .NewReader ("" ), & stdout , & stderr )
2292+ if code != 2 || ! strings .Contains (stderr .String (), `scope "user" is not supported yet` ) {
2293+ t .Fatalf ("user scope exit=%d stdout=%q stderr=%q" , code , stdout .String (), stderr .String ())
2294+ }
2295+
2296+ stdout .Reset ()
2297+ stderr .Reset ()
2298+ code = run ([]string {"--cwd" , project , "plugin" , "update" , "missing" }, strings .NewReader ("" ), & stdout , & stderr )
2299+ if code != 1 || ! strings .Contains (stderr .String (), "installed plugin missing was not found" ) {
2300+ t .Fatalf ("missing exit=%d stdout=%q stderr=%q" , code , stdout .String (), stderr .String ())
2301+ }
2302+ }
2303+
22222304func TestRunPluginEnableDisableCLI (t * testing.T ) {
22232305 configHome := t .TempDir ()
22242306 t .Setenv ("CLAUDE_CONFIG_DIR" , configHome )
0 commit comments