Skip to content

Commit c721256

Browse files
Add Name measurement value (#139)
* Add Name measurement value Fixes #56 Signed-off-by: Dionna Glaze <[email protected]> * Fix format error Signed-off-by: Yogesh Deshpande <[email protected]> * Fix format Signed-off-by: Yogesh Deshpande <[email protected]> * Fix Format Signed-off-by: Yogesh Deshpande <[email protected]> --------- Signed-off-by: Dionna Glaze <[email protected]> Signed-off-by: Yogesh Deshpande <[email protected]> Co-authored-by: Yogesh Deshpande <[email protected]>
1 parent 51737fa commit c721256

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

comid/measurement.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,7 @@ type Mval struct {
353353
SerialNumber *string `cbor:"8,keyasint,omitempty" json:"serial-number,omitempty"`
354354
UEID *eat.UEID `cbor:"9,keyasint,omitempty" json:"ueid,omitempty"`
355355
UUID *UUID `cbor:"10,keyasint,omitempty" json:"uuid,omitempty"`
356+
Name *string `cbor:"11,keyasint,omitempty" json:"name,omitempty"`
356357
IntegrityRegisters *IntegrityRegisters `cbor:"14,keyasint,omitempty" json:"integrity-registers,omitempty"`
357358
Extensions
358359
}
@@ -439,8 +440,10 @@ func (o Mval) Valid() error {
439440
o.SerialNumber == nil &&
440441
o.UEID == nil &&
441442
o.UUID == nil &&
443+
o.Name == nil &&
442444
o.IntegrityRegisters == nil &&
443445
o.Extensions.IsEmpty() {
446+
444447
return fmt.Errorf("no measurement value set")
445448
}
446449

@@ -756,6 +759,15 @@ func (o *Measurement) SetUUID(u UUID) *Measurement {
756759
return o
757760
}
758761

762+
// SetName sets the supplied name string in the measurement-values-map of the
763+
// target measurement
764+
func (o *Measurement) SetName(name string) *Measurement {
765+
if o != nil {
766+
o.Val.Name = &name
767+
}
768+
return o
769+
}
770+
759771
// nolint:gocritic
760772
func (o Measurement) Valid() error {
761773
if o.Key != nil && o.Key.IsSet() {

comid/measurement_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,12 @@ func TestMeasurement_NewUUIDMeasurement_bad_uuid(t *testing.T) {
193193
assert.Nil(t, tv.SetUUID(nonRFC4122UUID))
194194
}
195195

196+
func TestMeasurement_NameMeasurement(t *testing.T) {
197+
want := "Maureen"
198+
got := *(&Measurement{}).SetName("Maureen").Val.Name
199+
assert.Equal(t, want, got)
200+
}
201+
196202
var (
197203
testMKeyUintMin uint64
198204
testMKeyUintMax = ^uint64(0)

0 commit comments

Comments
 (0)