diff --git a/cmd/agent/agents.go b/cmd/agent/agents.go index d48eec9..b862c72 100644 --- a/cmd/agent/agents.go +++ b/cmd/agent/agents.go @@ -145,24 +145,6 @@ var agentDefs = map[string]agentDef{ }, } -var confirmationToolNames = computeConfirmationToolNames() - -func computeConfirmationToolNames() map[string]struct{} { - readOnly := make(map[string]struct{}, len(agentDefs["Aagje"].toolNames)) - for _, name := range agentDefs["Aagje"].toolNames { - readOnly[name] = struct{}{} - } - - result := make(map[string]struct{}) - for _, key := range []string{"Knorretje", "Daan"} { - for _, name := range agentDefs[key].toolNames { - if _, ok := readOnly[name]; !ok { - result[name] = struct{}{} - } - } - } - return result -} func init() { for _, def := range agentDefs { @@ -172,10 +154,6 @@ func init() { } } -func requireConfirmation(name string, _ any) bool { - _, ok := confirmationToolNames[name] - return ok -} func buildOrchestrator( advancedModel, liteModel model.LLM, mcpToolSet tool.Toolset, diff --git a/cmd/flags.go b/cmd/flags.go index 8f24037..aeaa4f7 100644 --- a/cmd/flags.go +++ b/cmd/flags.go @@ -57,7 +57,7 @@ func confirmWithTTYOverride(cmd *cobra.Command, isTTY bool, format string, args // 1. --dry-run takes precedence over everything. if DryRun(cmd) { - fmt.Fprintln(cmd.OutOrStdout(), msg) + _, _ = fmt.Fprintln(cmd.OutOrStdout(), msg) return ErrDryRun } diff --git a/pkg/caption/caption_test.go b/pkg/caption/caption_test.go index 14c7e22..397780b 100644 --- a/pkg/caption/caption_test.go +++ b/pkg/caption/caption_test.go @@ -432,17 +432,18 @@ func TestCaption_Update(t *testing.T) { WithLanguage("es"), }, verify: func(r *http.Request) { - if r.Method == "PUT" { + switch r.Method { + case "PUT": if r.URL.Query().Get("part") != "snippet" { t.Errorf("expected part=snippet, got %s", r.URL.Query().Get("part")) } - } else if r.Method == "GET" { + case "GET": if r.URL.Query().Get("videoId") != "video-id" { t.Errorf( "expected videoId=video-id, got %s", r.URL.Query().Get("videoId"), ) } - } else { + default: t.Errorf("unexpected method %s", r.Method) } }, diff --git a/pkg/channel/channel_test.go b/pkg/channel/channel_test.go index 90f2dbb..a08ac8d 100644 --- a/pkg/channel/channel_test.go +++ b/pkg/channel/channel_test.go @@ -431,15 +431,16 @@ func TestChannel_Update(t *testing.T) { WithMaxResults(1), }, verify: func(r *http.Request) { - if r.Method == "PUT" { + switch r.Method { + case "PUT": if r.URL.Query().Get("part") != "snippet" { t.Errorf("expected part=snippet, got %s", r.URL.Query().Get("part")) } - } else if r.Method == "GET" { + case "GET": if r.URL.Query().Get("id") != "channel-id" { t.Errorf("expected id=channel-id, got %s", r.URL.Query().Get("id")) } - } else { + default: t.Errorf("unexpected method %s", r.Method) } }, diff --git a/pkg/comment/comment_test.go b/pkg/comment/comment_test.go index 351bf8c..2a706a1 100644 --- a/pkg/comment/comment_test.go +++ b/pkg/comment/comment_test.go @@ -401,12 +401,13 @@ func TestComment_Update(t *testing.T) { WithMaxResults(1), }, verify: func(r *http.Request) { - if r.Method == "PUT" { + switch r.Method { + case "PUT": if r.URL.Query().Get("part") != "snippet" { t.Errorf("expected part=snippet, got %s", r.URL.Query().Get("part")) } - } else if r.Method == "GET" { - } else { + case "GET": + default: t.Errorf("unexpected method %s", r.Method) } }, @@ -423,10 +424,7 @@ func TestComment_Update(t *testing.T) { WithViewerRating("like"), WithMaxResults(1), }, - verify: func(r *http.Request) { - if r.Method == "PUT" { - } - }, + verify: func(_ *http.Request) {}, wantErr: false, }, } diff --git a/pkg/common/common_test.go b/pkg/common/common_test.go index 03a3507..62835e6 100644 --- a/pkg/common/common_test.go +++ b/pkg/common/common_test.go @@ -67,7 +67,8 @@ func TestPaginate(t *testing.T) { return func(w http.ResponseWriter, r *http.Request) { pageToken := r.URL.Query().Get("pageToken") w.Header().Set("Content-Type", "application/json") - if pageToken == "" { + switch pageToken { + case "": items := make([]string, 20) for i := range 20 { items[i] = fmt.Sprintf(`{"id": "v%d"}`, i+1) @@ -77,7 +78,7 @@ func TestPaginate(t *testing.T) { "items": %s, "nextPageToken": "page-2" }`, jsonItems) - } else if pageToken == "page-2" { + case "page-2": _, _ = w.Write([]byte(`{ "items": [{"id": "v21"}, {"id": "v22"}], "nextPageToken": "" @@ -333,8 +334,8 @@ func TestWithMaxResults(t *testing.T) { t.Run(tt.name, func(t *testing.T) { r := &testResource{} WithMaxResults[*testResource](tt.input)(r) - if r.Fields.MaxResults != tt.want { - t.Errorf("WithMaxResults(%d) = %d, want %d", tt.input, r.Fields.MaxResults, tt.want) + if r.MaxResults != tt.want { + t.Errorf("WithMaxResults(%d) = %d, want %d", tt.input, r.MaxResults, tt.want) } }) } @@ -344,10 +345,10 @@ func TestWithIds(t *testing.T) { r := &testResource{} ids := []string{"id1", "id2", "id3"} WithIds[*testResource](ids)(r) - if len(r.Fields.Ids) != len(ids) { - t.Fatalf("WithIds() got %d ids, want %d", len(r.Fields.Ids), len(ids)) + if len(r.Ids) != len(ids) { + t.Fatalf("WithIds() got %d ids, want %d", len(r.Ids), len(ids)) } - for i, id := range r.Fields.Ids { + for i, id := range r.Ids { if id != ids[i] { t.Errorf("WithIds()[%d] = %q, want %q", i, id, ids[i]) } @@ -358,10 +359,10 @@ func TestWithParts(t *testing.T) { r := &testResource{} parts := []string{"snippet", "contentDetails"} WithParts[*testResource](parts)(r) - if len(r.Fields.Parts) != len(parts) { - t.Fatalf("WithParts() got %d parts, want %d", len(r.Fields.Parts), len(parts)) + if len(r.Parts) != len(parts) { + t.Fatalf("WithParts() got %d parts, want %d", len(r.Parts), len(parts)) } - for i, p := range r.Fields.Parts { + for i, p := range r.Parts { if p != parts[i] { t.Errorf("WithParts()[%d] = %q, want %q", i, p, parts[i]) } @@ -371,8 +372,8 @@ func TestWithParts(t *testing.T) { func TestWithOutput(t *testing.T) { r := &testResource{} WithOutput[*testResource]("json")(r) - if r.Fields.Output != "json" { - t.Errorf("WithOutput() = %q, want %q", r.Fields.Output, "json") + if r.Output != "json" { + t.Errorf("WithOutput() = %q, want %q", r.Output, "json") } } @@ -380,7 +381,7 @@ func TestWithService(t *testing.T) { r := &testResource{} svc := &youtube.Service{} WithService[*testResource](svc)(r) - if r.Fields.Service != svc { + if r.Service != svc { t.Errorf("WithService() did not set service") } } @@ -388,23 +389,23 @@ func TestWithService(t *testing.T) { func TestWithHl(t *testing.T) { r := &testResource{} WithHl[*testResource]("en")(r) - if r.Fields.Hl != "en" { - t.Errorf("WithHl() = %q, want %q", r.Fields.Hl, "en") + if r.Hl != "en" { + t.Errorf("WithHl() = %q, want %q", r.Hl, "en") } } func TestWithChannelId(t *testing.T) { r := &testResource{} WithChannelId[*testResource]("chan-123")(r) - if r.Fields.ChannelId != "chan-123" { - t.Errorf("WithChannelId() = %q, want %q", r.Fields.ChannelId, "chan-123") + if r.ChannelId != "chan-123" { + t.Errorf("WithChannelId() = %q, want %q", r.ChannelId, "chan-123") } } func TestWithOnBehalfOfContentOwner(t *testing.T) { r := &testResource{} WithOnBehalfOfContentOwner[*testResource]("owner-456")(r) - if r.Fields.OnBehalfOfContentOwner != "owner-456" { - t.Errorf("WithOnBehalfOfContentOwner() = %q, want %q", r.Fields.OnBehalfOfContentOwner, "owner-456") + if r.OnBehalfOfContentOwner != "owner-456" { + t.Errorf("WithOnBehalfOfContentOwner() = %q, want %q", r.OnBehalfOfContentOwner, "owner-456") } } diff --git a/pkg/common/testutil.go b/pkg/common/testutil.go index d05594e..882b646 100644 --- a/pkg/common/testutil.go +++ b/pkg/common/testutil.go @@ -49,26 +49,22 @@ func PaginationHandler(idPrefix string, itemFmt ...func(string, int) string) htt return func(w http.ResponseWriter, r *http.Request) { pageToken := r.URL.Query().Get("pageToken") w.Header().Set("Content-Type", "application/json") - if pageToken == "" { + switch pageToken { + case "": items := make([]string, 20) for i := range 20 { items[i] = fmtItem(idPrefix, i) } - _, _ = w.Write( - fmt.Appendf( - nil, - `{"items": [%s], "nextPageToken": "page-2"}`, - strings.Join(items, ","), - ), + _, _ = fmt.Fprintf( + w, + `{"items": [%s], "nextPageToken": "page-2"}`, + strings.Join(items, ","), ) - } else if pageToken == "page-2" { - _, _ = w.Write( - []byte( - fmt.Sprintf( - `{"items": [%s, %s], "nextPageToken": ""}`, - fmtItem(idPrefix, 20), fmtItem(idPrefix, 21), - ), - ), + case "page-2": + _, _ = fmt.Fprintf( + w, + `{"items": [%s, %s], "nextPageToken": ""}`, + fmtItem(idPrefix, 20), fmtItem(idPrefix, 21), ) } } diff --git a/pkg/playlistImage/playlistImage_test.go b/pkg/playlistImage/playlistImage_test.go index 4f2d6d4..638165c 100644 --- a/pkg/playlistImage/playlistImage_test.go +++ b/pkg/playlistImage/playlistImage_test.go @@ -262,7 +262,8 @@ func TestPlaylistImage_Get_Pagination(t *testing.T) { } func TestPlaylistImage_List(t *testing.T) { - common.RunListTest(t, `{ + common.RunListTest( + t, `{ "items": [ { "id": "image-1", @@ -468,10 +469,7 @@ func TestPlaylistImage_Update(t *testing.T) { WithMaxResults(1), WithFile("test_image.jpg"), }, - verify: func(r *http.Request) { - if r.Method == "PUT" { - } - }, + verify: func(_ *http.Request) {}, wantErr: false, }, } diff --git a/pkg/playlistItem/playlistItem_test.go b/pkg/playlistItem/playlistItem_test.go index 0471c3f..08b774d 100644 --- a/pkg/playlistItem/playlistItem_test.go +++ b/pkg/playlistItem/playlistItem_test.go @@ -499,11 +499,7 @@ func TestPlaylistItem_Update(t *testing.T) { WithPrivacy("private"), WithMaxResults(1), }, - verify: func(r *http.Request) { - if r.Method == "PUT" { - if r.URL.Query().Get("id") != "" { - } - } + verify: func(_ *http.Request) { }, wantErr: false, },