diff --git a/initialization/initialization_test.go b/initialization/initialization_test.go index 0b5690220..765742d27 100644 --- a/initialization/initialization_test.go +++ b/initialization/initialization_test.go @@ -119,8 +119,8 @@ func TestInitialize_Migrate_Metadata(t *testing.T) { // store in old metadata format f, err := os.Create(filepath.Join(opts.DataDir, MetadataFileName)) require.NoError(t, err) - defer f.Close() require.NoError(t, json.NewEncoder(f).Encode(old)) + require.NoError(t, f.Close()) // just creating a new initializer should update the metadata init, err = NewInitializer( diff --git a/initialization/migrate_metadata.go b/initialization/migrate_metadata.go index db6907952..4f789dffa 100644 --- a/initialization/migrate_metadata.go +++ b/initialization/migrate_metadata.go @@ -157,7 +157,7 @@ func migrateV0(dir string, logger *zap.Logger) (err error) { tmp, err := os.Create(fmt.Sprintf("%s.tmp", filename)) if err != nil { - return fmt.Errorf("create temporary file %s: %w", tmp.Name(), err) + return fmt.Errorf("create temporary file: %w", err) } defer tmp.Close() @@ -170,7 +170,7 @@ func migrateV0(dir string, logger *zap.Logger) (err error) { } if err := atomic.ReplaceFile(tmp.Name(), filename); err != nil { - return fmt.Errorf("save file from %s, %s: %w", tmp.Name(), filename, err) + return fmt.Errorf("atomic replace: %w", err) } return nil diff --git a/initialization/migrate_metadata_test.go b/initialization/migrate_metadata_test.go index 8d41d25e1..da284702f 100644 --- a/initialization/migrate_metadata_test.go +++ b/initialization/migrate_metadata_test.go @@ -99,8 +99,8 @@ func Test_Migrate_Adds_NonceValue(t *testing.T) { path := t.TempDir() f, err := os.Create(filepath.Join(path, MetadataFileName)) require.NoError(t, err) - defer f.Close() require.NoError(t, json.NewEncoder(f).Encode(old)) + require.NoError(t, f.Close()) log := zaptest.NewLogger(t) require.NoError(t, MigratePoST(path, log))