Initial release of bdrclone

This commit is contained in:
2026-08-13 23:02:25 +08:00
commit d6d1956050
23 changed files with 3042 additions and 0 deletions

View File

@@ -0,0 +1,32 @@
package config
import (
"os"
"path/filepath"
"runtime"
"testing"
)
func TestSaveLoadSecureConfig(t *testing.T) {
path := filepath.Join(t.TempDir(), "nested", "config.json")
cfg := &Config{ClientID: "id", ClientSecret: "secret"}
if err := Save(path, cfg); err != nil {
t.Fatal(err)
}
loaded, err := Load(path)
if err != nil {
t.Fatal(err)
}
if loaded.Root != "/" || loaded.UserAgent != DefaultUserAgent || loaded.UploadParts != 3 {
t.Fatalf("defaults not applied: %+v", loaded)
}
if runtime.GOOS != "windows" {
info, err := os.Stat(path)
if err != nil {
t.Fatal(err)
}
if info.Mode().Perm() != 0o600 {
t.Fatalf("config permissions = %o", info.Mode().Perm())
}
}
}