Artifact ba244a58a173f44191ae603d17b758436a5108050daec3422b2f30a6acb7d5ca:
- File
cli/repo_clone_remember_test.go
— part of check-in
[caf59be3b2]
at
2026-10-21 16:42:09
on branch feat/submanifest-reader
— fix(cli): repo clone remembers last-sync-url
go-libfossil read last-sync-url as the default peer for repo cone store, widening and required-content recovery, but nothing wrote it, so only a repository fossil had cloned had one. repo clone now stores its source as fossil clone does, with any user name and without the password. (user: [email protected], size: 1431) [annotate] [blame] [check-ins using] [more...]
package cli import ( "path/filepath" "sync/atomic" "testing" libfossil "github.com/danmestas/go-libfossil" ) // repo clone remembers its source as last-sync-url, as fossil clone does, so // widening and required-content recovery find their peer without --remote. // Method: clone from an HTTP peer through the command, then read the setting. func TestRepoCloneRemembersSyncURL(t *testing.T) { source := requiredHTTPSource(t) var requests atomic.Int64 server := requiredHTTPServer(t, source, &requests) defer server.Close() path := filepath.Join(t.TempDir(), "clone.fossil") requiredHTTPStdout(t, func() error { return (&RepoCloneCmd{URL: server.URL, Path: path}).Run(&Globals{}) }) r, err := libfossil.Open(path) if err != nil { t.Fatal(err) } defer r.Close() if got, err := r.Config("last-sync-url"); err != nil || got != server.URL { t.Fatalf("last-sync-url = %q, %v; want %q", got, err, server.URL) } } // A password in the clone URL is never stored; the user name is. func TestRememberedSyncURLDropsPassword(t *testing.T) { for raw, want := range map[string]string{ "https://u:[email protected]/repo": "https://[email protected]/repo", "https://[email protected]/repo": "https://[email protected]/repo", "http://127.0.0.1:8080": "http://127.0.0.1:8080", } { if got := rememberedSyncURL(raw); got != want { t.Errorf("rememberedSyncURL(%q) = %q, want %q", raw, got, want) } } }