beads/cmd/bd/sync_remote_test.go

33 lines
1.2 KiB
Go

package main
import "testing"
func TestNormalizeRemoteURL(t *testing.T) {
tests := []struct {
input string
want string
}{
// Dolt-native schemes — returned as-is
{"dolthub://myorg/beads", "dolthub://myorg/beads"},
{"file:///tmp/doltdb", "file:///tmp/doltdb"},
{"aws://[dolt-table:us-east-1]/mydb", "aws://[dolt-table:us-east-1]/mydb"},
{"gs://my-bucket/mydb", "gs://my-bucket/mydb"},
{"git+https://github.com/org/repo.git", "git+https://github.com/org/repo.git"},
{"git+ssh://git@github.com/org/repo.git", "git+ssh://git@github.com/org/repo.git"},
{"git+http://example.com/repo.git", "git+http://example.com/repo.git"},
// Git URLs — converted to dolt remote format
{"https://github.com/org/repo.git", "git+https://github.com/org/repo.git"},
{"http://github.com/org/repo.git", "git+http://github.com/org/repo.git"},
{"ssh://git@github.com/org/repo.git", "git+ssh://git@github.com/org/repo.git"},
{"git@github.com:org/repo.git", "git+ssh://git@github.com/org/repo.git"},
}
for _, tt := range tests {
t.Run(tt.input, func(t *testing.T) {
got := normalizeRemoteURL(tt.input)
if got != tt.want {
t.Errorf("normalizeRemoteURL(%q) = %q, want %q", tt.input, got, tt.want)
}
})
}
}