Skip to content

Commit

Permalink
add filter to data_project in byName func and update the tests (#210)
Browse files Browse the repository at this point in the history
  • Loading branch information
samuel-br committed Jan 23, 2022
1 parent f4e846f commit 88c1e7d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion env0/data_project.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func getProjectByName(name interface{}, meta interface{}) (client.Project, diag.

projectsByName := make([]client.Project, 0)
for _, candidate := range projects {
if candidate.Name == name.(string) {
if candidate.Name == name.(string) && !candidate.IsArchived {
projectsByName = append(projectsByName, candidate)
}
}
Expand Down
11 changes: 10 additions & 1 deletion env0/data_project_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@ func TestProjectDataSource(t *testing.T) {
Description: "A project's description",
}

archivedProject := client.Project{
Id: "otherId",
Name: project.Name,
CreatedBy: project.CreatedBy,
Role: project.Role,
Description: project.Description,
IsArchived: true,
}

projectDataByName := map[string]interface{}{"name": project.Name}
projectDataById := map[string]interface{}{"id": project.Id}

Expand Down Expand Up @@ -74,7 +83,7 @@ func TestProjectDataSource(t *testing.T) {
t.Run("By Name", func(t *testing.T) {
runUnitTest(t,
getValidTestCase(projectDataByName),
mockListProjectsCall([]client.Project{project}),
mockListProjectsCall([]client.Project{project, archivedProject}),
)
})

Expand Down

0 comments on commit 88c1e7d

Please sign in to comment.