Skip to content

Commit 057feca

Browse files
committed
test(mnq): simplify config copy using ReadFile/WriteFile
1 parent c99445b commit 057feca

File tree

1 file changed

+2
-14
lines changed

1 file changed

+2
-14
lines changed

internal/namespaces/mnq/v1beta1/custom_nats_test.go

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package mnq_test
22

33
import (
4-
"io"
54
"os"
65
"path/filepath"
76
"reflect"
@@ -127,23 +126,12 @@ func beforeFuncCopyConfigToTmpHome() core.BeforeFunc {
127126
return err
128127
}
129128

130-
tmpConfigPath := filepath.Join(tmpConfigDir, "config.yaml")
131-
132-
src, err := os.Open(realConfigPath)
133-
if err != nil {
134-
return err
135-
}
136-
defer src.Close()
137-
138-
dst, err := os.Create(tmpConfigPath)
129+
data, err := os.ReadFile(realConfigPath)
139130
if err != nil {
140131
return err
141132
}
142-
defer dst.Close()
143-
144-
_, err = io.Copy(dst, src)
145133

146-
return err
134+
return os.WriteFile(filepath.Join(tmpConfigDir, "config.yaml"), data, 0o644)
147135
})
148136
}
149137

0 commit comments

Comments
 (0)