@@ -4980,9 +4980,18 @@ func (ts *IntegrationTestSuite) TestScheduleUpdate() {
4980
4980
err = handle .Delete (ctx )
4981
4981
ts .NoError (err )
4982
4982
}()
4983
+
4984
+ stringKey := temporal .NewSearchAttributeKeyString ("CustomStringField" )
4985
+ keywordKey := temporal .NewSearchAttributeKeyKeyword ("CustomKeywordField" )
4986
+ sa := temporal .NewSearchAttributes (
4987
+ stringKey .ValueSet ("CustomStringFieldValue" ),
4988
+ keywordKey .ValueSet ("foo" ),
4989
+ )
4990
+
4983
4991
updateFunc := func (input client.ScheduleUpdateInput ) (* client.ScheduleUpdate , error ) {
4984
4992
return & client.ScheduleUpdate {
4985
- Schedule : & input .Description .Schedule ,
4993
+ Schedule : & input .Description .Schedule ,
4994
+ TypedSearchAttributes : & sa ,
4986
4995
}, nil
4987
4996
}
4988
4997
description , err := handle .Describe (ctx )
@@ -4993,9 +5002,119 @@ func (ts *IntegrationTestSuite) TestScheduleUpdate() {
4993
5002
})
4994
5003
ts .NoError (err )
4995
5004
4996
- description2 , err := handle .Describe (ctx )
5005
+ ts .EventuallyWithT (func (c * assert.CollectT ) {
5006
+ d , err := handle .Describe (ctx )
5007
+ assert .NoError (c , err )
5008
+ assert .Equal (c , description .Schedule , d .Schedule )
5009
+ assert .Equal (c , 2 , d .TypedSearchAttributes .Size ())
5010
+ returnedString , _ := d .TypedSearchAttributes .GetString (stringKey )
5011
+ expectedString , _ := sa .GetString (stringKey )
5012
+ assert .Equal (c , expectedString , returnedString )
5013
+ returnedKeyword , _ := d .TypedSearchAttributes .GetKeyword (keywordKey )
5014
+ expectedKeyword , _ := sa .GetKeyword (keywordKey )
5015
+ assert .Equal (c , expectedKeyword , returnedKeyword )
5016
+ assert .Equal (c , 2 , len (d .SearchAttributes .IndexedFields ))
5017
+ }, time .Second , 100 * time .Millisecond )
5018
+
5019
+ // nil search attributes should leave current search attributes untouched
5020
+ updateFunc = func (input client.ScheduleUpdateInput ) (* client.ScheduleUpdate , error ) {
5021
+ return & client.ScheduleUpdate {
5022
+ Schedule : & input .Description .Schedule ,
5023
+ }, nil
5024
+ }
5025
+
5026
+ err = handle .Update (ctx , client.ScheduleUpdateOptions {
5027
+ DoUpdate : updateFunc ,
5028
+ })
5029
+ ts .NoError (err )
5030
+
5031
+ ts .EventuallyWithT (func (c * assert.CollectT ) {
5032
+ d , err := handle .Describe (ctx )
5033
+ assert .NoError (c , err )
5034
+ assert .Equal (c , 2 , d .TypedSearchAttributes .Size ())
5035
+ returnedString , _ := d .TypedSearchAttributes .GetString (stringKey )
5036
+ expectedString , _ := sa .GetString (stringKey )
5037
+ assert .Equal (c , expectedString , returnedString )
5038
+ returnedKeyword , _ := d .TypedSearchAttributes .GetKeyword (keywordKey )
5039
+ expectedKeyword , _ := sa .GetKeyword (keywordKey )
5040
+ assert .Equal (c , expectedKeyword , returnedKeyword )
5041
+ assert .Equal (c , 2 , len (d .SearchAttributes .IndexedFields ))
5042
+ }, time .Second , 100 * time .Millisecond )
5043
+
5044
+ // Updating an attribute without affecting the others
5045
+ updateFunc = func (input client.ScheduleUpdateInput ) (* client.ScheduleUpdate , error ) {
5046
+ newSa := temporal .NewSearchAttributes (
5047
+ input .Description .TypedSearchAttributes .Copy (),
5048
+ stringKey .ValueSet ("Changed" ),
5049
+ )
5050
+ return & client.ScheduleUpdate {
5051
+ Schedule : & input .Description .Schedule ,
5052
+ TypedSearchAttributes : & newSa ,
5053
+ }, nil
5054
+ }
5055
+
5056
+ err = handle .Update (ctx , client.ScheduleUpdateOptions {
5057
+ DoUpdate : updateFunc ,
5058
+ })
5059
+ ts .NoError (err )
5060
+
5061
+ ts .EventuallyWithT (func (c * assert.CollectT ) {
5062
+ d , err := handle .Describe (ctx )
5063
+ assert .NoError (c , err )
5064
+ assert .Equal (c , 2 , d .TypedSearchAttributes .Size ())
5065
+ returnedString , _ := d .TypedSearchAttributes .GetString (stringKey )
5066
+ expectedString , _ := temporal .NewSearchAttributes (stringKey .ValueSet ("Changed" )).GetString (stringKey )
5067
+ assert .Equal (c , expectedString , returnedString )
5068
+ returnedKeyword , _ := d .TypedSearchAttributes .GetKeyword (keywordKey )
5069
+ expectedKeyword , _ := sa .GetKeyword (keywordKey )
5070
+ assert .Equal (c , expectedKeyword , returnedKeyword )
5071
+ assert .Equal (c , 2 , len (d .SearchAttributes .IndexedFields ))
5072
+ }, time .Second , 100 * time .Millisecond )
5073
+
5074
+ // updating a single search attribute on an existing collection acts as an upsert on the entire collection
5075
+ newSa := temporal .NewSearchAttributes (stringKey .ValueSet ("Changed" ))
5076
+ updateFunc = func (input client.ScheduleUpdateInput ) (* client.ScheduleUpdate , error ) {
5077
+ return & client.ScheduleUpdate {
5078
+ Schedule : & input .Description .Schedule ,
5079
+ TypedSearchAttributes : & newSa ,
5080
+ }, nil
5081
+ }
5082
+
5083
+ err = handle .Update (ctx , client.ScheduleUpdateOptions {
5084
+ DoUpdate : updateFunc ,
5085
+ })
5086
+ ts .NoError (err )
5087
+
5088
+ ts .EventuallyWithT (func (c * assert.CollectT ) {
5089
+ d , err := handle .Describe (ctx )
5090
+ assert .NoError (c , err )
5091
+ assert .Equal (c , 1 , d .TypedSearchAttributes .Size ())
5092
+ returnedString , _ := d .TypedSearchAttributes .GetString (stringKey )
5093
+ expectedString , _ := newSa .GetString (stringKey )
5094
+ assert .Equal (c , expectedString , returnedString )
5095
+ assert .Equal (c , 1 , len (d .SearchAttributes .IndexedFields ))
5096
+ }, time .Second , 100 * time .Millisecond )
5097
+
5098
+ // empty search attributes should remove pre-existing search attributes
5099
+ sa = temporal .NewSearchAttributes ()
5100
+ updateFunc = func (input client.ScheduleUpdateInput ) (* client.ScheduleUpdate , error ) {
5101
+ return & client.ScheduleUpdate {
5102
+ Schedule : & input .Description .Schedule ,
5103
+ TypedSearchAttributes : & sa ,
5104
+ }, nil
5105
+ }
5106
+
5107
+ err = handle .Update (ctx , client.ScheduleUpdateOptions {
5108
+ DoUpdate : updateFunc ,
5109
+ })
4997
5110
ts .NoError (err )
4998
- ts .Equal (description .Schedule , description2 .Schedule )
5111
+
5112
+ ts .EventuallyWithT (func (c * assert.CollectT ) {
5113
+ d , err := handle .Describe (ctx )
5114
+ assert .NoError (c , err )
5115
+ assert .Nil (c , d .SearchAttributes )
5116
+ assert .Empty (c , d .TypedSearchAttributes )
5117
+ }, time .Second , 100 * time .Millisecond )
4999
5118
}
5000
5119
5001
5120
func (ts * IntegrationTestSuite ) TestScheduleUpdateCancelUpdate () {
0 commit comments