Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Name measurement value #139

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions comid/measurement.go
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,7 @@ type Mval struct {
SerialNumber *string `cbor:"8,keyasint,omitempty" json:"serial-number,omitempty"`
UEID *eat.UEID `cbor:"9,keyasint,omitempty" json:"ueid,omitempty"`
UUID *UUID `cbor:"10,keyasint,omitempty" json:"uuid,omitempty"`
Name *string `cbor:"11,keyasint,omitempty" json:"name,omitempty"`
IntegrityRegisters *IntegrityRegisters `cbor:"14,keyasint,omitempty" json:"integrity-registers,omitempty"`
Extensions
}
Expand Down Expand Up @@ -435,6 +436,7 @@ func (o Mval) Valid() error {
o.SerialNumber == nil &&
o.UEID == nil &&
o.UUID == nil &&
o.Name == nil &&
o.IntegrityRegisters == nil {
return fmt.Errorf("no measurement value set")
}
Expand Down Expand Up @@ -764,6 +766,15 @@ func (o *Measurement) SetUUID(u UUID) *Measurement {
return o
}

// SetName sets the supplied name string in the measurement-values-map of the
// target measurement
func (o *Measurement) SetName(name string) *Measurement {
if o != nil {
o.Val.Name = &name
}
return o
}

func (o Measurement) Valid() error {
if o.Key != nil && o.Key.IsSet() {
if err := o.Key.Valid(); err != nil {
Expand Down
6 changes: 6 additions & 0 deletions comid/measurement_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,12 @@ func TestMeasurement_NewUUIDMeasurement_bad_uuid(t *testing.T) {
assert.Nil(t, tv.SetUUID(nonRFC4122UUID))
}

func TestMeasurement_NameMeasurement(t *testing.T) {
want := "Maureen"
got := *(&Measurement{}).SetName("Maureen").Val.Name
assert.Equal(t, want, got)
}

var (
testMKeyUintMin uint64
testMKeyUintMax = ^uint64(0)
Expand Down
Loading