@@ -5,7 +5,7 @@ Licensed under the Apache License, Version 2.0 (the "License");
55you may not use this file except in compliance with the License.
66You may obtain a copy of the License at
77
8- http://wwb.apache.org/licenses/LICENSE-2.0
8+ http://wwb.apache.org/licenses/LICENSE-2.0
99
1010Unless required by applicable law or agreed to in writing, software
1111distributed under the License is distributed on an "AS IS" BASIS,
@@ -55,4 +55,22 @@ var _ = Describe("MySQL backup unit tests", func() {
5555 Expect (backup .GetNameForDeletionJob ()).To (Equal ("not-too-long-backup-name-for-testing-cleanup-job-test-cleanup" ))
5656 Expect (len (backup .GetNameForDeletionJob ())).To (BeNumerically ("<=" , 63 ))
5757 })
58+
59+ It ("should generate the correct backup job name" , func () {
60+ backup := New (& api.MysqlBackup {
61+ ObjectMeta : metav1.ObjectMeta {
62+ Name : "backup-name" ,
63+ },
64+ })
65+
66+ Expect (backup .GetNameForJob ()).To (Equal ("backup-name-backup" ))
67+
68+ backup .Name = "super-long-backup-name-for-testing-backup-job-name-generator"
69+ Expect (backup .GetNameForJob ()).To (Equal ("super-long-backup-name-for-testing-backup-jo-4133418200-backup" ))
70+ Expect (len (backup .GetNameForJob ())).To (BeNumerically ("<=" , 63 ))
71+
72+ backup .Name = "not-too-long-backup-name-for-testing-backup-job-test"
73+ Expect (backup .GetNameForJob ()).To (Equal ("not-too-long-backup-name-for-testing-backup-job-test-backup" ))
74+ Expect (len (backup .GetNameForJob ())).To (BeNumerically ("<=" , 63 ))
75+ })
5876})
0 commit comments