36 lines
1.4 KiB
Go
36 lines
1.4 KiB
Go
package cli
|
|
|
|
import (
|
|
"bytes"
|
|
"path/filepath"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestConfigKitReadOnlyCommandsLoadImportsAndProfiles(t *testing.T) {
|
|
t.Parallel()
|
|
root := t.TempDir()
|
|
path := filepath.Join(root, "notarius.yml")
|
|
writeConfigKitFile(t, filepath.Join(root, "fragment.yml"), "pipelines:\n imported:\n input: {module: input}\n")
|
|
writeConfigKitFile(t, path, "version: 5\nconfigkit:\n imports:\n - path: fragment.yml\npipelines:\n base:\n input: {module: input}\n")
|
|
var stdout, stderr bytes.Buffer
|
|
if code := runConfigKitPipelinesList([]string{"--config", path}, &stdout, &stderr, commandContractOptions(t)); code != 0 || stdout.String() != "base\nimported\n" {
|
|
t.Fatalf("list = %d, %q, %q", code, stdout.String(), stderr.String())
|
|
}
|
|
stdout.Reset()
|
|
stderr.Reset()
|
|
if code := runConfigKitValidate([]string{"--config", path}, &stdout, &stderr, commandContractOptions(t)); code != 0 || !strings.Contains(stdout.String(), "is valid") {
|
|
t.Fatalf("validate = %d, %q, %q", code, stdout.String(), stderr.String())
|
|
}
|
|
}
|
|
|
|
func TestConfigKitReadOnlyCommandsRejectVersionFour(t *testing.T) {
|
|
t.Parallel()
|
|
path := filepath.Join(t.TempDir(), "notarius.yml")
|
|
writeConfigKitFile(t, path, "version: 4\n")
|
|
var stdout, stderr bytes.Buffer
|
|
if code := runConfigKitPipelinesList([]string{"--config", path}, &stdout, &stderr, commandContractOptions(t)); code != 1 || !strings.Contains(stderr.String(), "version") {
|
|
t.Fatalf("list = %d, %q", code, stderr.String())
|
|
}
|
|
}
|