Naming, layout and comments: descriptive full-word names, one item per line in wrapped calls and literals, and doc comments on exported names
Short and single-letter names in application code become full words (tests keep theirs). Wrapped calls, signatures and composite literals put one item per line, and one-line function bodies are expanded. Exported names and groups of constants get doc comments, and comments refer to the renamed identifiers.
This commit is contained in:
1 parent
043e307663
commit
465358609a
78 files changed
+2374
-1402
No files matched your search
@@ -55,7 +55,9 @@ func TestMigrateUpCreateThenStatus(t *testing.T) {
|
||||
latest := latestVersion(t)
|
||||
|
||||
out := mustRun(t, "migrate", "up", "--create")
|
||||
cmdtest.Contains(t, out,
|
||||
cmdtest.Contains(
|
||||
t,
|
||||
out,
|
||||
"applied 00001_create_opportunities_table.sql",
|
||||
fmt.Sprintf("Database migrated to version %d", latest),
|
||||
)
|
||||
@@ -64,7 +66,9 @@ func TestMigrateUpCreateThenStatus(t *testing.T) {
|
||||
}
|
||||
|
||||
out = mustRun(t, "migrate", "status")
|
||||
cmdtest.Contains(t, out,
|
||||
cmdtest.Contains(
|
||||
t,
|
||||
out,
|
||||
fmt.Sprintf("Database version %d of %d (up-to-date)", latest, latest),
|
||||
"00001_create_opportunities_table.sql",
|
||||
)
|
||||
@@ -87,8 +91,11 @@ func TestMigrateUpAsksBeforeCreating(t *testing.T) {
|
||||
|
||||
out, err := run(t, "n\n", "migrate", "up")
|
||||
cmdtest.ErrContains(t, err, "no database file")
|
||||
cmdtest.Contains(t, out,
|
||||
"Database file './test.db' does not exist. Would you like to create it?")
|
||||
cmdtest.Contains(
|
||||
t,
|
||||
out,
|
||||
"Database file './test.db' does not exist. Would you like to create it?",
|
||||
)
|
||||
if cmdtest.Exists("test.db") {
|
||||
t.Error("test.db was created after answering no")
|
||||
}
|
||||
@@ -110,8 +117,11 @@ func TestMigrateUpBySteps(t *testing.T) {
|
||||
cmdtest.Contains(t, out, "Database migrated to version 2")
|
||||
|
||||
out = mustRun(t, "migrate", "status")
|
||||
cmdtest.Contains(t, out,
|
||||
fmt.Sprintf("Database version 2 of %d (%d pending)", latest, latest-2))
|
||||
cmdtest.Contains(
|
||||
t,
|
||||
out,
|
||||
fmt.Sprintf("Database version 2 of %d (%d pending)", latest, latest-2),
|
||||
)
|
||||
}
|
||||
|
||||
func TestMigrateDown(t *testing.T) {
|
||||
@@ -130,8 +140,11 @@ func TestMigrateDown(t *testing.T) {
|
||||
_, err := run(t, "", args...)
|
||||
cmdtest.ErrContains(t, err, "pass the --yes flag")
|
||||
}
|
||||
cmdtest.Contains(t, mustRun(t, "migrate", "status"),
|
||||
fmt.Sprintf("Database version %d of %d", latest-1, latest))
|
||||
cmdtest.Contains(
|
||||
t,
|
||||
mustRun(t, "migrate", "status"),
|
||||
fmt.Sprintf("Database version %d of %d", latest-1, latest),
|
||||
)
|
||||
|
||||
out = mustRun(t, "migrate", "down", "--steps", "0", "--yes")
|
||||
cmdtest.Contains(t, out, "Database cleared")
|
||||
|
||||
Reference in new issue
Block a user