Skip to content

Commit

Permalink
fix lint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
sgerhardt committed Jul 19, 2024
1 parent 07f605d commit e09deb4
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion cmd/chatter/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 == "" {
Expand Down
6 changes: 3 additions & 3 deletions internal/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand All @@ -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,
Expand Down
5 changes: 4 additions & 1 deletion internal/client/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import (
)

func TestClient_GenerateVoiceFromText(t *testing.T) {
t.Parallel()

type fields struct {
apiKey string
outputFilePath string
Expand All @@ -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",
Expand Down Expand Up @@ -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{
Expand Down
2 changes: 1 addition & 1 deletion internal/client/web.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
2 changes: 2 additions & 0 deletions internal/client/web_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
)

func TestWebReader(t *testing.T) {
t.Parallel()

tests := []struct {
name string
Expand Down Expand Up @@ -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{
Expand Down

0 comments on commit e09deb4

Please sign in to comment.