From 64a0910ec848c3dd9b34068f162173677e5867a8 Mon Sep 17 00:00:00 2001 From: Mickael Stanislas Date: Thu, 6 Jul 2023 21:54:38 +0200 Subject: [PATCH] fix: Unit tests --- .github/workflows/goreport.yml | 11 +++++ .github/workflows/tests.yml | 42 ++++++++++++++++--- README.md | 7 ++++ internal/null_if_attribute_is_one_of_test.go | 8 ++-- .../require_if_attribute_is_one_of_test.go | 8 ++-- 5 files changed, 63 insertions(+), 13 deletions(-) create mode 100644 .github/workflows/goreport.yml diff --git a/.github/workflows/goreport.yml b/.github/workflows/goreport.yml new file mode 100644 index 0000000..6122182 --- /dev/null +++ b/.github/workflows/goreport.yml @@ -0,0 +1,11 @@ +name: Go Report Card Refresh + +on: + release: + types: [published] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: creekorful/goreportcard-action@v1.0 \ No newline at end of file diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 7ff1763..fe14142 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -15,19 +15,51 @@ permissions: contents: read jobs: - # Ensure project builds before running testing matrix lint: name: Lint runs-on: ubuntu-latest timeout-minutes: 5 steps: - - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 - - uses: actions/setup-go@6edd4406fa81c3da01a34fa6f6343087c207a568 # v3.5.0 + - uses: actions/checkout@v3 + - uses: actions/setup-go@v4 with: go-version-file: 'go.mod' cache: true - run: go mod download - name: Run linters - uses: golangci/golangci-lint-action@08e2f20817b15149a52b5b3ebe7de50aff2ba8c5 # v3.4.0 + uses: golangci/golangci-lint-action@v3 with: - version: latest \ No newline at end of file + version: latest + + coverage: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + go: + - '1.20' + - '1.19' + - '1.18' + steps: + - uses: actions/setup-go@v3 + with: + go-version: ${{ matrix.go }} + - uses: actions/checkout@v3 + - run: go test -v -coverprofile=profile.cov ./... + + - name: Send coverage + uses: shogo82148/actions-goveralls@v1 + with: + path-to-profile: profile.cov + flag-name: Go-${{ matrix.go }} + parallel: true + + # notifies that all test jobs are finished. + coverage-finish: + needs: coverage + runs-on: ubuntu-latest + steps: + - uses: shogo82148/actions-goveralls@v1 + with: + parallel-finished: true + diff --git a/README.md b/README.md index c73d79d..9e9cbd2 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,9 @@ Issues + + GoReport + # terraform-plugin-framework-validators @@ -27,4 +30,8 @@ go get github.com/FrangipaneTeam/terraform-plugin-framework-validators@latest ## Documentation +The documentation for the validators can be found [here](https://github.frangipane.io/terraform/validators/getting-started/). + +## Maintainers + This repository is maintained by the [Frangipane Team](https://github.com/FrangipaneTeam) diff --git a/internal/null_if_attribute_is_one_of_test.go b/internal/null_if_attribute_is_one_of_test.go index d958616..425c357 100644 --- a/internal/null_if_attribute_is_one_of_test.go +++ b/internal/null_if_attribute_is_one_of_test.go @@ -58,7 +58,7 @@ func TestNullIfAttributeIsOneOfValidator(t *testing.T) { types.StringValue("excepted value"), }, expError: true, - expErrorMessage: "If foo attribute is set and the value is one of \"excepted value\", this attribute is null", + expErrorMessage: "If foo attribute is set and the value is one of \"excepted value\", this attribute is NULL", }, "extendedString": { req: internal.NullIfAttributeIsOneOfRequest{ @@ -124,7 +124,7 @@ func TestNullIfAttributeIsOneOfValidator(t *testing.T) { types.StringValue("bar1 excepted value"), }, expError: true, - expErrorMessage: "If foobar[0].bar1 attribute is set and the value is one of \"bar1 excepted value\", this attribute is null", + expErrorMessage: "If foobar[0].bar1 attribute is set and the value is one of \"bar1 excepted value\", this attribute is NULL", }, "baseInt64": { req: internal.NullIfAttributeIsOneOfRequest{ @@ -155,7 +155,7 @@ func TestNullIfAttributeIsOneOfValidator(t *testing.T) { types.Int64Value(10), }, expError: true, - expErrorMessage: "If foo attribute is set and the value is one of 10, this attribute is null", + expErrorMessage: "If foo attribute is set and the value is one of 10, this attribute is NULL", }, "baseBool": { req: internal.NullIfAttributeIsOneOfRequest{ @@ -186,7 +186,7 @@ func TestNullIfAttributeIsOneOfValidator(t *testing.T) { types.BoolValue(true), }, expError: true, - expErrorMessage: "If foo attribute is set and the value is one of true, this attribute is null", + expErrorMessage: "If foo attribute is set and the value is one of true, this attribute is NULL", }, "path-attribute-is-null": { req: internal.NullIfAttributeIsOneOfRequest{ diff --git a/internal/require_if_attribute_is_one_of_test.go b/internal/require_if_attribute_is_one_of_test.go index b158eb5..83549c4 100644 --- a/internal/require_if_attribute_is_one_of_test.go +++ b/internal/require_if_attribute_is_one_of_test.go @@ -58,7 +58,7 @@ func TestRequireIfAttributeIsOneOfValidator(t *testing.T) { types.StringValue("excepted value"), }, expError: true, - expErrorMessage: "If foo attribute is set and the value is one of \"excepted value\", this attribute is required", + expErrorMessage: "If foo attribute is set and the value is one of \"excepted value\", this attribute is REQUIRED", }, "extendedString": { req: internal.RequireIfAttributeIsOneOfRequest{ @@ -124,7 +124,7 @@ func TestRequireIfAttributeIsOneOfValidator(t *testing.T) { types.StringValue("bar1 excepted value"), }, expError: true, - expErrorMessage: "If foobar[0].bar1 attribute is set and the value is one of \"bar1 excepted value\", this attribute is required", + expErrorMessage: "If foobar[0].bar1 attribute is set and the value is one of \"bar1 excepted value\", this attribute is REQUIRED", }, "baseInt64": { req: internal.RequireIfAttributeIsOneOfRequest{ @@ -155,7 +155,7 @@ func TestRequireIfAttributeIsOneOfValidator(t *testing.T) { types.Int64Value(10), }, expError: true, - expErrorMessage: "If foo attribute is set and the value is one of 10, this attribute is required", + expErrorMessage: "If foo attribute is set and the value is one of 10, this attribute is REQUIRED", }, "baseBool": { req: internal.RequireIfAttributeIsOneOfRequest{ @@ -186,7 +186,7 @@ func TestRequireIfAttributeIsOneOfValidator(t *testing.T) { types.BoolValue(true), }, expError: true, - expErrorMessage: "If foo attribute is set and the value is one of true, this attribute is required", + expErrorMessage: "If foo attribute is set and the value is one of true, this attribute is REQUIRED", }, "path-attribute-is-null": { req: internal.RequireIfAttributeIsOneOfRequest{