File tree Expand file tree Collapse file tree 2 files changed +18
-3
lines changed Expand file tree Collapse file tree 2 files changed +18
-3
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ import (
1111 "github.com/databrickslabs/terraform-provider-databricks/common"
1212 "github.com/databrickslabs/terraform-provider-databricks/sqlanalytics/api"
1313 "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
14+ "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
1415)
1516
1617// QueryEntity defines the parameters that can be set in the resource.
@@ -493,9 +494,10 @@ func ResourceQuery() *schema.Resource {
493494 s := common .StructToSchema (
494495 QueryEntity {},
495496 func (m map [string ]* schema.Schema ) map [string ]* schema.Schema {
497+ schedule := m ["schedule" ].Elem .(* schema.Resource )
498+
496499 // Make different query schedule types mutually exclusive.
497500 {
498- schedule := m ["schedule" ].Elem .(* schema.Resource )
499501 ns := []string {"continuous" , "daily" , "weekly" }
500502 for _ , n1 := range ns {
501503 for _ , n2 := range ns {
@@ -506,6 +508,19 @@ func ResourceQuery() *schema.Resource {
506508 }
507509 }
508510 }
511+
512+ // Validate week of day in weekly schedule.
513+ // Manually verified that this is case sensitive.
514+ weekly := schedule .Schema ["weekly" ].Elem .(* schema.Resource )
515+ weekly .Schema ["day_of_week" ].ValidateFunc = validation .StringInSlice ([]string {
516+ "Sunday" ,
517+ "Monday" ,
518+ "Tuesday" ,
519+ "Wednesday" ,
520+ "Thursday" ,
521+ "Friday" ,
522+ "Saturday" ,
523+ }, false )
509524 return m
510525 })
511526
Original file line number Diff line number Diff line change @@ -216,7 +216,7 @@ func TestQueryCreateWithWeeklySchedule(t *testing.T) {
216216 intervalWeeks := 2
217217 intervalSeconds := intervalWeeks * 7 * 24 * 60 * 60
218218 timeOfDay := "06:00"
219- dayOfWeek := "sunday "
219+ dayOfWeek := "Sunday "
220220 untilDate := "2021-04-21"
221221
222222 d , err := qa.ResourceFixture {
@@ -267,7 +267,7 @@ func TestQueryCreateWithWeeklySchedule(t *testing.T) {
267267 weekly {
268268 interval_weeks = 2
269269 time_of_day = "06:00"
270- day_of_week = "sunday "
270+ day_of_week = "Sunday "
271271 until_date = "2021-04-21"
272272 }
273273 }
You can’t perform that action at this time.
0 commit comments