From c49eb952e135ea563156f7b46b9d8c50e9f6f30c Mon Sep 17 00:00:00 2001 From: Vincent Demeester Date: Thu, 25 Jan 2024 15:00:14 +0100 Subject: [PATCH] Add testdata to fix unit tests Signed-off-by: Vincent Demeester --- internal/contract/contract_test.go | 4 +- internal/linter/linter_test.go | 2 +- internal/render/markdown_test.go | 2 +- testdata/resources/.catalog.yaml | 17 +++++++ testdata/resources/task.yaml | 76 ++++++++++++++++++++++++++++++ 5 files changed, 97 insertions(+), 4 deletions(-) create mode 100644 testdata/resources/.catalog.yaml create mode 100644 testdata/resources/task.yaml diff --git a/internal/contract/contract_test.go b/internal/contract/contract_test.go index a9943c5c..809028f7 100644 --- a/internal/contract/contract_test.go +++ b/internal/contract/contract_test.go @@ -50,13 +50,13 @@ func TestNewContractFromFile(t *testing.T) { g := o.NewWithT(t) t.Run("Filename", func(_ *testing.T) { - c, err := NewContractFromFile("../../test/resources/.catalog.yaml") + c, err := NewContractFromFile("../../testdata/resources/.catalog.yaml") g.Expect(err).To(o.BeNil()) g.Expect(c.Catalog.Resources).ToNot(o.BeNil()) }) t.Run("Directory", func(_ *testing.T) { - c, err := NewContractFromFile("../../test/resources") + c, err := NewContractFromFile("../../testdata/resources") g.Expect(err).To(o.BeNil()) g.Expect(c.Catalog.Resources).ToNot(o.BeNil()) }) diff --git a/internal/linter/linter_test.go b/internal/linter/linter_test.go index 8395db64..a2bea3c6 100644 --- a/internal/linter/linter_test.go +++ b/internal/linter/linter_test.go @@ -13,7 +13,7 @@ func TestNewLinter(t *testing.T) { cfg := config.NewConfig() - l, err := NewLinter(cfg, "../../test/resources/task.yaml") + l, err := NewLinter(cfg, "../../testdata/resources/task.yaml") g.Expect(err).To(o.Succeed()) g.Expect(l).NotTo(o.BeNil()) diff --git a/internal/render/markdown_test.go b/internal/render/markdown_test.go index 5399a95a..9eb1ea25 100644 --- a/internal/render/markdown_test.go +++ b/internal/render/markdown_test.go @@ -12,7 +12,7 @@ func TestNewMarkdow(t *testing.T) { cfg := config.NewConfig() - m, err := NewMarkdown(cfg, "../../test/resources/task.yaml") + m, err := NewMarkdown(cfg, "../../testdata/resources/task.yaml") g.Expect(err).To(o.Succeed()) g.Expect(m).NotTo(o.BeNil()) diff --git a/testdata/resources/.catalog.yaml b/testdata/resources/.catalog.yaml new file mode 100644 index 00000000..3641884d --- /dev/null +++ b/testdata/resources/.catalog.yaml @@ -0,0 +1,17 @@ +version: v1 +catalog: + repository: + description: "" + attestation: + publickey: "" + resources: + tasks: + - name: task + version: 0.0.1 + filename: ../../test/resources/task.yaml + checksum: f2d507741e983223beb94b5411264004e8d2cbbf0326a716c8313002e505e706 + signature: "" + pipelines: [] + probe: + tasks: [] + pipelines: [] diff --git a/testdata/resources/task.yaml b/testdata/resources/task.yaml new file mode 100644 index 00000000..5b0a1682 --- /dev/null +++ b/testdata/resources/task.yaml @@ -0,0 +1,76 @@ +--- +apiVersion: tekton.dev/v1beta1 +kind: Task +metadata: + name: task +spec: + description: | + Task description. + + workspaces: + - name: required-workspace + description: | + Workspace "required-workspace" description. + - name: optional-workspace + optional: true + description: | + Workspace "optional-workspace" description. + + params: + - name: STRING_PARAM + type: string + description: | + String parameter description. + - name: STRING_PARAM_EMPTY + type: string + default: "" + description: | + String parameter description. + - name: STRING_PARAM_WITH_DEFAULT + type: string + default: default + description: | + String parameter description. + - name: ARRAY_PARAM + type: array + description: | + Array parameter description. + - name: ARRAY_PARAM_EMPTY + type: array + default: [] + description: | + Array parameter description. + - name: ARRAY_PARAM_WITH_DEFAULT + type: array + default: + - entry + description: | + Array parameter description. + - name: OBJECT_PARAM + type: object + description: | + Object parameter description. + - name: OBJECT_PARAM_EMPTY + type: object + properties: + key: + type: string + default: + key: "" + description: | + Object parameter description. + - name: OBJECT_PARAM_WITH_DEFAULT + type: object + properties: + key: + type: string + default: + key: value + description: | + Object parameter description. + + + results: + - name: RESULT + description: | + Result description.