Skip to content

Commit

Permalink
Further work on logging index
Browse files Browse the repository at this point in the history
Signed-off-by: Yogesh Deshpande <[email protected]>
  • Loading branch information
yogeshbdeshpande committed Jan 30, 2025
1 parent 073439c commit 9ec2a7c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions comid/tdx-profile/teetcbstatus.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ func NewTeeTcbStatus(val []any) *TeeTcbStatus {
}

func (o *TeeTcbStatus) AddTeeTcbStatus(val []any) error {
for _, v := range val {
for i, v := range val {
switch t := v.(type) {
case string:
*o = append(*o, t)
default:
return fmt.Errorf("invalid type: %T for tcb status", t)
return fmt.Errorf("invalid type: %T for tcb status at index: %d", t, i)
}
}
return nil
Expand All @@ -42,12 +42,12 @@ func (o TeeTcbStatus) Valid() error {
return fmt.Errorf("empty tcb status")
}

for _, v := range o {
for i, v := range o {
switch t := v.(type) {
case string:
continue
default:
return fmt.Errorf("invalid type %T for tcb status", t)
return fmt.Errorf("invalid type: %T for tcb status at index: %d", t, i)
}
}
return nil
Expand Down
4 changes: 2 additions & 2 deletions comid/tdx-profile/teetcbstatus_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func TestTcbStatus_AddTcbStatus_OK(t *testing.T) {
}

func TestTcbStatus_AddTcbStatus_NOK(t *testing.T) {
expectedErr := "invalid type: int for tcb status"
expectedErr := "invalid type: int for tcb status at index: 0"
s := make([]any, len(TestInvalidTCBStatus))
for i := range TestInvalidTCBStatus {
s[i] = TestInvalidTCBStatus[i]
Expand All @@ -66,7 +66,7 @@ func TestTcbStatus_Valid_NOK(t *testing.T) {
status := TeeTcbStatus{}
err := status.Valid()
assert.EqualError(t, err, expectedErr)
expectedErr = "invalid type int for tcb status"
expectedErr = "invalid type: int for tcb status at index: 0"
s := make([]any, len(TestInvalidTCBStatus))
for i := range TestInvalidTCBStatus {
s[i] = TestInvalidTCBStatus[i]
Expand Down

0 comments on commit 9ec2a7c

Please sign in to comment.