Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
yaronya committed Aug 13, 2024
1 parent 49ed41e commit 35d7fcb
Showing 1 changed file with 5 additions and 17 deletions.
22 changes: 5 additions & 17 deletions env0/data_environment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,6 @@ func TestEnvironmentDataSource(t *testing.T) {
},
}

otherEnvironment := client.Environment{
Id: "other-id",
Name: "other-name",
}

environmentWithSameName := client.Environment{
Id: "other-id",
Name: environment.Name,
Expand Down Expand Up @@ -126,21 +121,21 @@ func TestEnvironmentDataSource(t *testing.T) {
t.Run("By Name", func(t *testing.T) {
runUnitTest(t,
getValidTestCase(environmentFieldsByName),
mockListEnvironmentsCall([]client.Environment{environment, otherEnvironment}, &template),
mockListEnvironmentsCall([]client.Environment{environment}, &template),
)
})

t.Run("By Name with Archived", func(t *testing.T) {
runUnitTest(t,
getValidTestCase(environmentFieldsByNameWithExclude),
mockListEnvironmentsCall([]client.Environment{environment, archivedEnvironment, otherEnvironment}, &template),
mockListEnvironmentsCall([]client.Environment{environment, archivedEnvironment}, &template),
)
})

t.Run("By Name with Different Project Id", func(t *testing.T) {
runUnitTest(t,
getValidTestCase(environmentFieldByNameWithProjectId),
mockListEnvironmentsCall([]client.Environment{environment, environmentWithSameName, otherEnvironment}, &template),
mockListEnvironmentsCall([]client.Environment{environment, environmentWithSameName}, &template),
)
})

Expand All @@ -154,14 +149,14 @@ func TestEnvironmentDataSource(t *testing.T) {
t.Run("Throw error when by name and more than one environment exists", func(t *testing.T) {
runUnitTest(t,
getErrorTestCase(environmentFieldsByName, "Found multiple environments for name"),
mockListEnvironmentsCall([]client.Environment{environment, environment, otherEnvironment}, nil),
mockListEnvironmentsCall([]client.Environment{environment, environment}, nil),
)
})

t.Run("Throw error when by name and more than one environment exists (archived use-case)", func(t *testing.T) {
runUnitTest(t,
getErrorTestCase(environmentFieldsByName, "Found multiple environments for name"),
mockListEnvironmentsCall([]client.Environment{environment, archivedEnvironment, otherEnvironment}, nil),
mockListEnvironmentsCall([]client.Environment{environment, archivedEnvironment}, nil),
)
})

Expand All @@ -171,11 +166,4 @@ func TestEnvironmentDataSource(t *testing.T) {
mockListEnvironmentsCall([]client.Environment{}, nil),
)
})

t.Run("Throw error when by name and no environments found with that name", func(t *testing.T) {
runUnitTest(t,
getErrorTestCase(environmentFieldsByName, "Could not find an env0 environment with name"),
mockListEnvironmentsCall([]client.Environment{otherEnvironment}, nil),
)
})
}

0 comments on commit 35d7fcb

Please sign in to comment.