Skip to content

Commit

Permalink
import tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lajos88 committed Oct 13, 2020
1 parent 81dcaf6 commit 356b9e5
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
5 changes: 5 additions & 0 deletions configcat/resource_setting_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
},
})
}
Expand Down
12 changes: 6 additions & 6 deletions configcat/resource_setting_value.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
},
Expand Down Expand Up @@ -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
}
5 changes: 5 additions & 0 deletions configcat/resource_setting_value_bool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,11 @@ func TestResourceSettingValueExistingNoFreeze(t *testing.T) {
checkFalseValue,
),
},
resource.TestStep{
ResourceName: "configcat_setting_value.test",
ImportState: true,
ImportStateVerify: true,
},
},
})
}
Expand Down

0 comments on commit 356b9e5

Please sign in to comment.