Skip to content

Commit

Permalink
Add more tests to arm and base (#983)
Browse files Browse the repository at this point in the history
continuation of [RSDK-325]
  • Loading branch information
alexis-wei authored Jul 7, 2022
1 parent 71c7992 commit 23ccbc2
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
20 changes: 20 additions & 0 deletions component/arm/arm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,17 @@ func TestWrapWithReconfigurable(t *testing.T) {
reconfArm2, err := arm.WrapWithReconfigurable(reconfArm1)
test.That(t, err, test.ShouldBeNil)
test.That(t, reconfArm2, test.ShouldEqual, reconfArm1)

var actualArm2 arm.LocalArm = &mockLocal{Name: testArmName}
reconfArm3, err := arm.WrapWithReconfigurable(actualArm2)
test.That(t, err, test.ShouldBeNil)

reconfArm4, err := arm.WrapWithReconfigurable(reconfArm3)
test.That(t, err, test.ShouldBeNil)
test.That(t, reconfArm4, test.ShouldResemble, reconfArm3)

_, ok := reconfArm4.(arm.LocalArm)
test.That(t, ok, test.ShouldBeTrue)
}

func TestReconfigurableArm(t *testing.T) {
Expand Down Expand Up @@ -304,6 +315,15 @@ func TestReconfigurableArm(t *testing.T) {
err = reconfArm3.Reconfigure(context.Background(), reconfArm1)
test.That(t, err, test.ShouldNotBeNil)
test.That(t, err, test.ShouldBeError, rutils.NewUnexpectedTypeError(reconfArm3, reconfArm1))

actualArm4 := &mock{Name: testArmName2}
reconfArm4, err := arm.WrapWithReconfigurable(actualArm4)
test.That(t, err, test.ShouldBeNil)
test.That(t, reconfArm4, test.ShouldNotBeNil)

err = reconfArm3.Reconfigure(context.Background(), reconfArm4)
test.That(t, err, test.ShouldBeNil)
test.That(t, reconfArm3, test.ShouldResemble, reconfArm4)
}

func TestStop(t *testing.T) {
Expand Down
20 changes: 20 additions & 0 deletions component/base/base_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,17 @@ func TestWrapWithReconfigurable(t *testing.T) {
reconfBase2, err := base.WrapWithReconfigurable(reconfBase1)
test.That(t, err, test.ShouldBeNil)
test.That(t, reconfBase2, test.ShouldEqual, reconfBase1)

var actualBase2 base.LocalBase = &mockLocal{Name: testBaseName}
reconfBase3, err := base.WrapWithReconfigurable(actualBase2)
test.That(t, err, test.ShouldBeNil)

reconfBase4, err := base.WrapWithReconfigurable(reconfBase3)
test.That(t, err, test.ShouldBeNil)
test.That(t, reconfBase4, test.ShouldResemble, reconfBase3)

_, ok := reconfBase4.(base.LocalBase)
test.That(t, ok, test.ShouldBeTrue)
}

func TestReconfigurableBase(t *testing.T) {
Expand Down Expand Up @@ -237,6 +248,15 @@ func TestReconfigurableBase(t *testing.T) {
err = reconfBase3.Reconfigure(context.Background(), reconfBase1)
test.That(t, err, test.ShouldNotBeNil)
test.That(t, err, test.ShouldBeError, rutils.NewUnexpectedTypeError(reconfBase3, reconfBase1))

actualBase4 := &mock{Name: testBaseName2}
reconfBase4, err := base.WrapWithReconfigurable(actualBase4)
test.That(t, err, test.ShouldBeNil)
test.That(t, reconfBase4, test.ShouldNotBeNil)

err = reconfBase3.Reconfigure(context.Background(), reconfBase4)
test.That(t, err, test.ShouldBeNil)
test.That(t, reconfBase3, test.ShouldResemble, reconfBase4)
}

func TestClose(t *testing.T) {
Expand Down

0 comments on commit 23ccbc2

Please sign in to comment.