Skip to content

Commit

Permalink
More fixes for windows
Browse files Browse the repository at this point in the history
  • Loading branch information
fasmat committed Sep 20, 2023
1 parent 8f0e366 commit dde5915
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion initialization/initialization_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
4 changes: 2 additions & 2 deletions initialization/migrate_metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Check warning on line 161 in initialization/migrate_metadata.go

View check run for this annotation

Codecov / codecov/patch

initialization/migrate_metadata.go#L160-L161

Added lines #L160 - L161 were not covered by tests
defer tmp.Close()

Expand All @@ -170,7 +170,7 @@ func migrateV0(dir string, logger *zap.Logger) (err error) {
}

Check warning on line 170 in initialization/migrate_metadata.go

View check run for this annotation

Codecov / codecov/patch

initialization/migrate_metadata.go#L169-L170

Added lines #L169 - L170 were not covered by tests

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)
}

Check warning on line 174 in initialization/migrate_metadata.go

View check run for this annotation

Codecov / codecov/patch

initialization/migrate_metadata.go#L173-L174

Added lines #L173 - L174 were not covered by tests

return nil
Expand Down
2 changes: 1 addition & 1 deletion initialization/migrate_metadata_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit dde5915

Please sign in to comment.