@@ -23,39 +23,45 @@ import (
2323func TestSanitizeRepoName (t * testing.T ) {
2424 testCases := []struct {
2525 testName string
26- repoPrefix string
26+ repoSuffix string
2727 repoName string
2828 expectedName string
2929 }{
3030 {
3131 testName : "RepoSync test-ns/repo-sync" ,
32- repoPrefix : "test " ,
32+ repoSuffix : "project/cluster " ,
3333 repoName : "test-ns/repo-sync" ,
34- expectedName : "cs-e2e- test-test- ns-repo-sync-19dcbc51 " ,
34+ expectedName : "test-ns-repo-sync-project-cluster-b96b1396 " ,
3535 },
3636 {
3737 testName : "RepoSync test/ns-repo-sync should not collide with RepoSync test-ns/repo-sync" ,
38- repoPrefix : "test " ,
38+ repoSuffix : "project/cluster " ,
3939 repoName : "test/ns-repo-sync" ,
40- expectedName : "cs-e2e- test-test- ns-repo-sync-f98ca740 " ,
40+ expectedName : "test-ns-repo-sync-project-cluster-d98dee7d " ,
4141 },
4242 {
43- testName : "A very long repoPrefix should be truncated" ,
44- repoPrefix : "autopilot-rapid-latest-10" ,
43+ testName : "A very long repoSuffix should be truncated" ,
44+ repoSuffix : "kpt-config-sync-ci-main/ autopilot-rapid-latest-10" ,
4545 repoName : "config-management-system/root-sync" ,
46- expectedName : "cs-e2e-autopilot-rapid-latest-10-config-management-sys-0aab99c5" ,
46+ expectedName : "config-management-system-root-sync-kpt-config-sync-ci-6485bfa0" ,
47+ },
48+ {
49+ testName : "A similar very long repoSuffix should be truncated and not collide" ,
50+ repoSuffix : "kpt-config-sync-ci-release/autopilot-rapid-latest-10" ,
51+ repoName : "config-management-system/root-sync" ,
52+ expectedName : "config-management-system-root-sync-kpt-config-sync-ci-8b9c3b0d" ,
4753 },
4854 {
4955 testName : "A very long repoName should be truncated" ,
50- repoPrefix : "test" ,
56+ repoSuffix : "test" ,
5157 repoName : "config-management-system/root-sync-with-a-very-long-name" ,
52- expectedName : "cs-e2e-test- config-management-system-root-sync-with-a--0d0af6c0 " ,
58+ expectedName : "config-management-system-root-sync-with-a-very-long-na-3b0dae1c " ,
5359 },
5460 }
5561
5662 for _ , tc := range testCases {
5763 t .Run (tc .testName , func (t * testing.T ) {
58- gotName := SanitizeRepoName (tc .repoPrefix , tc .repoName )
64+ gotName := SanitizeRepoName (tc .repoSuffix , tc .repoName )
5965 assert .Equal (t , tc .expectedName , gotName )
6066 })
6167 }
0 commit comments