Skip to content

Commit

Permalink
Refactoring to use updated known value check types (#266)
Browse files Browse the repository at this point in the history
  • Loading branch information
bendbennett committed Jan 15, 2024
1 parent 01fe9a9 commit fb9fed8
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 77 deletions.
50 changes: 25 additions & 25 deletions statecheck/expect_known_output_value_at_path_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ func TestExpectKnownOutputValueAtPath_CheckState_Bool_KnownValueWrongType(t *tes
knownvalue.Float64ValueExact(1.23),
),
},
ExpectError: regexp.MustCompile(`expected json\.Number value for Float64Value check, got: bool`),
ExpectError: regexp.MustCompile(`expected json\.Number value for Float64ValueExact check, got: bool`),
},
},
})
Expand Down Expand Up @@ -170,7 +170,7 @@ func TestExpectKnownOutputValueAtPath_CheckState_Bool_KnownValueWrongValue(t *te
knownvalue.BoolValueExact(false),
),
},
ExpectError: regexp.MustCompile("expected value false for BoolValue check, got: true"),
ExpectError: regexp.MustCompile("expected value false for BoolValueExact check, got: true"),
},
},
})
Expand Down Expand Up @@ -234,7 +234,7 @@ func TestExpectKnownOutputValueAtPath_CheckState_Float64_KnownValueWrongType(t *
knownvalue.StringValueExact("str"),
),
},
ExpectError: regexp.MustCompile(`expected string value for StringValue check, got: json\.Number`),
ExpectError: regexp.MustCompile(`expected string value for StringValueExact check, got: json\.Number`),
},
},
})
Expand Down Expand Up @@ -266,7 +266,7 @@ func TestExpectKnownOutputValueAtPath_CheckState_Float64_KnownValueWrongValue(t
knownvalue.Float64ValueExact(3.21),
),
},
ExpectError: regexp.MustCompile("expected value 3.21 for Float64Value check, got: 1.23"),
ExpectError: regexp.MustCompile("expected value 3.21 for Float64ValueExact check, got: 1.23"),
},
},
})
Expand Down Expand Up @@ -329,7 +329,7 @@ func TestExpectKnownOutputValueAtPath_CheckState_Int64_KnownValueWrongValue(t *t
knownvalue.Int64ValueExact(321),
),
},
ExpectError: regexp.MustCompile("expected value 321 for Int64Value check, got: 123"),
ExpectError: regexp.MustCompile("expected value 321 for Int64ValueExact check, got: 123"),
},
},
})
Expand Down Expand Up @@ -401,7 +401,7 @@ func TestExpectKnownOutputValueAtPath_CheckState_List_KnownValueWrongType(t *tes
knownvalue.MapValueExact(map[string]knownvalue.Check{}),
),
},
ExpectError: regexp.MustCompile(`expected map\[string\]any value for MapValue check, got: \[\]interface {}`),
ExpectError: regexp.MustCompile(`expected map\[string\]any value for MapValueExact check, got: \[\]interface {}`),
},
},
})
Expand Down Expand Up @@ -439,7 +439,7 @@ func TestExpectKnownOutputValueAtPath_CheckState_List_KnownValueWrongValue(t *te
}),
),
},
ExpectError: regexp.MustCompile(`list element index 0: expected value value3 for StringValue check, got: value1`),
ExpectError: regexp.MustCompile(`list element index 0: expected value value3 for StringValueExact check, got: value1`),
},
},
})
Expand Down Expand Up @@ -471,7 +471,7 @@ func TestExpectKnownOutputValueAtPath_CheckState_ListPartial(t *testing.T) {
statecheck.ExpectKnownOutputValueAtPath(
"test_resource_one_output",
tfjsonpath.New("list_attribute"),
knownvalue.ListValuePartialMatch(map[int]knownvalue.Check{
knownvalue.ListValuePartial(map[int]knownvalue.Check{
0: knownvalue.StringValueExact("value1"),
}),
),
Expand Down Expand Up @@ -509,12 +509,12 @@ func TestExpectKnownOutputValueAtPath_CheckState_ListPartial_KnownValueWrongValu
statecheck.ExpectKnownOutputValueAtPath(
"test_resource_one_output",
tfjsonpath.New("list_attribute"),
knownvalue.ListValuePartialMatch(map[int]knownvalue.Check{
knownvalue.ListValuePartial(map[int]knownvalue.Check{
0: knownvalue.StringValueExact("value3"),
}),
),
},
ExpectError: regexp.MustCompile(`list element 0: expected value value3 for StringValue check, got: value1`),
ExpectError: regexp.MustCompile(`list element 0: expected value value3 for StringValueExact check, got: value1`),
},
},
})
Expand Down Expand Up @@ -583,7 +583,7 @@ func TestExpectKnownOutputValueAtPath_CheckState_ListElements_WrongNum(t *testin
knownvalue.ListElementsExact(3),
),
},
ExpectError: regexp.MustCompile("expected 3 elements for ListElements check, got 2 elements"),
ExpectError: regexp.MustCompile("expected 3 elements for ListElementsExact check, got 2 elements"),
},
},
})
Expand Down Expand Up @@ -660,7 +660,7 @@ func TestExpectKnownOutputValueAtPath_CheckState_ListNestedBlockPartial(t *testi
statecheck.ExpectKnownOutputValueAtPath(
"test_resource_one_output",
tfjsonpath.New("list_nested_block"),
knownvalue.ListValuePartialMatch(map[int]knownvalue.Check{
knownvalue.ListValuePartial(map[int]knownvalue.Check{
1: knownvalue.MapValueExact(map[string]knownvalue.Check{
"list_nested_block_attribute": knownvalue.StringValueExact("rts"),
}),
Expand Down Expand Up @@ -774,7 +774,7 @@ func TestExpectKnownOutputValueAtPath_CheckState_Map_KnownValueWrongType(t *test
knownvalue.ListValueExact([]knownvalue.Check{}),
),
},
ExpectError: regexp.MustCompile(`expected \[\]any value for ListValue check, got: map\[string\]interface {}`),
ExpectError: regexp.MustCompile(`expected \[\]any value for ListValueExact check, got: map\[string\]interface {}`),
},
},
})
Expand Down Expand Up @@ -812,7 +812,7 @@ func TestExpectKnownOutputValueAtPath_CheckState_Map_KnownValueWrongValue(t *tes
}),
),
},
ExpectError: regexp.MustCompile(`missing element key3 for MapValue check`),
ExpectError: regexp.MustCompile(`missing element key3 for MapValueExact check`),
},
},
})
Expand Down Expand Up @@ -844,7 +844,7 @@ func TestExpectKnownOutputValueAtPath_CheckState_MapPartial(t *testing.T) {
statecheck.ExpectKnownOutputValueAtPath(
"test_resource_one_output",
tfjsonpath.New("map_attribute"),
knownvalue.MapValuePartialMatch(map[string]knownvalue.Check{
knownvalue.MapValuePartial(map[string]knownvalue.Check{
"key1": knownvalue.StringValueExact("value1"),
}),
),
Expand Down Expand Up @@ -880,7 +880,7 @@ func TestExpectKnownOutputValueAtPath_CheckState_MapPartial_KnownValueWrongValue
statecheck.ExpectKnownOutputValueAtPath(
"test_resource_one_output",
tfjsonpath.New("map_attribute"),
knownvalue.MapValuePartialMatch(map[string]knownvalue.Check{
knownvalue.MapValuePartial(map[string]knownvalue.Check{
"key3": knownvalue.StringValueExact("value1"),
}),
),
Expand Down Expand Up @@ -954,7 +954,7 @@ func TestExpectKnownOutputValueAtPath_CheckState_MapElements_WrongNum(t *testing
knownvalue.MapElementsExact(3),
),
},
ExpectError: regexp.MustCompile("expected 3 elements for MapElements check, got 2 elements"),
ExpectError: regexp.MustCompile("expected 3 elements for MapElementsExact check, got 2 elements"),
},
},
})
Expand Down Expand Up @@ -1029,7 +1029,7 @@ func TestExpectKnownOutputValueAtPath_CheckState_Number_KnownValueWrongValue(t *
knownvalue.NumberValueExact(f),
),
},
ExpectError: regexp.MustCompile("expected value 321 for NumberValue check, got: 123"),
ExpectError: regexp.MustCompile("expected value 321 for NumberValueExact check, got: 123"),
},
},
})
Expand Down Expand Up @@ -1104,7 +1104,7 @@ func TestExpectKnownOutputValueAtPath_CheckState_Set_KnownValueWrongValue(t *tes
}),
),
},
ExpectError: regexp.MustCompile(`missing value value3 for SetValue check`),
ExpectError: regexp.MustCompile(`missing value value3 for SetValueExact check`),
},
},
})
Expand Down Expand Up @@ -1136,7 +1136,7 @@ func TestExpectKnownOutputValueAtPath_CheckState_SetPartial(t *testing.T) {
statecheck.ExpectKnownOutputValueAtPath(
"test_resource_one_output",
tfjsonpath.New("set_attribute"),
knownvalue.SetValuePartialMatch([]knownvalue.Check{
knownvalue.SetValuePartial([]knownvalue.Check{
knownvalue.StringValueExact("value2"),
}),
),
Expand Down Expand Up @@ -1172,7 +1172,7 @@ func TestExpectKnownOutputValueAtPath_CheckState_SetPartial_KnownValueWrongValue
statecheck.ExpectKnownOutputValueAtPath(
"test_resource_one_output",
tfjsonpath.New("set_attribute"),
knownvalue.SetValuePartialMatch([]knownvalue.Check{
knownvalue.SetValuePartial([]knownvalue.Check{
knownvalue.StringValueExact("value3"),
}),
),
Expand Down Expand Up @@ -1288,7 +1288,7 @@ func TestExpectKnownOutputValueAtPath_CheckState_SetNestedBlockPartial(t *testin
statecheck.ExpectKnownOutputValueAtPath(
"test_resource_one_output",
tfjsonpath.New("set_nested_block"),
knownvalue.SetValuePartialMatch([]knownvalue.Check{
knownvalue.SetValuePartial([]knownvalue.Check{
knownvalue.MapValueExact(map[string]knownvalue.Check{
"set_nested_block_attribute": knownvalue.StringValueExact("rts"),
}),
Expand Down Expand Up @@ -1391,7 +1391,7 @@ func TestExpectKnownOutputValueAtPath_CheckState_String_KnownValueWrongType(t *t
tfjsonpath.New("string_attribute"),
knownvalue.BoolValueExact(true)),
},
ExpectError: regexp.MustCompile("expected bool value for BoolValue check, got: string"),
ExpectError: regexp.MustCompile("expected bool value for BoolValueExact check, got: string"),
},
},
})
Expand Down Expand Up @@ -1422,7 +1422,7 @@ func TestExpectKnownOutputValueAtPath_CheckState_String_KnownValueWrongValue(t *
tfjsonpath.New("string_attribute"),
knownvalue.StringValueExact("rts")),
},
ExpectError: regexp.MustCompile("expected value rts for StringValue check, got: str"),
ExpectError: regexp.MustCompile("expected value rts for StringValueExact check, got: str"),
},
},
})
Expand All @@ -1449,7 +1449,7 @@ func TestExpectKnownOutputValueAtPath_CheckState_UnknownAttributeType(t *testing
},
},
},
expectedErr: fmt.Errorf("expected json.Number value for Int64Value check, got: float32"),
expectedErr: fmt.Errorf("expected json.Number value for Int64ValueExact check, got: float32"),
},
}

Expand Down
Loading

0 comments on commit fb9fed8

Please sign in to comment.