Skip to content

Commit 3fe3bee

Browse files
pierresouchayaiharos
authored andcommitted
BUILD Enforce go vet to check for format/issues in build
This also showed that require dependency was almost not needed, replaced it with require which was used elsewhere. travis will now call make travis that will check: - formatting is correct - go vet is called - no differences with git
1 parent 49db67a commit 3fe3bee

File tree

6 files changed

+16
-11
lines changed

6 files changed

+16
-11
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ before_script:
1010
- sudo wget https://github.com/haproxytech/dataplaneapi/releases/download/v1.2.5/dataplaneapi -O /usr/local/bin/dataplaneapi
1111
- sudo chmod +x /usr/local/bin/dataplaneapi
1212
- haproxy -vv
13+
script: make travis
1314
addons:
1415
apt:
1516
update: true

GNUmakefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,8 @@ bin: $(BIN)
1010

1111
test:
1212
go test -v -timeout 30s ${gobuild_args} ./...
13+
check:
14+
go fmt ./...
15+
go vet ./...
16+
git diff --exit-code
17+
travis: check bin test

go.sum

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ github.com/bgentry/speakeasy v0.1.0 h1:ByYyxL9InA1OWqxJqqp2A5pYHUrCiAL6K3J+LKSsQ
5050
github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs=
5151
github.com/bitly/go-hostpool v0.0.0-20171023180738-a3a6125de932 h1:mXoPYz/Ul5HYEDvkta6I8/rnYM5gSdSV2tJ6XbZuEtY=
5252
github.com/bitly/go-hostpool v0.0.0-20171023180738-a3a6125de932/go.mod h1:NOuUCSz6Q9T7+igc/hlvDOUdtWKryOrtFyIVABv/p7k=
53-
github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869 h1:DDGfHa7BWjL4YnC6+E63dPcxHo2sUxDIu8g3QgEJdRY=
5453
github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869/go.mod h1:Ekp36dRnpXw/yCqJaO+ZrUyxD+3VXMFFr56k5XYrpB4=
5554
github.com/boltdb/bolt v1.3.1 h1:JQmyP4ZBrce+ZQu0dY660FMfatumYDLun9hBCUVIkF4=
5655
github.com/boltdb/bolt v1.3.1/go.mod h1:clJnj/oiGkjum5o1McbSZDSLxVThjynRyGBgiAx27Ps=

haproxy/halog/log_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import (
44
"fmt"
55
"testing"
66

7-
"github.com/bmizerany/assert"
87
"github.com/sirupsen/logrus"
8+
"github.com/stretchr/testify/require"
99
)
1010

1111
type fakeHook struct {
@@ -30,7 +30,7 @@ func (h *fakeHook) Fire(e *logrus.Entry) error {
3030

3131
func ensureLogIsPresent(t *testing.T, hook *fakeHook, expectedLevel logrus.Level, prefix, msg string) {
3232
haproxyLog("haproxy", fmt.Sprintf("%s%s", prefix, msg))
33-
assert.Equal(t, fmt.Sprintf("haproxy: %s", msg), hook.lastMessage[expectedLevel])
33+
require.Equal(t, fmt.Sprintf("haproxy: %s", msg), hook.lastMessage[expectedLevel])
3434
}
3535

3636
func Test_log(t *testing.T) {

haproxy/haproxy_cmd/cmd_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,22 @@ import (
44
"testing"
55

66
"github.com/haproxytech/haproxy-consul-connect/lib"
7-
"github.com/stretchr/testify/assert"
7+
"github.com/stretchr/testify/require"
88
)
99

1010
func Test_runCommand_ok(t *testing.T) {
1111
t.Parallel()
1212
sd := lib.NewShutdown()
1313
cmd, err := runCommand(sd, "ls", ".")
14-
assert.NoError(t, err)
14+
require.NoError(t, err)
1515
cmd.Wait()
1616
}
1717

1818
func Test_runCommand_nok_wrong_path(t *testing.T) {
1919
t.Parallel()
2020
sd := lib.NewShutdown()
2121
cmd, err := runCommand(sd, "/path/to/nowhere/that/can/be/found/myExec", "--help")
22-
assert.NotNil(t, err)
23-
assert.Contains(t, err.Error(), "no such file or directory")
24-
assert.Nil(t, cmd)
22+
require.NotNil(t, err)
23+
require.Contains(t, err.Error(), "no such file or directory")
24+
require.Nil(t, cmd)
2525
}

lib/shutdown_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"testing"
55
"time"
66

7-
"github.com/stretchr/testify/assert"
7+
"github.com/stretchr/testify/require"
88
)
99

1010
func Test_Shutdown(t *testing.T) {
@@ -17,7 +17,7 @@ func Test_Shutdown(t *testing.T) {
1717
sd.Done()
1818
}()
1919
sd.Wait()
20-
assert.GreaterOrEqual(t, time.Since(start).Milliseconds(), expectedDuration.Milliseconds())
20+
require.GreaterOrEqual(t, time.Since(start).Milliseconds(), expectedDuration.Milliseconds())
2121

2222
// Shutting down
2323
start = time.Now()
@@ -26,6 +26,6 @@ func Test_Shutdown(t *testing.T) {
2626
sd.Shutdown("Kill waiting tasks")
2727
}()
2828
<-sd.Stop
29-
assert.GreaterOrEqual(t, time.Since(start).Milliseconds(), expectedDuration.Milliseconds())
29+
require.GreaterOrEqual(t, time.Since(start).Milliseconds(), expectedDuration.Milliseconds())
3030

3131
}

0 commit comments

Comments
 (0)