mirror of https://github.com/dapr/go-sdk.git
Fix error saving actor state for readonly changes (#233)
Signed-off-by: Tianpeng Wang <tpwang@alauda.io>
This commit is contained in:
parent
40d8a4eabe
commit
d3c3384c4e
|
|
@ -88,6 +88,11 @@ func (d *DaprStateAsyncProvider) Apply(actorType, actorID string, changes []*Act
|
||||||
Value: value,
|
Value: value,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if len(operations) == 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
return d.daprClient.SaveStateTransactionally(context.Background(), actorType, actorID, operations)
|
return d.daprClient.SaveStateTransactionally(context.Background(), actorType, actorID, operations)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,35 @@ func TestDaprStateAsyncProvider_Apply(t *testing.T) {
|
||||||
args args
|
args args
|
||||||
wantErr bool
|
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.
|
// TODO: Add test cases.
|
||||||
}
|
}
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue