1
0
Fork 0

Update linter

This commit is contained in:
Ludovic Fernandez 2020-05-11 12:06:07 +02:00 committed by GitHub
parent f12c27aa7c
commit 328611c619
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
157 changed files with 489 additions and 508 deletions

View file

@ -24,7 +24,7 @@ const (
traefikTestAccessLogFile = "access.log"
)
// AccessLogSuite
// AccessLogSuite tests suite.
type AccessLogSuite struct{ BaseSuite }
type accessLogValue struct {
@ -562,7 +562,7 @@ func extractLines(c *check.C) []string {
func checkStatsForLogFile(c *check.C) {
err := try.Do(1*time.Second, func() error {
if _, errStat := os.Stat(traefikTestLogFile); errStat != nil {
return fmt.Errorf("could not get stats for log file: %s", errStat)
return fmt.Errorf("could not get stats for log file: %w", errStat)
}
return nil
})

View file

@ -20,7 +20,7 @@ import (
checker "github.com/vdemeester/shakers"
)
// ACME test suites (using libcompose)
// ACME test suites (using libcompose).
type AcmeSuite struct {
BaseSuite
pebbleIP string
@ -74,7 +74,7 @@ func setupPebbleRootCA() (*http.Transport, error) {
certPool := x509.NewCertPool()
if ok := certPool.AppendCertsFromPEM(customCAs); !ok {
return nil, fmt.Errorf("error creating x509 cert pool from %q: %v", path, err)
return nil, fmt.Errorf("error creating x509 cert pool from %q: %w", path, err)
}
return &http.Transport{
@ -394,7 +394,7 @@ func (s *AcmeSuite) TestTLSALPN01DomainsInSAN(c *check.C) {
s.retrieveAcmeCertificate(c, testCase)
}
// Test Let's encrypt down
// Test Let's encrypt down.
func (s *AcmeSuite) TestNoValidLetsEncryptServer(c *check.C) {
file := s.adaptFile(c, "fixtures/acme/acme_base.toml", templateModel{
Acme: map[string]static.CertificateResolver{
@ -417,7 +417,7 @@ func (s *AcmeSuite) TestNoValidLetsEncryptServer(c *check.C) {
c.Assert(err, checker.IsNil)
}
// Doing an HTTPS request and test the response certificate
// Doing an HTTPS request and test the response certificate.
func (s *AcmeSuite) retrieveAcmeCertificate(c *check.C, testCase acmeTestCase) {
if len(testCase.template.PortHTTP) == 0 {
testCase.template.PortHTTP = ":5002"

View file

@ -47,7 +47,7 @@ func (s *ConsulCatalogSuite) waitToElectConsulLeader() error {
leader, err := s.consulClient.Status().Leader()
if err != nil || len(leader) == 0 {
return fmt.Errorf("leader not found. %v", err)
return fmt.Errorf("leader not found. %w", err)
}
return nil

View file

@ -19,7 +19,7 @@ import (
checker "github.com/vdemeester/shakers"
)
// Consul test suites (using libcompose)
// Consul test suites (using libcompose).
type ConsulSuite struct {
BaseSuite
kvClient store.Store

View file

@ -18,7 +18,7 @@ const (
composeProject = "minimal"
)
// Docker test suites
// Docker tests suite.
type DockerComposeSuite struct {
BaseSuite
}

View file

@ -17,14 +17,14 @@ import (
checker "github.com/vdemeester/shakers"
)
// Images to have or pull before the build in order to make it work
// FIXME handle this offline but loading them before build
// Images to have or pull before the build in order to make it work.
// FIXME handle this offline but loading them before build.
var RequiredImages = map[string]string{
"swarm": "1.0.0",
"containous/whoami": "latest",
}
// Docker test suites
// Docker tests suite.
type DockerSuite struct {
BaseSuite
project *docker.Project

View file

@ -10,7 +10,7 @@ import (
checker "github.com/vdemeester/shakers"
)
// ErrorPagesSuite test suites (using libcompose)
// ErrorPagesSuite test suites (using libcompose).
type ErrorPagesSuite struct {
BaseSuite
ErrorPageIP string

View file

@ -19,7 +19,7 @@ import (
checker "github.com/vdemeester/shakers"
)
// etcd test suites (using libcompose)
// etcd test suites (using libcompose).
type EtcdSuite struct {
BaseSuite
kvClient store.Store

View file

@ -10,7 +10,7 @@ import (
checker "github.com/vdemeester/shakers"
)
// File test suites
// File tests suite.
type FileSuite struct{ BaseSuite }
func (s *FileSuite) SetUpSuite(c *check.C) {
@ -32,7 +32,7 @@ func (s *FileSuite) TestSimpleConfiguration(c *check.C) {
c.Assert(err, checker.IsNil)
}
// #56 regression test, make sure it does not fail
// #56 regression test, make sure it does not fail?
func (s *FileSuite) TestSimpleConfigurationNoPanic(c *check.C) {
cmd, display := s.traefikCmd(withConfigFile("fixtures/file/56-simple-panic.toml"))
defer display(c)

View file

@ -24,7 +24,7 @@ var LocalhostKey []byte
const randCharset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"
// GRPCSuite
// GRPCSuite tests suite.
type GRPCSuite struct{ BaseSuite }
type myserver struct {

View file

@ -10,7 +10,7 @@ import (
checker "github.com/vdemeester/shakers"
)
// Headers test suites
// Headers tests suite.
type HeadersSuite struct{ BaseSuite }
func (s *HeadersSuite) TestSimpleConfiguration(c *check.C) {

View file

@ -11,7 +11,7 @@ import (
checker "github.com/vdemeester/shakers"
)
// HealthCheck test suites (using libcompose)
// HealthCheck test suites (using libcompose).
type HealthCheckSuite struct {
BaseSuite
whoami1IP string
@ -206,7 +206,7 @@ func (s *HealthCheckSuite) TestPortOverload(c *check.C) {
c.Assert(err, checker.IsNil)
}
// Checks if all the loadbalancers created will correctly update the server status
// Checks if all the loadbalancers created will correctly update the server status.
func (s *HealthCheckSuite) TestMultipleRoutersOnSameService(c *check.C) {
file := s.adaptFile(c, "fixtures/healthcheck/multiple-routers-one-same-service.toml", struct {
Server1 string

View file

@ -18,7 +18,7 @@ import (
checker "github.com/vdemeester/shakers"
)
// HTTPSSuite
// HTTPSSuite tests suite.
type HTTPSSuite struct{ BaseSuite }
// TestWithSNIConfigHandshake involves a client sending a SNI hostname of
@ -441,7 +441,7 @@ func (s *HTTPSSuite) TestWithOverlappingDynamicCertificate(c *check.C) {
}
// TestWithClientCertificateAuthentication
// The client can send a certificate signed by a CA trusted by the server but it's optional
// The client can send a certificate signed by a CA trusted by the server but it's optional.
func (s *HTTPSSuite) TestWithClientCertificateAuthentication(c *check.C) {
file := s.adaptFile(c, "fixtures/https/clientca/https_1ca1config.toml", struct{}{})
defer os.Remove(file)
@ -499,7 +499,7 @@ func (s *HTTPSSuite) TestWithClientCertificateAuthentication(c *check.C) {
}
// TestWithClientCertificateAuthentication
// Use two CA:s and test that clients with client signed by either of them can connect
// Use two CA:s and test that clients with client signed by either of them can connect.
func (s *HTTPSSuite) TestWithClientCertificateAuthenticationMultipleCAs(c *check.C) {
server1 := httptest.NewServer(http.HandlerFunc(func(rw http.ResponseWriter, _ *http.Request) { _, _ = rw.Write([]byte("server1")) }))
server2 := httptest.NewServer(http.HandlerFunc(func(rw http.ResponseWriter, _ *http.Request) { _, _ = rw.Write([]byte("server2")) }))
@ -596,7 +596,7 @@ func (s *HTTPSSuite) TestWithClientCertificateAuthenticationMultipleCAs(c *check
}
// TestWithClientCertificateAuthentication
// Use two CA:s in two different files and test that clients with client signed by either of them can connect
// Use two CA:s in two different files and test that clients with client signed by either of them can connect.
func (s *HTTPSSuite) TestWithClientCertificateAuthenticationMultipleCAsMultipleFiles(c *check.C) {
server1 := httptest.NewServer(http.HandlerFunc(func(rw http.ResponseWriter, _ *http.Request) { _, _ = rw.Write([]byte("server1")) }))
server2 := httptest.NewServer(http.HandlerFunc(func(rw http.ResponseWriter, _ *http.Request) { _, _ = rw.Write([]byte("server2")) }))

View file

@ -24,7 +24,7 @@ import (
var updateExpected = flag.Bool("update_expected", false, "Update expected files in testdata")
// K8sSuite
// K8sSuite tests suite.
type K8sSuite struct{ BaseSuite }
func (s *K8sSuite) SetUpSuite(c *check.C) {
@ -128,7 +128,7 @@ func matchesConfig(wantConfig string, buf *bytes.Buffer) try.ResponseCondition {
return func(res *http.Response) error {
body, err := ioutil.ReadAll(res.Body)
if err != nil {
return fmt.Errorf("failed to read response body: %s", err)
return fmt.Errorf("failed to read response body: %w", err)
}
if err := res.Body.Close(); err != nil {

View file

@ -16,7 +16,7 @@ import (
checker "github.com/vdemeester/shakers"
)
// Log rotation integration test suite
// Log rotation integration test suite.
type LogRotationSuite struct{ BaseSuite }
func (s *LogRotationSuite) SetUpSuite(c *check.C) {

View file

@ -12,7 +12,7 @@ import (
checker "github.com/vdemeester/shakers"
)
// Marathon test suites (using libcompose)
// Marathon test suites (using libcompose).
type MarathonSuite15 struct {
BaseSuite
marathonURL string

View file

@ -17,7 +17,7 @@ const (
containerNameMarathon = "marathon"
)
// Marathon test suites (using libcompose)
// Marathon test suites (using libcompose).
type MarathonSuite struct {
BaseSuite
marathonURL string

View file

@ -19,7 +19,7 @@ import (
checker "github.com/vdemeester/shakers"
)
// Redis test suites (using libcompose)
// Redis test suites (using libcompose).
type RedisSuite struct {
BaseSuite
kvClient store.Store

View file

@ -20,7 +20,7 @@ import (
checker "github.com/vdemeester/shakers"
)
// SimpleSuite
// SimpleSuite tests suite.
type SimpleSuite struct{ BaseSuite }
func (s *SimpleSuite) TestInvalidConfigShouldFail(c *check.C) {

View file

@ -12,18 +12,16 @@ import (
)
// ResponseCondition is a retry condition function.
// It receives a response, and returns an error
// if the response failed the condition.
// It receives a response, and returns an error if the response failed the condition.
type ResponseCondition func(*http.Response) error
// BodyContains returns a retry condition function.
// The condition returns an error if the request body does not contain all the given
// strings.
// The condition returns an error if the request body does not contain all the given strings.
func BodyContains(values ...string) ResponseCondition {
return func(res *http.Response) error {
body, err := ioutil.ReadAll(res.Body)
if err != nil {
return fmt.Errorf("failed to read response body: %s", err)
return fmt.Errorf("failed to read response body: %w", err)
}
for _, value := range values {
@ -36,13 +34,12 @@ func BodyContains(values ...string) ResponseCondition {
}
// BodyNotContains returns a retry condition function.
// The condition returns an error if the request body contain one of the given
// strings.
// The condition returns an error if the request body contain one of the given strings.
func BodyNotContains(values ...string) ResponseCondition {
return func(res *http.Response) error {
body, err := ioutil.ReadAll(res.Body)
if err != nil {
return fmt.Errorf("failed to read response body: %s", err)
return fmt.Errorf("failed to read response body: %w", err)
}
for _, value := range values {
@ -55,13 +52,12 @@ func BodyNotContains(values ...string) ResponseCondition {
}
// BodyContainsOr returns a retry condition function.
// The condition returns an error if the request body does not contain one of the given
// strings.
// The condition returns an error if the request body does not contain one of the given strings.
func BodyContainsOr(values ...string) ResponseCondition {
return func(res *http.Response) error {
body, err := ioutil.ReadAll(res.Body)
if err != nil {
return fmt.Errorf("failed to read response body: %s", err)
return fmt.Errorf("failed to read response body: %w", err)
}
for _, value := range values {
@ -79,7 +75,7 @@ func HasBody() ResponseCondition {
return func(res *http.Response) error {
body, err := ioutil.ReadAll(res.Body)
if err != nil {
return fmt.Errorf("failed to read response body: %s", err)
return fmt.Errorf("failed to read response body: %w", err)
}
if len(body) == 0 {
@ -182,11 +178,11 @@ func HasHeaderStruct(header http.Header) ResponseCondition {
}
// DoCondition is a retry condition function.
// It returns an error
// It returns an error.
type DoCondition func() error
// KVExists is a retry condition function.
// Verify if a Key exists in the store
// Verify if a Key exists in the store.
func KVExists(kv store.Store, key string) DoCondition {
return func() error {
_, err := kv.Exists(key, nil)

View file

@ -115,7 +115,7 @@ func Do(timeout time.Duration, operation DoCondition) error {
select {
case <-stopTimer.C:
fmt.Println("-")
return fmt.Errorf("try operation failed: %s", err)
return fmt.Errorf("try operation failed: %w", err)
case <-retryTick.C:
fmt.Print("*")
if err = operation(); err == nil {

View file

@ -18,7 +18,7 @@ import (
"golang.org/x/net/websocket"
)
// WebsocketSuite
// WebsocketSuite tests suite.
type WebsocketSuite struct{ BaseSuite }
func (s *WebsocketSuite) TestBase(c *check.C) {

View file

@ -19,7 +19,7 @@ import (
checker "github.com/vdemeester/shakers"
)
// Zk test suites (using libcompose)
// Zk test suites (using libcompose).
type ZookeeperSuite struct {
BaseSuite
kvClient store.Store