Skip to content

Commit f1b6c35

Browse files
Kelsi HoyleKelsi Hoyle
authored andcommitted
move arch update to its own test
1 parent 7c45d69 commit f1b6c35

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

admin_terraform_version_integration_test.go

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,8 @@ func TestAdminTerraformVersions_ReadUpdate(t *testing.T) {
212212
client := testClient(t)
213213
ctx := context.Background()
214214

215+
var id string
216+
215217
t.Run("reads and updates", func(t *testing.T) {
216218
version := genSafeRandomTerraformVersion()
217219
sha := String(genSha(t))
@@ -233,7 +235,7 @@ func TestAdminTerraformVersions_ReadUpdate(t *testing.T) {
233235
}
234236
tfv, err := client.Admin.TerraformVersions.Create(ctx, opts)
235237
require.NoError(t, err)
236-
id := tfv.ID
238+
id = tfv.ID
237239

238240
defer func() {
239241
deleteErr := client.Admin.TerraformVersions.Delete(ctx, id)
@@ -270,11 +272,13 @@ func TestAdminTerraformVersions_ReadUpdate(t *testing.T) {
270272
assert.Equal(t, *updateOpts.Deprecated, tfv.Deprecated)
271273
assert.Equal(t, *opts.Enabled, tfv.Enabled)
272274
assert.Equal(t, *opts.Beta, tfv.Beta)
275+
})
273276

274-
// Update using Archs
275-
anotherUpdateVersion := genSafeRandomTerraformVersion()
277+
t.Run("update with Archs", func(t *testing.T) {
278+
updateVersion := genSafeRandomTerraformVersion()
279+
sha := String(genSha(t))
276280
updateArchOpts := AdminTerraformVersionUpdateOptions{
277-
Version: String(anotherUpdateVersion),
281+
Version: String(updateVersion),
278282
Deprecated: Bool(false),
279283
Archs: []*ToolVersionArchitectureOptions{{
280284
URL: "https://www.hashicorp.com",
@@ -284,15 +288,15 @@ func TestAdminTerraformVersions_ReadUpdate(t *testing.T) {
284288
}},
285289
}
286290

287-
tfv, err = client.Admin.TerraformVersions.Update(ctx, id, updateArchOpts)
291+
tfv, err := client.Admin.TerraformVersions.Update(ctx, id, updateArchOpts)
288292
require.NoError(t, err)
289293

290294
assert.Equal(t, len(tfv.Archs), 1)
291295
assert.Equal(t, updateArchOpts.Archs[0].URL, tfv.Archs[0].URL)
292296
assert.Equal(t, updateArchOpts.Archs[0].Sha, tfv.Archs[0].Sha)
293297
assert.Equal(t, updateArchOpts.Archs[0].OS, tfv.Archs[0].OS)
294298
assert.Equal(t, updateArchOpts.Archs[0].Arch, tfv.Archs[0].Arch)
295-
assert.Equal(t, anotherUpdateVersion, tfv.Version)
299+
assert.Equal(t, updateVersion, tfv.Version)
296300
})
297301

298302
t.Run("with non-existent terraform version", func(t *testing.T) {

0 commit comments

Comments
 (0)