@@ -14,8 +14,6 @@ import (
14
14
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
15
15
)
16
16
17
- // TODO: change this to only test for a non-existent image.
18
- // Move the heavy lifting to integration.
19
17
func TestAccCachedImageDataSource (t * testing.T ) {
20
18
t .Run ("Found" , func (t * testing.T ) {
21
19
ctx , cancel := context .WithTimeout (context .Background (), 5 * time .Minute )
@@ -28,23 +26,13 @@ func TestAccCachedImageDataSource(t *testing.T) {
28
26
29
27
deps := setup (ctx , t , files )
30
28
seedCache (ctx , t , deps )
31
- tfCfg := fmt .Sprintf (`resource "envbuilder_cached_image" "test" {
32
- builder_image = %q
33
- workspace_folder = %q
34
- git_url = %q
35
- git_ssh_private_key_path = %q
36
- extra_env = {
37
- "FOO" : "bar"
38
- }
39
- cache_repo = %q
40
- verbose = true
41
- }` , deps .BuilderImage , deps .Repo .Dir , deps .Repo .URL , deps .Repo .Key , deps .CacheRepo )
29
+ deps .ExtraEnv ["FOO" ] = "bar"
42
30
resource .Test (t , resource.TestCase {
43
31
PreCheck : func () { testAccPreCheck (t ) },
44
32
ProtoV6ProviderFactories : testAccProtoV6ProviderFactories ,
45
33
Steps : []resource.TestStep {
46
34
{
47
- Config : tfCfg ,
35
+ Config : deps . Config ( t ) ,
48
36
Check : resource .ComposeAggregateTestCheckFunc (
49
37
// Inputs should still be present.
50
38
resource .TestCheckResourceAttr ("envbuilder_cached_image.test" , "cache_repo" , deps .CacheRepo ),
@@ -89,24 +77,14 @@ func TestAccCachedImageDataSource(t *testing.T) {
89
77
RUN date > /date.txt` ,
90
78
}
91
79
deps := setup (ctx , t , files )
80
+ deps .ExtraEnv ["FOO" ] = "bar"
92
81
// We do not seed the cache.
93
- tfCfg := fmt .Sprintf (`resource "envbuilder_cached_image" "test" {
94
- builder_image = %q
95
- workspace_folder = %q
96
- git_url = %q
97
- git_ssh_private_key_path = %q
98
- extra_env = {
99
- "FOO" : "bar"
100
- }
101
- cache_repo = %q
102
- verbose = true
103
- }` , deps .BuilderImage , deps .Repo .Dir , deps .Repo .URL , deps .Repo .Key , deps .CacheRepo )
104
82
resource .Test (t , resource.TestCase {
105
83
PreCheck : func () { testAccPreCheck (t ) },
106
84
ProtoV6ProviderFactories : testAccProtoV6ProviderFactories ,
107
85
Steps : []resource.TestStep {
108
86
{
109
- Config : tfCfg ,
87
+ Config : deps . Config ( t ) ,
110
88
Check : resource .ComposeAggregateTestCheckFunc (
111
89
// Computed values MUST be present.
112
90
resource .TestCheckResourceAttr ("envbuilder_cached_image.test" , "id" , uuid .Nil .String ()),
0 commit comments