Skip to content

Commit

Permalink
Fix linting errors
Browse files Browse the repository at this point in the history
  • Loading branch information
bojand committed Jul 25, 2019
1 parent 4b73c55 commit 571e42f
Show file tree
Hide file tree
Showing 12 changed files with 21 additions and 31 deletions.
2 changes: 1 addition & 1 deletion printer/printer.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ func jsonify(v interface{}, pretty bool) string {
return string(d)
}

return string(out.Bytes())
return out.String()
}

func formatNanoUnit(d time.Duration) string {
Expand Down
2 changes: 1 addition & 1 deletion runner/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ func createClientTransportCredentials(skipVerify bool, cacertFile, clientCertFil
tlsConf.Certificates = []tls.Certificate{certificate}
}

if skipVerify == true {
if skipVerify {
tlsConf.InsecureSkipVerify = true
} else if cacertFile != "" {
// Create a certificate pool from the certificate authority
Expand Down
2 changes: 1 addition & 1 deletion runner/requester.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ func (b *Requester) Stop(reason StopReason) {
// Finish finishes the test run
func (b *Requester) Finish() *Report {
close(b.results)
total := time.Now().Sub(b.start)
total := time.Since(b.start)

// Wait until the reporter is done.
<-b.reporter.done
Expand Down
3 changes: 3 additions & 0 deletions runner/run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ func TestRunUnary(t *testing.T) {
msg.Name = "bob"

binData, err := proto.Marshal(msg)
assert.NoError(t, err)

report, err := Run(
"helloworld.Greeter.SayHello",
Expand Down Expand Up @@ -226,6 +227,7 @@ func TestRunUnary(t *testing.T) {
msg.Name = "bob"

binData, err := proto.Marshal(msg)
assert.NoError(t, err)

report, err := Run(
"helloworld.Greeter.SayHello",
Expand Down Expand Up @@ -534,6 +536,7 @@ func TestRunClientStreamingBinary(t *testing.T) {
msg.Name = "bob"

binData, err := proto.Marshal(msg)
assert.NoError(t, err)

report, err := Run(
"helloworld.Greeter.SayHelloCS",
Expand Down
2 changes: 1 addition & 1 deletion runner/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ func (w *Worker) makeServerStreamingRequest(ctx *context.Context, input *dynamic
str, err := w.stub.InvokeRpcServerStream(*ctx, w.mtd, input)
// TODO: need to handle and propagate errors
for err == nil {
_, err := str.RecvMsg()
_, err = str.RecvMsg()
if err != nil {
if err == io.EOF {
err = nil
Expand Down
1 change: 1 addition & 0 deletions web/database/database_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ func TestWithAlreadyExistingSqliteFolder(t *testing.T) {
assert.NoError(t, err)

err = os.MkdirAll("test/somepath", 0777)
assert.NoError(t, err)

db, err := New("sqlite3", "test/somepath/testdb.db", false)
assert.Nil(t, err)
Expand Down
2 changes: 0 additions & 2 deletions web/database/detail.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,10 @@ func (d *Database) CreateDetailsBatch(rid uint, s []*model.Detail) (uint, uint)
NC := 10

var nErr uint32
nErr = 0

sem := make(chan bool, NC)

var nCreated, errCount uint
errCount = 0

for _, item := range s {
sem <- true
Expand Down
2 changes: 1 addition & 1 deletion web/database/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func (d *Database) ListProjects(limit, page uint, sortField, order string) ([]*m
}

offset := uint(0)
if page >= 0 && limit >= 0 {
if page > 0 && limit > 0 {
offset = page * limit
}

Expand Down
2 changes: 1 addition & 1 deletion web/database/report.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func (d *Database) listReports(byProject bool, pid, limit, page uint, sortField,
}

offset := uint(0)
if page >= 0 && limit >= 0 {
if page > 0 && limit > 0 {
offset = page * limit
}

Expand Down
27 changes: 9 additions & 18 deletions web/database/report_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,8 +242,7 @@ func TestDatabase_Report(t *testing.T) {
})

t.Run("FindReportByID", func(t *testing.T) {
r := new(model.Report)
r, err = db.FindReportByID(rid)
r, err := db.FindReportByID(rid)

assert.NoError(t, err)
assert.NotNil(t, r)
Expand Down Expand Up @@ -278,8 +277,7 @@ func TestDatabase_Report(t *testing.T) {
})

t.Run("FindReportByID 2", func(t *testing.T) {
r := new(model.Report)
r, err = db.FindReportByID(rid2)
r, err := db.FindReportByID(rid2)

assert.NoError(t, err)
assert.NotNil(t, r)
Expand Down Expand Up @@ -314,8 +312,7 @@ func TestDatabase_Report(t *testing.T) {
})

t.Run("FindReportByID 3", func(t *testing.T) {
r := new(model.Report)
r, err = db.FindReportByID(rid3)
r, err := db.FindReportByID(rid3)

assert.NoError(t, err)
assert.NotNil(t, r)
Expand Down Expand Up @@ -350,33 +347,29 @@ func TestDatabase_Report(t *testing.T) {
})

t.Run("FindReportByID missing", func(t *testing.T) {
r := new(model.Report)
r, err = db.FindReportByID(123432)
r, err := db.FindReportByID(123432)

assert.Error(t, err)
assert.Nil(t, r)
})

t.Run("FindPreviousReport", func(t *testing.T) {
r := new(model.Report)
r, err = db.FindPreviousReport(rid3)
r, err := db.FindPreviousReport(rid3)

assert.NoError(t, err)
assert.NotNil(t, r)
assert.Equal(t, rid2, r.ID)
})

t.Run("FindPreviousReport invalid id", func(t *testing.T) {
r := new(model.Report)
r, err = db.FindPreviousReport(12345)
r, err := db.FindPreviousReport(12345)

assert.Error(t, err)
assert.Nil(t, r)
})

t.Run("FindPreviousReport no previous", func(t *testing.T) {
r := new(model.Report)
r, err = db.FindPreviousReport(rid)
r, err := db.FindPreviousReport(rid)

assert.Error(t, err)
assert.Nil(t, r)
Expand Down Expand Up @@ -495,17 +488,15 @@ func TestDatabase_Report(t *testing.T) {
})

t.Run("FindLatestReportForProject", func(t *testing.T) {
r := new(model.Report)
r, err = db.FindLatestReportForProject(pid2)
r, err := db.FindLatestReportForProject(pid2)

assert.NoError(t, err)
assert.NotNil(t, r)
assert.Equal(t, rid3, r.ID)
})

t.Run("FindLatestReportForProject invalid id", func(t *testing.T) {
r := new(model.Report)
r, err = db.FindLatestReportForProject(12345)
r, err := db.FindLatestReportForProject(12345)

assert.NoError(t, err)
assert.Nil(t, r)
Expand Down
2 changes: 1 addition & 1 deletion web/model/detail.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ type Detail struct {
runner.ResultDetail
}

const layoutISO string = "2006-01-02T15:04:05.666Z"
const layoutISO string = "2006-01-02T15:04:05.000Z"
const layoutISO2 string = "2006-01-02T15:04:05-0700"

// UnmarshalJSON for Detail
Expand Down
5 changes: 1 addition & 4 deletions web/router/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,7 @@ func New(db *database.Database, appInfo *api.ApplicationInfo, conf *config.Confi
s.Pre(middleware.AddTrailingSlashWithConfig(middleware.TrailingSlashConfig{
Skipper: func(ctx echo.Context) bool {
path := ctx.Request().URL.Path
if strings.Contains(path, "/api") {
return false
}
return true
return !strings.Contains(path, "/api")
},
}))

Expand Down

0 comments on commit 571e42f

Please sign in to comment.