2022-02-23 10:30:19 +02:00
|
|
|
//go:build integration
|
2020-02-18 16:19:50 +02:00
|
|
|
// +build integration
|
2022-02-23 10:30:19 +02:00
|
|
|
|
2022-09-19 12:47:13 +02:00
|
|
|
// can be executed with
|
|
|
|
// go test -v -tags integration -run TestAPICLIIntegration ./integration/...
|
2020-02-18 16:19:50 +02:00
|
|
|
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"os"
|
|
|
|
"path/filepath"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
"github.com/testcontainers/testcontainers-go"
|
|
|
|
)
|
|
|
|
|
2022-09-19 12:47:13 +02:00
|
|
|
func TestDummyIntegration(t *testing.T) {
|
2020-02-18 16:19:50 +02:00
|
|
|
t.Skip("Skipping testing - this is just to show how it can be done")
|
|
|
|
ctx := context.Background()
|
|
|
|
|
|
|
|
dir, err := os.Getwd()
|
|
|
|
assert.NoError(t, err, "Getting current working directory failed.")
|
|
|
|
dir = filepath.Dir(dir)
|
|
|
|
|
|
|
|
req := testcontainers.ContainerRequest{
|
|
|
|
Image: "node:lts-stretch",
|
|
|
|
Cmd: []string{"tail", "-f"},
|
|
|
|
BindMounts: map[string]string{dir: "/data"},
|
|
|
|
//ToDo: we may set up a tmp directory and mount it in addition, e.g. for runtime artifacts ...
|
|
|
|
}
|
|
|
|
|
|
|
|
testContainer, err := testcontainers.GenericContainer(ctx, testcontainers.GenericContainerRequest{
|
|
|
|
ContainerRequest: req,
|
|
|
|
Started: true,
|
|
|
|
})
|
|
|
|
assert.NoError(t, err)
|
|
|
|
|
|
|
|
piperOptions := []string{
|
|
|
|
"<piperStep>",
|
|
|
|
"-- <piperFlag1>",
|
|
|
|
"<piperFlag1Value>",
|
|
|
|
"...",
|
|
|
|
"--noTelemetry",
|
|
|
|
}
|
|
|
|
|
|
|
|
code, err := testContainer.Exec(ctx, append([]string{"/data/piper"}, piperOptions...))
|
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.Equal(t, 0, code)
|
|
|
|
}
|