File tree Expand file tree Collapse file tree 2 files changed +32
-0
lines changed Expand file tree Collapse file tree 2 files changed +32
-0
lines changed Original file line number Diff line number Diff line change 44package statecheck_test
55
66import (
7+ "fmt"
78 "regexp"
89 "testing"
910
@@ -42,6 +43,13 @@ func TestExtractBoolValue_Basic(t *testing.T) {
4243 },
4344 },
4445 })
46+
47+ t .Run ("CheckTargetVar" , func (t * testing.T ) {
48+ // Now use the testAccAssertBoolEquals function to verify the value of targetVar
49+ if err := testAccAssertBoolEquals (true , targetVar ); err != nil {
50+ t .Errorf ("Error in testAccAssertBoolEquals: %v" , err )
51+ }
52+ })
4553}
4654
4755func TestExtractBoolValue_KnownValueWrongType (t * testing.T ) {
@@ -136,3 +144,11 @@ func TestExtractBoolValue_ResourceNotFound(t *testing.T) {
136144 },
137145 })
138146}
147+
148+ // testAccAssertBoolEquals compares the expected and target bool values.
149+ func testAccAssertBoolEquals (expected bool , targetVar bool ) error {
150+ if targetVar != expected {
151+ return fmt .Errorf ("expected targetVar to be %v, got %v" , expected , targetVar )
152+ }
153+ return nil
154+ }
Original file line number Diff line number Diff line change 44package statecheck_test
55
66import (
7+ "fmt"
78 "testing"
89
910 "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
@@ -41,4 +42,19 @@ func TestExtractStringValue_Basic(t *testing.T) {
4142 },
4243 },
4344 })
45+
46+ t .Run ("CheckTargetVar" , func (t * testing.T ) {
47+ // Now use the testAccAssertBoolEquals function to verify the value of targetVar
48+ if err := testAccAssertStringEquals ("str" , targetVar ); err != nil {
49+ t .Errorf ("Error in testAccAssertBoolEquals: %v" , err )
50+ }
51+ })
52+ }
53+
54+ // testAccAssertStringEquals compares the expected and target string values.
55+ func testAccAssertStringEquals (expected string , targetVar string ) error {
56+ if targetVar != expected {
57+ return fmt .Errorf ("expected targetVar to be %v, got %v" , expected , targetVar )
58+ }
59+ return nil
4460}
You can’t perform that action at this time.
0 commit comments