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"}, // Dolt remotesapi URLs — also converted (callers that need // pass-through for user-provided URLs should skip normalization) {"http://myserver:7007/mydb", "git+http://myserver:7007/mydb"}, {"https://doltremoteapi.example.com/mydb", "git+https://doltremoteapi.example.com/mydb"}, } 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) } }) } }