Skip to content

Commit

Permalink
fix addrundata from removing platformexceptions (#1978)
Browse files Browse the repository at this point in the history
* fix addrundata from removing platformexceptions

* add unit test

* update acdc to gofmt
  • Loading branch information
prinikasn authored Aug 4, 2023
1 parent 05d0223 commit 32303e1
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
1 change: 1 addition & 0 deletions tools/addrundata/case.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ func (tc *testcase) fix() error {

if tc.existing != nil {
tc.fixed.Testbed = tc.existing.Testbed
tc.fixed.PlatformExceptions = tc.existing.PlatformExceptions
u, err := uuid.Parse(tc.existing.Uuid)
if err == nil && u.Variant() == uuid.RFC4122 && u.Version() == 4 {
// Existing UUID is valid, but make sure it is normalized.
Expand Down
45 changes: 45 additions & 0 deletions tools/addrundata/case_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,51 @@ func TestCase_FixUUID(t *testing.T) {
}
}

func TestCase_FixWithPlatformExceptions(t *testing.T) {
tc := testcase{
markdown: &mpb.Metadata{
PlanId: "XX-1.1",
Description: "Foo Functional Test",
},
existing: &mpb.Metadata{
Testbed: mpb.Metadata_TESTBED_DUT,
PlatformExceptions: []*mpb.Metadata_PlatformExceptions{
{
Platform: &mpb.Metadata_Platform{
HardwareModelRegex: "8808",
},
Deviations: &mpb.Metadata_Deviations{
Ipv4MissingEnabled: true,
},
},
},
},
}
if err := tc.fix(); err != nil {
t.Fatal(err)
}
got := tc.fixed
want := &mpb.Metadata{
Uuid: got.Uuid,
PlanId: tc.markdown.PlanId,
Description: tc.markdown.Description,
Testbed: mpb.Metadata_TESTBED_DUT,
PlatformExceptions: []*mpb.Metadata_PlatformExceptions{
{
Platform: &mpb.Metadata_Platform{
HardwareModelRegex: "8808",
},
Deviations: &mpb.Metadata_Deviations{
Ipv4MissingEnabled: true,
},
},
},
}
if diff := cmp.Diff(want, got, tcopts...); diff != "" {
t.Errorf("fixed -want,+got:\n%s", diff)
}
}

func TestCase_Write(t *testing.T) {
var want, got testcase

Expand Down

0 comments on commit 32303e1

Please sign in to comment.