Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
gregito committed Aug 4, 2023
1 parent a802b9f commit 90b40e6
Show file tree
Hide file tree
Showing 5 changed files with 148 additions and 92 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Build

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
build:
name: Build
runs-on: ubuntu-latest
timeout-minutes: 5

strategy:
matrix:
go-version: [ '1.20', '1.19', '1.18' ]

steps:
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
- uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4.0.1
with:
go-version: ${{ matrix.go-version }}
- name: Setup Terraform
uses: hashicorp/setup-terraform@633666f66e0061ca3b725c73b2ec20cd13a8fdd1 # v2.0.3
with:
terraform_version: '1.4.*'
terraform_wrapper: false

- name: Generate
run: make generate

- name: Confirm no diff
run: |
git diff --compact-summary --exit-code || \
(echo "*** Unexpected differences after code generation. Run 'make generate' and commit."; exit 1)
- name: Build
run: make build
78 changes: 78 additions & 0 deletions .github/workflows/quality.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: Quality

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
lint:
needs: build
name: Code analysis
runs-on: ubuntu-latest
timeout-minutes: 5

strategy:
matrix:
go-version: [ '1.20', '1.19', '1.18' ]

steps:
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
- uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4.0.1
with:
go-version: ${{ matrix.go-version }}
- name: Run linters
uses: golangci/golangci-lint-action@639cd343e1d3b897ff35927a75193d57cfcba299 # v3.6.0
with:
version: latest
args: --timeout 3m
test:
name: 'Terraform Provider Acceptance Tests (OS: ${{ matrix.os }} / TF: ${{ matrix.terraform }})'
needs: lint
runs-on: ${{ matrix.os }}
timeout-minutes: 15

strategy:
fail-fast: false
matrix:
os:
- macos-latest
- windows-latest
- ubuntu-latest
terraform:
- '1.0.*'
- '1.1.*'
- '1.2.*'
- '1.3.*'
- '1.4.*'

steps:
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
- uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4.0.1
with:
go-version-file: 'go.mod'

- name: Setup Terraform ${{ matrix.terraform }}
uses: hashicorp/setup-terraform@633666f66e0061ca3b725c73b2ec20cd13a8fdd1 # v2.0.3
with:
terraform_version: ${{ matrix.terraform }}
terraform_wrapper: false

- name: Run acceptance test
run: make testacc
coverage:
name: 'Terraform Provider quality gate :: unit test coverage.'
needs: test
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
- uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4.0.1
with:
go-version-file: 'go.mod'
- name: Go Coverage
uses: gwatts/[email protected]
with:
coverage-threshold: 6.7 # current (2023.08.03) state, should be increased - ideally up to at least 50% - as soon as possible
#cover-pkg: ./...
88 changes: 0 additions & 88 deletions .github/workflows/test.yml

This file was deleted.

13 changes: 9 additions & 4 deletions resources/datalake/resource_azure_datalake.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,17 @@ import (
"context"
"time"

"github.com/cloudera/terraform-provider-cdp/cdp-sdk-go/cdp"
"github.com/cloudera/terraform-provider-cdp/cdp-sdk-go/gen/datalake/client/operations"
datalakemodels "github.com/cloudera/terraform-provider-cdp/cdp-sdk-go/gen/datalake/models"
"github.com/cloudera/terraform-provider-cdp/utils"
"github.com/hashicorp/terraform-plugin-framework/attr"
"github.com/hashicorp/terraform-plugin-framework/diag"
"github.com/hashicorp/terraform-plugin-framework/resource"
"github.com/hashicorp/terraform-plugin-framework/types"
"github.com/hashicorp/terraform-plugin-framework/types/basetypes"
"github.com/hashicorp/terraform-plugin-log/tflog"

"github.com/cloudera/terraform-provider-cdp/cdp-sdk-go/cdp"
"github.com/cloudera/terraform-provider-cdp/cdp-sdk-go/gen/datalake/client/operations"
datalakemodels "github.com/cloudera/terraform-provider-cdp/cdp-sdk-go/gen/datalake/models"
"github.com/cloudera/terraform-provider-cdp/utils"
)

var (
Expand Down Expand Up @@ -362,3 +363,7 @@ func (r *azureDatalakeResource) Delete(ctx context.Context, req resource.DeleteR
return
}
}

func SomethingToTest(a int, b int) int {
return a + b
}
22 changes: 22 additions & 0 deletions resources/datalake/resource_azure_datalake_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Copyright 2023 Cloudera. All Rights Reserved.
//
// This file is licensed under the Apache License Version 2.0 (the "License").
// You may not use this file except in compliance with the License.
// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.
//
// This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
// OF ANY KIND, either express or implied. Refer to the License for the specific
// permissions and limitations governing your use of the file.

package datalake

import (
"fmt"
"testing"
)

func TestDummy(t *testing.T) {
//t.Errorf("Not even a dummy works ¯\\_(ツ)_/¯")
a := SomethingToTest(1, 2)
fmt.Println(a)
}

0 comments on commit 90b40e6

Please sign in to comment.