Set backupSchedule as required in MongoDB Flex instance (#96)

* Set backupSchedule as required in MongoDB Flex instance

* Update example and generate docs

* Add regex explanation comment

* Fix acceptance test

* Fix map fields
This commit is contained in:
João Palet 2023-10-20 14:38:19 +02:00 committed by GitHub
parent 59ee1b529e
commit e61bfe09a5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 134 additions and 27 deletions

View file

@ -748,3 +748,75 @@ func TestLoadFlavorId(t *testing.T) {
})
}
}
func TestSimplifyBackupSchedule(t *testing.T) {
tests := []struct {
description string
input string
expected string
}{
{
"simple schedule",
"0 0 * * *",
"0 0 * * *",
},
{
"schedule with leading zeros",
"00 00 * * *",
"0 0 * * *",
},
{
"schedule with leading zeros 2",
"00 001 * * *",
"0 1 * * *",
},
{
"schedule with leading zeros 3",
"00 0010 * * *",
"0 10 * * *",
},
{
"simple schedule with slash",
"0 0/6 * * *",
"0 0/6 * * *",
},
{
"schedule with leading zeros and slash",
"00 00/6 * * *",
"0 0/6 * * *",
},
{
"schedule with leading zeros and slash 2",
"00 001/06 * * *",
"0 1/6 * * *",
},
{
"simple schedule with comma",
"0 10,15 * * *",
"0 10,15 * * *",
},
{
"schedule with leading zeros and comma",
"0 010,0015 * * *",
"0 10,15 * * *",
},
{
"simple schedule with comma and slash",
"0 0-11/10 * * *",
"0 0-11/10 * * *",
},
{
"schedule with leading zeros, comma, and slash",
"00 000-011/010 * * *",
"0 0-11/10 * * *",
},
}
for _, tt := range tests {
t.Run(tt.description, func(t *testing.T) {
output := simplifyBackupSchedule(tt.input)
if output != tt.expected {
t.Fatalf("Data does not match: %s", output)
}
})
}
}