From e09deb4b4e919c263be23b90cce739d2481da890 Mon Sep 17 00:00:00 2001 From: sgerhardt Date: Fri, 19 Jul 2024 09:11:09 -0500 Subject: [PATCH] fix lint issues --- cmd/chatter/main.go | 2 +- internal/client/client.go | 6 +++--- internal/client/client_test.go | 5 ++++- internal/client/web.go | 2 +- internal/client/web_test.go | 2 ++ 5 files changed, 11 insertions(+), 6 deletions(-) diff --git a/cmd/chatter/main.go b/cmd/chatter/main.go index 7966079..1a8e892 100644 --- a/cmd/chatter/main.go +++ b/cmd/chatter/main.go @@ -30,7 +30,7 @@ func run() { client.New(app, httpClient).Run() } -func setup() (config.AppConfig, client.Http) { +func setup() (config.AppConfig, client.HTTP) { var app config.AppConfig key, dir := readEnvFile() if key == "" { diff --git a/internal/client/client.go b/internal/client/client.go index 53e9471..8b55fcc 100644 --- a/internal/client/client.go +++ b/internal/client/client.go @@ -39,11 +39,11 @@ type PronunciationDictionaryLocators struct { } type ElevenLabs struct { - httpClient Http + httpClient HTTP Config config.AppConfig } -type Http interface { +type HTTP interface { Do(req *http.Request) (*http.Response, error) } @@ -68,7 +68,7 @@ func (c *ElevenLabs) Write(data []byte) (int, error) { return len(data), nil } -func New(cfg config.AppConfig, httpClient Http) *ElevenLabs { +func New(cfg config.AppConfig, httpClient HTTP) *ElevenLabs { return &ElevenLabs{ Config: cfg, httpClient: httpClient, diff --git a/internal/client/client_test.go b/internal/client/client_test.go index 7f18fa1..5d0999a 100644 --- a/internal/client/client_test.go +++ b/internal/client/client_test.go @@ -14,6 +14,8 @@ import ( ) func TestClient_GenerateVoiceFromText(t *testing.T) { + t.Parallel() + type fields struct { apiKey string outputFilePath string @@ -37,7 +39,7 @@ func TestClient_GenerateVoiceFromText(t *testing.T) { voiceID: "", }, error: errors.New("voice ID is required"), - mockSetup: func(client *mocks.Http) {}, + mockSetup: func(_ *mocks.Http) {}, }, { name: "marshals a payload to json", @@ -69,6 +71,7 @@ func TestClient_GenerateVoiceFromText(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { + t.Parallel() mockClient := mocks.NewHttp(t) tt.mockSetup(mockClient) cfg := config.AppConfig{ diff --git a/internal/client/web.go b/internal/client/web.go index 549e0d1..84dd606 100644 --- a/internal/client/web.go +++ b/internal/client/web.go @@ -49,7 +49,7 @@ func extractTextFromHTML(r io.Reader) (string, error) { var sb strings.Builder // Select relevant tags and extract text count := 0 - doc.Find("title, h1, h2, h3, h4, h5, h6, p").Each(func(i int, s *goquery.Selection) { + doc.Find("title, h1, h2, h3, h4, h5, h6, p").Each(func(_ int, s *goquery.Selection) { count += utf8.RuneCountInString(s.Text()) sb.WriteString(s.Text()) sb.WriteString("\n") diff --git a/internal/client/web_test.go b/internal/client/web_test.go index c3ef770..13f7a31 100644 --- a/internal/client/web_test.go +++ b/internal/client/web_test.go @@ -12,6 +12,7 @@ import ( ) func TestWebReader(t *testing.T) { + t.Parallel() tests := []struct { name string @@ -46,6 +47,7 @@ func TestWebReader(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { + t.Parallel() mockClient := mocks.NewHttp(t) tt.mockSetup(mockClient) appConfig := config.AppConfig{