From 356b9e599e13bda7b9b6e670121f65533353b3f1 Mon Sep 17 00:00:00 2001 From: Lajos Date: Tue, 13 Oct 2020 23:58:10 +0200 Subject: [PATCH] import tests --- configcat/resource_setting_test.go | 5 +++++ configcat/resource_setting_value.go | 12 ++++++------ configcat/resource_setting_value_bool_test.go | 5 +++++ 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/configcat/resource_setting_test.go b/configcat/resource_setting_test.go index 9b82cacb..c7c51a85 100644 --- a/configcat/resource_setting_test.go +++ b/configcat/resource_setting_test.go @@ -97,6 +97,11 @@ func testResourceSettingForSettingType(t *testing.T, settingType string) { resource.TestCheckResourceAttr("configcat_setting.testBoolean", SETTING_TYPE, settingType), ), }, + resource.TestStep{ + ResourceName: "configcat_setting.testBoolean", + ImportState: true, + ImportStateVerify: true, + }, }, }) } diff --git a/configcat/resource_setting_value.go b/configcat/resource_setting_value.go index d6f1a8e4..1e4cedd6 100644 --- a/configcat/resource_setting_value.go +++ b/configcat/resource_setting_value.go @@ -30,7 +30,7 @@ func resourceConfigCatSettingValue() *schema.Resource { d.Set(SETTING_ID, settingID) d.Set(ENVIRONMENT_ID, environmentID) d.Set(INIT_ONLY, false) - d.SetId(fmt.Sprintf("%s:%d", environmentID, settingID)) + d.SetId(fmt.Sprintf("%s:%s", environmentID, settingID)) return []*schema.ResourceData{d}, nil }, @@ -445,17 +445,17 @@ func getComparator(comparator string) (*sw.RolloutRuleComparator, error) { return nil, fmt.Errorf("could not parse Comparator: %s", comparator) } -func resourceConfigCatSettingValueParseId(id string) (string, int32, error) { +func resourceConfigCatSettingValueParseId(id string) (string, string, error) { parts := strings.SplitN(id, ":", 2) if len(parts) != 2 || parts[0] == "" || parts[1] == "" { - return "", 0, fmt.Errorf("unexpected format of ID (%s), expected environmentID.settingID", id) + return "", "", fmt.Errorf("unexpected format of ID (%s), expected environmentID.settingID", id) } - settingID, err := strconv.ParseInt(parts[1], 10, 32) + _, err := strconv.ParseInt(parts[1], 10, 32) if err != nil { - return "", 0, fmt.Errorf("unexpected format of ID (%s), expected environmentID.settingID. Error: %s", id, err) + return "", "", fmt.Errorf("unexpected format of ID (%s), expected environmentID.settingID. Error: %s", id, err) } - return parts[0], int32(settingID), nil + return parts[0], parts[1], nil } diff --git a/configcat/resource_setting_value_bool_test.go b/configcat/resource_setting_value_bool_test.go index a14abd83..974a5f64 100644 --- a/configcat/resource_setting_value_bool_test.go +++ b/configcat/resource_setting_value_bool_test.go @@ -98,6 +98,11 @@ func TestResourceSettingValueExistingNoFreeze(t *testing.T) { checkFalseValue, ), }, + resource.TestStep{ + ResourceName: "configcat_setting_value.test", + ImportState: true, + ImportStateVerify: true, + }, }, }) }