Skip to content

Commit

Permalink
fix: Unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
azrod authored and dmicheneau committed Jul 10, 2023
1 parent 0e192ff commit 64a0910
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 13 deletions.
11 changes: 11 additions & 0 deletions .github/workflows/goreport.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: Go Report Card Refresh

on:
release:
types: [published]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: creekorful/[email protected]
42 changes: 37 additions & 5 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
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

7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
<a href="https://github.com/FrangipaneTeam/terraform-plugin-framework-validators/issues">
<img alt="Issues" src="https://img.shields.io/github/issues/FrangipaneTeam/terraform-plugin-framework-validators?style=for-the-badge&logo=bilibili&color=F5E0DC&logoColor=D9E0EE&labelColor=302D41" />
</a>
<a href="https://goreportcard.com/report/github.com/FrangipaneTeam/terraform-plugin-framework-validators">
<img alt="GoReport" src="https://goreportcard.com/badge/github.com/FrangipaneTeam/terraform-plugin-framework-validators?style=for-the-badge" />
</a>
</div>

# terraform-plugin-framework-validators
Expand All @@ -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)
8 changes: 4 additions & 4 deletions internal/null_if_attribute_is_one_of_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down Expand Up @@ -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{
Expand Down Expand Up @@ -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{
Expand Down Expand Up @@ -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{
Expand Down
8 changes: 4 additions & 4 deletions internal/require_if_attribute_is_one_of_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down Expand Up @@ -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{
Expand Down Expand Up @@ -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{
Expand Down Expand Up @@ -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{
Expand Down

0 comments on commit 64a0910

Please sign in to comment.