Fix error saving actor state for readonly changes (#233)

Signed-off-by: Tianpeng Wang <tpwang@alauda.io>
This commit is contained in:
Timon Wong 2022-01-12 01:37:26 +08:00 committed by GitHub
parent 40d8a4eabe
commit d3c3384c4e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 34 additions and 0 deletions

View File

@ -88,6 +88,11 @@ func (d *DaprStateAsyncProvider) Apply(actorType, actorID string, changes []*Act
Value: value,
})
}
if len(operations) == 0 {
return nil
}
return d.daprClient.SaveStateTransactionally(context.Background(), actorType, actorID, operations)
}

View File

@ -37,6 +37,35 @@ func TestDaprStateAsyncProvider_Apply(t *testing.T) {
args args
wantErr bool
}{
{
name: "empty changes",
args: args{
actorType: "testActor",
actorID: "test-0",
changes: nil,
},
wantErr: false,
},
{
name: "only readonly state changes",
args: args{
actorType: "testActor",
actorID: "test-0",
changes: []*ActorStateChange{
{
stateName: "stateName1",
value: "Any",
changeKind: None,
},
{
stateName: "stateName2",
value: "Any",
changeKind: None,
},
},
},
wantErr: false,
},
// TODO: Add test cases.
}
for _, tt := range tests {