feat(hostsets): Classify all proto fields

This commit is contained in:
Johan Brandhorst-Satzkorn committed 2022-04-20 13:32:31 -04:00
1 parent 8fa3e8dee0
commit d51ce41db8
11 files changed
+483 -285

No files matched your search

+16 -8
View File
@@ -75,8 +75,10 @@ func TestLoopbackPlugin(t *testing.T) {
require.NoError(err)
_, err = plg.OnCreateSet(ctx, &plgpb.OnCreateSetRequest{
Set: &hostsets.HostSet{
Id: "set1",
Attributes: attrs,
Id: "set1",
Attrs: &hostsets.HostSet_Attributes{
Attributes: attrs,
},
},
})
require.NoError(err)
@@ -92,8 +94,10 @@ func TestLoopbackPlugin(t *testing.T) {
require.NoError(err)
_, err = plg.OnCreateSet(ctx, &plgpb.OnCreateSetRequest{
Set: &hostsets.HostSet{
Id: "set2",
Attributes: attrs,
Id: "set2",
Attrs: &hostsets.HostSet_Attributes{
Attributes: attrs,
},
},
})
require.NoError(err)
@@ -249,8 +253,10 @@ func TestLoopbackPluginArrays(t *testing.T) {
require.NoError(err)
_, err = plg.OnCreateSet(ctx, &plgpb.OnCreateSetRequest{
Set: &hostsets.HostSet{
Id: "set1",
Attributes: attrs,
Id: "set1",
Attrs: &hostsets.HostSet_Attributes{
Attributes: attrs,
},
},
})
require.NoError(err)
@@ -274,8 +280,10 @@ func TestLoopbackPluginArrays(t *testing.T) {
require.NoError(err)
_, err = plg.OnCreateSet(ctx, &plgpb.OnCreateSetRequest{
Set: &hostsets.HostSet{
Id: "set2",
Attributes: attrs,
Id: "set2",
Attrs: &hostsets.HostSet_Attributes{
Attributes: attrs,
},
},
})
require.NoError(err)
+3 -1
View File
@@ -725,7 +725,9 @@ func toPluginSet(ctx context.Context, in *HostSet) (*pb.HostSet, error) {
if err := proto.Unmarshal(in.GetAttributes(), attrs); err != nil {
return nil, errors.Wrap(ctx, err, op, errors.WithMsg("unable to marshal attributes"))
}
hs.Attributes = attrs
hs.Attrs = &pb.HostSet_Attributes{
Attributes: attrs,
}
}
return hs, nil
}
@@ -648,14 +648,14 @@ func TestRepository_UpdateSet(t *testing.T) {
checkUpdateSetRequestCurrentAttributes := func(want map[string]interface{}) checkPluginReqFunc {
return func(t *testing.T, got *plgpb.OnUpdateSetRequest) {
t.Helper()
assert.Empty(t, cmp.Diff(mustStruct(want), got.CurrentSet.Attributes, protocmp.Transform()), "checkUpdateSetRequestCurrentAttributes")
assert.Empty(t, cmp.Diff(mustStruct(want), got.CurrentSet.GetAttributes(), protocmp.Transform()), "checkUpdateSetRequestCurrentAttributes")
}
}
checkUpdateSetRequestNewAttributes := func(want map[string]interface{}) checkPluginReqFunc {
return func(t *testing.T, got *plgpb.OnUpdateSetRequest) {
t.Helper()
assert.Empty(t, cmp.Diff(mustStruct(want), got.NewSet.Attributes, protocmp.Transform()), "checkUpdateSetRequestNewAttributes")
assert.Empty(t, cmp.Diff(mustStruct(want), got.NewSet.GetAttributes(), protocmp.Transform()), "checkUpdateSetRequestNewAttributes")
}
}