Skip to content

Commit e4e84f5

Browse files
committed
fix tests, update run triggers to handle deprecated in the same way
1 parent 22a0415 commit e4e84f5

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

notification_configuration.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,8 @@ func (s *notificationConfigurations) Read(ctx context.Context, notificationConfi
307307
return nil, err
308308
}
309309

310+
backfillDeprecatedSubscribable(nc)
311+
310312
return nc, nil
311313
}
312314

@@ -332,6 +334,8 @@ func (s *notificationConfigurations) Update(ctx context.Context, notificationCon
332334
return nil, err
333335
}
334336

337+
backfillDeprecatedSubscribable(nc)
338+
335339
return nc, nil
336340
}
337341

notification_configuration_integration_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ func TestNotificationConfigurationList(t *testing.T) {
7070
nil,
7171
)
7272
assert.Nil(t, ncl)
73-
assert.EqualError(t, err, ErrInvalidWorkspaceID.Error())
73+
assert.EqualError(t, err, ErrRequiredDestinationType.Error())
7474
})
7575
}
7676

run_trigger.go

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ type RunTrigger struct {
5757
SourceableName string `jsonapi:"attr,sourceable-name"`
5858
WorkspaceName string `jsonapi:"attr,workspace-name"`
5959
// DEPRECATED. The sourceable field is polymorphic. Use SourceableChoice instead.
60-
Sourceable *Workspace `jsonapi:"relation,sourceable"`
60+
Sourceable *Workspace `jsonapi:"relation,sourceable,omitempty"`
6161
SourceableChoice *SourceableChoice `jsonapi:"polyrelation,sourceable"`
6262
Workspace *Workspace `jsonapi:"relation,workspace"`
6363
}
@@ -121,6 +121,10 @@ func (s *runTriggers) List(ctx context.Context, workspaceID string, options *Run
121121
return nil, err
122122
}
123123

124+
for i := range rtl.Items {
125+
backfillDeprecatedSourceable(rtl.Items[i])
126+
}
127+
124128
return rtl, nil
125129
}
126130

@@ -145,6 +149,8 @@ func (s *runTriggers) Create(ctx context.Context, workspaceID string, options Ru
145149
return nil, err
146150
}
147151

152+
backfillDeprecatedSourceable(rt)
153+
148154
return rt, nil
149155
}
150156

@@ -166,6 +172,8 @@ func (s *runTriggers) Read(ctx context.Context, runTriggerID string) (*RunTrigge
166172
return nil, err
167173
}
168174

175+
backfillDeprecatedSourceable(rt)
176+
169177
return rt, nil
170178
}
171179

@@ -203,6 +211,14 @@ func (o *RunTriggerListOptions) valid() error {
203211
return nil
204212
}
205213

214+
func backfillDeprecatedSourceable(runTrigger *RunTrigger) {
215+
if runTrigger.Sourceable != nil || runTrigger.SourceableChoice == nil {
216+
return
217+
}
218+
219+
runTrigger.Sourceable = runTrigger.SourceableChoice.Workspace
220+
}
221+
206222
func validateRunTriggerFilterParam(filterParam RunTriggerFilterOp, includeParams []RunTriggerIncludeOpt) error {
207223
switch filterParam {
208224
case RunTriggerOutbound, RunTriggerInbound:

0 commit comments

Comments
 (0)