Skip to content

Commit

Permalink
lint: Fix errcheck
Browse files Browse the repository at this point in the history
  • Loading branch information
sue445 committed Jul 13, 2024
1 parent cd01573 commit 9aa6fc5
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 11 deletions.
2 changes: 1 addition & 1 deletion adapter/mysql/adapter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func withDatabase(callback func(*Adapter)) {
panic(err)
}

defer close()
defer close() //nolint:errcheck

adapter.db.MustExec("DROP TABLE IF EXISTS followers;")
adapter.db.MustExec("DROP TABLE IF EXISTS articles;")
Expand Down
2 changes: 1 addition & 1 deletion adapter/oracle/adapter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func withDatabase(callback func(*Adapter)) {
panic(err)
}

defer close()
defer close() //nolint:errcheck

// adapter.db.MustExec("DROP TABLE followers")
// adapter.db.MustExec("DROP TABLE articles")
Expand Down
2 changes: 1 addition & 1 deletion adapter/postgresql/adapter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func withDatabase(callback func(*Adapter)) {
panic(err)
}

defer close()
defer close() //nolint:errcheck

adapter.db.MustExec("DROP TABLE IF EXISTS followers;")
adapter.db.MustExec("DROP TABLE IF EXISTS articles;")
Expand Down
2 changes: 1 addition & 1 deletion adapter/sqlite3/adapter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ func withDatabase(callback func(*Adapter)) {
panic(err)
}

defer close()
defer close() //nolint:errcheck

adapter.DB.MustExec("PRAGMA foreign_keys = ON;")

Expand Down
2 changes: 1 addition & 1 deletion cmd/plant_erd-oracle/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func main() {
return errors.WithStack(err)
}

return generator.Run(schema)
return generator.Run(schema) //nolint:errcheck
}

sort.Sort(cli.CommandsByName(app.Commands))
Expand Down
6 changes: 3 additions & 3 deletions cmd/plant_erd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func main() {
return errors.WithStack(err)
}

return generator.Run(schema)
return generator.Run(schema) //nolint:errcheck
},
},
{
Expand Down Expand Up @@ -135,7 +135,7 @@ func main() {
return errors.WithStack(err)
}

return generator.Run(schema)
return generator.Run(schema) //nolint:errcheck
},
},
{
Expand Down Expand Up @@ -199,7 +199,7 @@ func main() {
return errors.WithStack(err)
}

return generator.Run(schema)
return generator.Run(schema) //nolint:errcheck
},
},
}
Expand Down
14 changes: 11 additions & 3 deletions lib/erd_generator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package lib

import (
"bytes"
"github.com/stretchr/testify/require"
"io"
"os"
"path/filepath"
Expand Down Expand Up @@ -214,7 +215,8 @@ func TestErdGenerator_output_ToFile(t *testing.T) {
Filepath: filePath,
}

g.output("aaa")
err := g.output("aaa")
require.NoError(t, err)

data, err := os.ReadFile(filePath)

Expand All @@ -237,10 +239,16 @@ func captureStdout(f func()) string {
f()

os.Stdout = stdout
w.Close()
err = w.Close()
if err != nil {
panic(err)
}

var buf bytes.Buffer
io.Copy(&buf, r)
_, err = io.Copy(&buf, r)
if err != nil {
panic(err)
}

return buf.String()
}
Expand Down

0 comments on commit 9aa6fc5

Please sign in to comment.