Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions internal/log/formatter.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,11 @@ func (f *Formatter) Format(entry *logrus.Entry) ([]byte, error) {

func trimFilename(s string) string {
const sub = "pg_timetable/internal/"
idx := strings.Index(s, sub)
if idx == -1 {
_, after, ok := strings.Cut(s, sub)
if !ok {
return s
}
return s[idx+len(sub):]
return after
}

func (f *Formatter) writeCaller(b *bytes.Buffer, entry *logrus.Entry) {
Expand Down
2 changes: 1 addition & 1 deletion internal/pgengine/access_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func TestSelectChains(t *testing.T) {
pge := pgengine.NewDB(mockPool, "pgengine_unit_test")
defer mockPool.Close()

for i := 0; i < 3; i++ {
for range 3 {
mockPool.ExpectQuery("SELECT.+chain_id").WithArgs(pgxmock.AnyArg()).WillReturnError(errors.New("error"))
mockPool.ExpectQuery("SELECT.+chain_id").WithArgs(pgxmock.AnyArg()).WillReturnRows(pgxmock.NewRows([]string{"foo"}).AddRow("baz"))
}
Expand Down
2 changes: 1 addition & 1 deletion internal/pgengine/bootstrap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func TestExecuteSchemaScripts(t *testing.T) {
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
mockPool.ExpectQuery("SELECT EXISTS").WillReturnRows(pgxmock.NewRows([]string{"exists"}).AddRow(false))
for i := 0; i < 5; i++ {
for range 5 {
mockPool.ExpectExec(".*").WillReturnResult(pgxmock.NewResult("EXECUTE", 1))
}
assert.NoError(t, mockpge.ExecuteSchemaScripts(ctx))
Expand Down
3 changes: 1 addition & 2 deletions internal/pgengine/log_hook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,7 @@ func TestCancelledContext(t *testing.T) {
}

func TestFireError(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
ctx := t.Context()
h := NewHook(ctx, &PgEngine{}, "debug")
err := errors.New("fire error")
go func() { h.lastError <- err }()
Expand Down
4 changes: 2 additions & 2 deletions internal/scheduler/shell_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ type testCommander struct{}
// overwrite CombinedOutput function of os/exec so only parameter syntax and return codes are checked...
func (c testCommander) CombinedOutput(_ context.Context, command string, args ...string) ([]byte, error) {
if strings.HasPrefix(command, "ping") {
return []byte(fmt.Sprint(command, args)), nil
return fmt.Append(nil, command, args), nil
}
return []byte(fmt.Sprintf("Command %s not found", command)), &exec.Error{Name: command, Err: exec.ErrNotFound}
return fmt.Appendf(nil, "Command %s not found", command), &exec.Error{Name: command, Err: exec.ErrNotFound}
}

func TestShellCommandDuration(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion internal/tasks/files_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ var ts = httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http
}
w.Header().Set("Content-Disposition", fmt.Sprintf("attachment;filename=\"%s\"", "test.txt"))
bw := bufio.NewWriterSize(w, 4096)
for i := 0; i < 4096; i++ {
for i := range 4096 {
_, _ = bw.Write([]byte{byte(i)})
}
_ = bw.Flush()
Expand Down
Loading