-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Expand file tree
/
Copy pathserialize_test.go
More file actions
37 lines (32 loc) · 775 Bytes
/
serialize_test.go
File metadata and controls
37 lines (32 loc) · 775 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package serialize
import (
"os"
"runtime"
"testing"
config "github.com/ipfs/kubo/config"
)
func TestConfig(t *testing.T) {
const filename = ".ipfsconfig"
cfgWritten := new(config.Config)
cfgWritten.Identity.PeerID = "faketest"
err := WriteConfigFile(filename, cfgWritten)
if err != nil {
t.Fatal(err)
}
cfgRead, err := Load(filename)
if err != nil {
t.Fatal(err)
}
if cfgWritten.Identity.PeerID != cfgRead.Identity.PeerID {
t.Fatal()
}
st, err := os.Stat(filename)
if err != nil {
t.Fatalf("cannot stat config file: %v", err)
}
if runtime.GOOS != "windows" { // see https://golang.org/src/os/types_windows.go
if g := st.Mode().Perm(); g&0o117 != 0 {
t.Fatalf("config file should not be executable or accessible to world: %v", g)
}
}
}