Skip to content

Commit

Permalink
Fix tests and linter
Browse files Browse the repository at this point in the history
  • Loading branch information
michel-laterman committed Jan 30, 2023
1 parent 21c811e commit babe889
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions internal/pkg/agent/cmd/enroll_cmd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import (
"bytes"
"context"
"crypto/tls"
"errors"
"fmt"
"io"
"io/ioutil"
"net"
Expand All @@ -18,7 +20,6 @@ import (
"strconv"
"testing"

"github.com/pkg/errors"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

Expand All @@ -43,7 +44,7 @@ func (m *mockStore) Save(in io.Reader) error {
}

buf := new(bytes.Buffer)
io.Copy(buf, in) // nolint:errcheck //not required
io.Copy(buf, in) //nolint:errcheck // not required
m.Content = buf.Bytes()
return nil
}
Expand Down Expand Up @@ -397,7 +398,6 @@ func TestPrepareFleetTLS(t *testing.T) {

assert.True(t, cmd.options.Insecure)
assert.Equal(t, "http://localhost:8220", cmd.options.URL)
assert.Equal(t, "localhost:8221", cmd.options.InternalURL)

assert.Equal(t, "", cmd.options.FleetServer.Host)
})
Expand All @@ -422,9 +422,10 @@ func TestPrepareFleetTLS(t *testing.T) {
assert.False(t, cmd.options.Insecure)
assert.NotEmpty(t, cmd.options.FleetServer.Cert)
assert.NotEmpty(t, cmd.options.FleetServer.CertKey)
assert.Equal(t, "https://localhost:8220", cmd.options.URL)
assert.NotEmpty(t, cmd.options.CAs)
assert.Equal(t, "localhost:8221", cmd.options.InternalURL)

hostname, _ := os.Hostname()
assert.Equal(t, fmt.Sprintf("https://%s:8221", hostname), cmd.options.URL)

assert.Equal(t, "", cmd.options.FleetServer.Host)
})
Expand Down Expand Up @@ -460,7 +461,7 @@ func withTLSServer(

port := listener.Addr().(*net.TCPAddr).Port

s := http.Server{
s := http.Server{ //nolint:gosec // test server config
Handler: m(t),
TLSConfig: &tls.Config{
Certificates: []tls.Certificate{serverCert},
Expand All @@ -469,7 +470,7 @@ func withTLSServer(
}

// Uses the X509KeyPair pair defined in the TLSConfig struct instead of file on disk.
go s.ServeTLS(listener, "", "") // nolint:errcheck //not required
go s.ServeTLS(listener, "", "") //nolint:errcheck // not required

test(t, ca.Crt(), "localhost:"+strconv.Itoa(port))
}
Expand All @@ -480,7 +481,7 @@ func bytesToTMPFile(b []byte) (string, error) {
if err != nil {
return "", err
}
f.Write(b) // nolint:errcheck //not required
f.Write(b) //nolint:errcheck // not required
if err := f.Close(); err != nil {
return "", err
}
Expand Down

0 comments on commit babe889

Please sign in to comment.