Skip to content

Commit

Permalink
Clean up and add testcontainer
Browse files Browse the repository at this point in the history
  • Loading branch information
UnstoppableMango committed Jun 27, 2024
1 parent 458a7f1 commit 2b8318b
Show file tree
Hide file tree
Showing 11 changed files with 4,683 additions and 102 deletions.
3 changes: 2 additions & 1 deletion examples/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.pulumi/
**/bin/
node_modules/

package-lock.json
yarn.lock
34 changes: 34 additions & 0 deletions examples/examples_nodejs_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package examples

import (
"path/filepath"
"testing"

"github.com/pulumi/pulumi/pkg/v3/testing/integration"
"github.com/stretchr/testify/require"
)

func TestSimpleTs(t *testing.T) {
require.NoError(t, startNodes(t), "failed to start docker nodes")

test := getJSBaseOptions(t).With(integration.ProgramTestOptions{
Dir: filepath.Join(getCwd(t), "typescript"),
Config: map[string]string{
"name": "exampleCluster",
"endpoint": "https://cluster.local:6443",
"node0": "10.6.0.2",
},
})
integration.ProgramTest(t, &test)
}

func getJSBaseOptions(t *testing.T) integration.ProgramTestOptions {
base := getBaseOptions(t)
baseJS := base.With(integration.ProgramTestOptions{
Dependencies: []string{
"@pulumiverse/talos",
},
})

return baseJS
}
35 changes: 34 additions & 1 deletion examples/examples_test.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
package examples

import (
"context"
"os"
"path/filepath"
"testing"

"github.com/stretchr/testify/require"
tc "github.com/testcontainers/testcontainers-go"
tcc "github.com/testcontainers/testcontainers-go/modules/compose"

"github.com/pulumi/pulumi/pkg/v3/testing/integration"
)

Expand All @@ -16,9 +22,36 @@ func getCwd(t *testing.T) string {
return cwd
}

func getBaseOptions() integration.ProgramTestOptions {
func getBaseOptions(t *testing.T) integration.ProgramTestOptions {
return integration.ProgramTestOptions{
RunUpdateTest: false,
ExpectRefreshChanges: true,
LocalProviders: []integration.LocalDependency{{
Package: "talos",
Path: filepath.Join(getCwd(t), "..", "bin"),
}},
}
}

func startNodes(t *testing.T) error {
composePath := filepath.Join(getCwd(t), "testdata", "docker-compose.yaml")
compose, err := tcc.NewDockerComposeWith(
tcc.WithStackFiles(composePath),
tcc.WithLogger(tc.TestLogger(t)),
)
require.NoError(t, err)

t.Cleanup(func() {
err := compose.Down(context.Background(),
tcc.RemoveOrphans(true),
tcc.RemoveImagesLocal,
tcc.RemoveVolumes(true),
)
require.NoError(t, err)
})

ctx, cancel := context.WithCancel(context.Background())
t.Cleanup(cancel)

return compose.Up(ctx, tcc.Wait(true))
}
24 changes: 0 additions & 24 deletions examples/examples_typescript_test.go

This file was deleted.

23 changes: 0 additions & 23 deletions examples/examples_yaml_test.go

This file was deleted.

Loading

0 comments on commit 2b8318b

Please sign in to comment.