Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing import tests #399

Merged
merged 1 commit into from
Feb 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 22 additions & 0 deletions grafana/resource_organization_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,22 @@ func TestAccOrganization_basic(t *testing.T) {
),
),
},
{
ResourceName: "grafana_organization.test",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"admins", "admin_user", "create_users"}, // Users are imported explicitly (with create_users == false)
ImportStateCheck: func(s []*terraform.InstanceState) error {
if len(s) != 1 {
return fmt.Errorf("expected 1 state: %#v", s)
}
admin := s[0].Attributes["admins.0"]
if admin != "admin@localhost" {
return fmt.Errorf("expected admin@localhost: %s", admin)
}
return nil
},
},
},
})
}
Expand Down Expand Up @@ -168,6 +184,12 @@ func TestAccOrganization_defaultAdmin(t *testing.T) {
),
),
},
{
ResourceName: "grafana_organization.test",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"admin_user", "create_user"}, // These are provider-side attributes and aren't returned by the API
},
},
})
}
Expand Down
1 change: 1 addition & 0 deletions grafana/resource_team.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ func ReadTeam(ctx context.Context, d *schema.ResourceData, meta interface{}) dia
if err != nil {
return diag.FromErr(err)
}
d.Set("team_id", teamID)
d.Set("name", resp.Name)
if resp.Email != "" {
d.Set("email", resp.Email)
Expand Down
11 changes: 11 additions & 0 deletions grafana/resource_team_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ func TestAccTeam_basic(t *testing.T) {
),
),
},
{
ResourceName: "grafana_team.test",
ImportState: true,
ImportStateVerify: true,
},
},
})
}
Expand Down Expand Up @@ -97,6 +102,12 @@ func TestAccTeam_Members(t *testing.T) {
),
),
},
// Test the import with members
{
ResourceName: "grafana_team.test",
ImportState: true,
ImportStateVerify: true,
},
{
Config: testAccTeamConfig_memberRemove,
Check: resource.ComposeTestCheckFunc(
Expand Down
6 changes: 6 additions & 0 deletions grafana/resource_user_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@ func TestAccUser_basic(t *testing.T) {
),
),
},
{
ResourceName: "grafana_user.test",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"password"},
},
},
})
}
Expand Down