Skip to content

Commit 29dfeae

Browse files
mjyoccajpogran-hashi
authored andcommitted
chore: update testdata with separate bundle
1 parent 63e2ed9 commit 29dfeae

File tree

9 files changed

+101
-62
lines changed

9 files changed

+101
-62
lines changed

internal/stacks/stackconfig/config_test.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -286,31 +286,32 @@ func TestOmittingBuiltInProviders(t *testing.T) {
286286
}
287287

288288
func TestComponentSourceResolution(t *testing.T) {
289-
bundle, err := sourcebundle.OpenDir("testdata/basics-bundle")
289+
stackResourceName := "pet-nulls"
290+
bundle, err := sourcebundle.OpenDir("testdata/embedded-stack-bundle")
290291
if err != nil {
291292
t.Fatal(err)
292293
}
293294

294-
rootAddr := sourceaddrs.MustParseSource("git::https://example.com/component-test.git").(sourceaddrs.RemoteSource)
295+
rootAddr := sourceaddrs.MustParseSource("git::https://example.com/root.git").(sourceaddrs.RemoteSource)
295296
config, diags := LoadConfigDir(rootAddr, bundle)
296297
if len(diags) != 0 {
297298
t.Fatalf("unexpected diagnostics:\n%s", diags.NonFatalErr().Error())
298299
}
299300

300301
t.Run("component source resolution", func(t *testing.T) {
301302
// Verify that the component was loaded
302-
if got, want := len(config.Root.Stack.Components), 1; got != want {
303+
if got, want := len(config.Root.Stack.EmbeddedStacks), 1; got != want {
303304
t.Errorf("wrong number of components %d; want %d", got, want)
304305
}
305306

306307
t.Run("pet-nulls component", func(t *testing.T) {
307-
cmpn, ok := config.Root.Stack.Components["pet-nulls"]
308+
cmpn, ok := config.Root.Stack.EmbeddedStacks[stackResourceName]
308309
if !ok {
309-
t.Fatal("Root stack config has no component named \"pet-nulls\".")
310+
t.Fatalf("Root stack config has no component named %q.", stackResourceName)
310311
}
311312

312313
// Verify component name
313-
if got, want := cmpn.Name, "pet-nulls"; got != want {
314+
if got, want := cmpn.Name, stackResourceName; got != want {
314315
t.Errorf("wrong component name\ngot: %s\nwant: %s", got, want)
315316
}
316317

@@ -320,7 +321,7 @@ func TestComponentSourceResolution(t *testing.T) {
320321
t.Fatalf("expected ComponentSource, got %T", cmpn.SourceAddr)
321322
}
322323

323-
expectedSourceStr := "app.staging.terraform.io/component-configurations/pet-nulls"
324+
expectedSourceStr := "example.com/awesomecorp/tfstack-pet-nulls"
324325
if got := componentSource.String(); got != expectedSourceStr {
325326
t.Errorf("wrong source address\ngot: %s\nwant: %s", got, expectedSourceStr)
326327
}

internal/stacks/stackconfig/testdata/basics-bundle/component-test/main.tfcomponent.hcl

Lines changed: 0 additions & 9 deletions
This file was deleted.

internal/stacks/stackconfig/testdata/basics-bundle/component-test/variables.tfcomponent.hcl

Lines changed: 0 additions & 7 deletions
This file was deleted.

internal/stacks/stackconfig/testdata/basics-bundle/pet-nulls/main.tf

Lines changed: 0 additions & 15 deletions
This file was deleted.

internal/stacks/stackconfig/testdata/basics-bundle/terraform-sources.json

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,6 @@
3131
"local": "builtin",
3232
"meta": {}
3333
},
34-
{
35-
"source": "git::https://example.com/component-test.git",
36-
"local": "component-test",
37-
"meta": {}
38-
},
39-
{
40-
"source": "git::https://example.com/pet-nulls.git?ref=v0.0.2",
41-
"local": "pet-nulls",
42-
"meta": {}
43-
}
4434
],
4535
"registry": [
4636
{
@@ -54,18 +44,5 @@
5444
}
5545
}
5646
}
57-
],
58-
"components": [
59-
{
60-
"source": "app.staging.terraform.io/component-configurations/pet-nulls",
61-
"versions": {
62-
"0.0.1": {
63-
"source": "git::https://example.com/pet-nulls.git?ref=v0.0.1"
64-
},
65-
"0.0.2": {
66-
"source": "git::https://example.com/pet-nulls.git?ref=v0.0.2"
67-
}
68-
}
69-
}
7047
]
71-
}
48+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
variable "name" {
2+
type = string
3+
}
4+
5+
resource "null_resource" "example" {
6+
triggers = {
7+
name = var.name
8+
}
9+
}
10+
11+
output "greeting" {
12+
value = "Hello, ${var.name}!"
13+
}
14+
15+
output "resource_id" {
16+
value = null_resource.example.id
17+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
required_providers {
3+
null = {
4+
source = "hashicorp/null"
5+
version = "3.2.1"
6+
}
7+
}
8+
9+
variable "name" {
10+
type = string
11+
}
12+
13+
component "a" {
14+
source = "./a"
15+
16+
inputs = {
17+
name = var.name
18+
}
19+
providers = {
20+
null = var.provider
21+
}
22+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
required_providers {
2+
null = {
3+
source = "hashicorp/null"
4+
version = "3.2.1"
5+
}
6+
}
7+
8+
9+
stack "pet-nulls" {
10+
source = "example.com/awesomecorp/tfstack-pet-nulls"
11+
version = "0.0.2"
12+
13+
inputs = {
14+
name = var.name
15+
provider = provider.null.a
16+
}
17+
}
18+
19+
provider "null" "a" {
20+
}
21+
22+
locals {
23+
sound = "bleep bloop"
24+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"terraform_source_bundle": 1,
3+
"packages": [
4+
{
5+
"source": "git::https://example.com/root.git",
6+
"local": "root",
7+
"meta": {}
8+
},
9+
{
10+
"source": "git::https://example.com/pet-nulls.git?ref=0.0.2",
11+
"local": "component",
12+
"meta": {}
13+
}
14+
],
15+
"registry": [],
16+
"components": [
17+
{
18+
"source": "example.com/awesomecorp/tfstack-pet-nulls",
19+
"versions": {
20+
"0.0.1": {
21+
"source": "git::https://example.com/pet-nulls.git?ref=0.0.1"
22+
},
23+
"0.0.2": {
24+
"source": "git::https://example.com/pet-nulls.git?ref=0.0.2"
25+
}
26+
}
27+
}
28+
]
29+
}

0 commit comments

Comments
 (0)